Skip to content

Commit

Permalink
layout-contact-and-imprint-improved-all-now-readable--data-from-json-…
Browse files Browse the repository at this point in the history
…file-from-utils-function-and-not-from-mongo
  • Loading branch information
ti ko authored and ti ko committed Dec 27, 2023
1 parent 1788383 commit b6a6fe4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion layouts/contact/single.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ partial "head.html" }}
<div id="contact">
<h3 style="margin-top: 130px;margin-bottom: 30px;">Kontakt</h3>
<h3 style="margin-top: 60px;margin-bottom: 30px;">Kontakt</h3>

{{.Content}}

Expand Down
4 changes: 2 additions & 2 deletions layouts/imprint/single.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ partial "head.html" }}
<div id="imprint" style="margin-bottom: 100px;">
<h3 style="margin-top: 130px;margin-bottom: 30px">Imprint</h3>
<div id="imprint">
<h3 style="margin-top: 60px">Imprint</h3>

{{.Content}}

Expand Down
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ partial "head.html" }}

<h2
style="margin-bottom: 50px; 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;">
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</h2>


Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</script>
</head>

<body>
<div id=container class="container">
<body style="width:800px;padding-top: 80px;margin-left: auto;margin-right: auto;">
<div id=container class="container" style="padding-bottom: 80px;">
<div id="topnav">
<h4 class="mt-5 mb-3" style="color: white;">
Timo' s online classes
Expand Down
37 changes: 18 additions & 19 deletions static/client.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@

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
container.append(main_div)
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')
Expand All @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
float: left;
color: #f2f2f2;
text-decoration: none;
padding: 14px 16px;
padding: 10px 10px;
}

/* Change the color of links on hover */
Expand Down

0 comments on commit b6a6fe4

Please sign in to comment.