From b6a6fe4489f9c9f1ac1b9a141c732fb3abd7d742 Mon Sep 17 00:00:00 2001 From: ti ko Date: Wed, 27 Dec 2023 16:26:08 +0100 Subject: [PATCH] layout-contact-and-imprint-improved-all-now-readable--data-from-json-file-from-utils-function-and-not-from-mongo --- layouts/contact/single.html | 2 +- layouts/imprint/single.html | 4 ++-- layouts/index.html | 2 +- layouts/partials/head.html | 4 ++-- static/client.js | 37 ++++++++++++++++++------------------- static/style.css | 2 +- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/layouts/contact/single.html b/layouts/contact/single.html index 4fe7583..645ba02 100644 --- a/layouts/contact/single.html +++ b/layouts/contact/single.html @@ -1,6 +1,6 @@ {{ partial "head.html" }}
-

Kontakt

+

Kontakt

{{.Content}} diff --git a/layouts/imprint/single.html b/layouts/imprint/single.html index 0db83bf..ddd4418 100644 --- a/layouts/imprint/single.html +++ b/layouts/imprint/single.html @@ -1,6 +1,6 @@ {{ partial "head.html" }} -
-

Imprint

+
+

Imprint

{{.Content}} diff --git a/layouts/index.html b/layouts/index.html index 1580c71..88019d5 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -2,7 +2,7 @@ {{ partial "head.html" }}

+ style="margin-top: 40px; margin-bottom: 70px; font-size: 5rem; color: #fef6e4; text-shadow: 5px 5px 0px #172c66, 10px 10px 0px #001858, 15px 15px 0px #f9bc60,20px 20px 0px #ff8e3c, 25px 25px 0px #9656a1;"> Online math classes

diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 5348fe7..6a98ca7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,8 +8,8 @@ - -
+ +

Timo' s online classes diff --git a/static/client.js b/static/client.js index 7edc9bc..6cd25ba 100644 --- a/static/client.js +++ b/static/client.js @@ -1,17 +1,20 @@ document.title = tiko -document.body.style.paddingTop = '90px' -container.style.paddingBottom = '80px' -var net_host = 'http://localhost' +// var net_host = 'http://localhost' var net_host = 'https://tifun.netlify.app' var net_fun = '/.netlify/functions/' data() async function data() { var data = 'data' - var res = (await (await fetch(net_host + net_fun + 'mongo?op=find&coll=' + data)).json()); - res = await (await (fetch(net_host + net_fun + 'utils', { method: 'post', body: JSON.stringify({ type: 'sortTable', val: res, sort1: 'cat', sort2: 'text' }) }))).json(); + // var res = await (await fetch(net_host + net_fun + 'mongo?op=find&coll=' + data)).json(); + // var res = [{ text: 'Alice', cat: 21 },]; + var utils = 'utils' + var res = await (await (fetch(net_host + net_fun + utils))).json() + + res = await (await (fetch(net_host + net_fun + utils, { method: 'post', body: JSON.stringify({ type: 'sortTable', val: res, sort1: 'cat', sort2: 'text' }) }))).json(); + // console.log(res) var main_div = document.createElement('div') main_div.id = data @@ -19,21 +22,7 @@ async function data() { var list = document.createElement('ul') main_div.append(list) - // res = [ { text: 'Alice', cat: 21 },{ text: 'Max', cat: 20 },{ text: 'Jane', cat: 20 },{ text: 'Jane2', cat: 20 },{ text: 'Jane3', cat: 22 },]; - - function groupBy(objectArray, property) { - return objectArray.reduce(function (acc, obj) { - var key = obj[property]; - if (!acc[key]) { - acc[key] = []; - } - acc[key].push(obj); - return acc; - }, {}); - } - res = groupBy(res, 'cat'); - // console.log(res) for (var elem in res) { var head = document.createElement('h5') @@ -48,6 +37,16 @@ async function data() { } } +function groupBy(objectArray, property) { + return objectArray.reduce((acc, obj) => { + var key = obj[property]; + if (!acc[key]) + acc[key] = []; + + acc[key].push(obj); + return acc; + }, {}); +} function table(arr) { var excludes = ['_id', '__v', 'cat', 'name', 'url'] diff --git a/static/style.css b/static/style.css index 14b9504..57e06fc 100644 --- a/static/style.css +++ b/static/style.css @@ -9,7 +9,7 @@ float: left; color: #f2f2f2; text-decoration: none; - padding: 14px 16px; + padding: 10px 10px; } /* Change the color of links on hover */