+
+
+ Timo' s online classes
+
\ No newline at end of file
diff --git a/static/client.js b/static/client.js
index c1a3a0e..7edc9bc 100644
--- a/static/client.js
+++ b/static/client.js
@@ -1,47 +1,88 @@
-var cdn = 'https://cdnjs.cloudflare.com/ajax/libs/'
-var tiko = "Tiko's"
-
document.title = tiko
document.body.style.paddingTop = '90px'
container.style.paddingBottom = '80px'
-async function client(topic = 'index') {
- var topicUp = topic[0].toUpperCase() + topic.slice(1)
- var elem = document.createElement('div')
- container.append(elem)
- elem.id = topic
-
- var hIntro = document.createElement("h4");
- hIntro.classList.add('mt-5', 'mb-3');
- hIntro.innerHTML = topicUp
- elem.prepend(hIntro)
- var aHref = document.createElement("a");
- aHref.textContent = topicUp
- aHref.classList.add('nav')
- aHref.href = '#' + topic
- topnav.append(aHref)
- if (topic === 'index') {
- aHref.classList.add('active')
- aHref.href = '#container'
+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 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')
+ head.textContent = elem
+ head.style.marginTop = '40px'
+ list.append(head)
+ for (var elem2 of res[elem]) {
+ var li = document.createElement('li')
+ li.textContent = elem2.text
+ list.append(li)
+ }
}
- return elem
}
-nav()
-function nav() {
- var aref = document.createElement("a");
- topnav.classList.add('fixed-top', 'bg-dark')
- bottomnav.classList.add('fixed-bottom', 'bg-dark')
- aref.textContent = tiko;
- aref.href = '/'
- aref.classList.add('active', 'nav')
- bottomnav.append(aref)
- for (var elem of ["contact", 'imprint']) {
- var ahref = document.createElement("a");
- ahref.href = '/' + elem;
- ahref.textContent = elem[0].toUpperCase() + elem.slice(1)
- ahref.classList.add('nav')
- bottomnav.append(ahref)
+
+function table(arr) {
+ var excludes = ['_id', '__v', 'cat', 'name', 'url']
+ var table_ = document.createElement('table')
+ var thead = document.createElement('thead')
+ var tr = document.createElement('tr')
+ thead.appendChild(tr)
+ var columns = []
+ for (var elem of arr) {
+ for (var key in elem) {
+ if (excludes.includes(key)) continue
+ if (elem.hasOwnProperty(key) && !columns.includes(key)) {
+ columns.push(key);
+ var th = document.createElement('th')
+ th.appendChild(document.createTextNode(key[0].toUpperCase() + key.slice(1)));
+ tr.appendChild(th);
+ }
+ }
+ }
+ table_.appendChild(thead);
+ var tbody = document.createElement('tbody');
+ for (var elem of arr) {
+ var tr = document.createElement('tr')
+
+ for (var elem2 of columns) {
+ var val = elem[elem2]
+ var td = document.createElement('td');
+
+
+ td.innerHTML = val
+ tr.appendChild(td);
+ }
+ tbody.appendChild(tr)
}
+ table_.appendChild(tbody);
+ table_.classList.add('table', 'table-bordered', 'table-striped')
+ return table_;
}
\ No newline at end of file
diff --git a/static/index.js b/static/index.js
deleted file mode 100644
index 4710533..0000000
--- a/static/index.js
+++ /dev/null
@@ -1,51 +0,0 @@
-// console.log(12)
-var alias_cloud = 'social_cloud'
-var dateformat = /^\d{4}-\d{2}-\d{2}/
-var github = 'https://github.com/'
-var git = github + 'tik9/'
-var git2 = git + 'tik'
-var gitBase = git2 + '/blob/master'
-// var net_host = 'http://localhost'
-var net_host = 'https://tifun.netlify.app'
-var net_fun = '/.netlify/functions/'
-var net_mongo = net_host + net_fun + 'mongo?op=find&coll='
-
-index()
-
-async function index() {
- var index = arguments.callee.name
-
- await client()
- var res = []
- res = await (await fetch(net_mongo + index)).json()
- res = res.filter(val => val.category === 'nachhilfe');
- res = res.map(obj => ({ ...obj, url: '#' + obj.name }))
- // console.log(2, res)
- var div = document.getElementById(index)
- div.append(table(res, index))
- div.classList.add('mt-5')
-
- await subjects();
- (await client('Ihr client')).append(document.createTextNode('Browser: ' + navigator.userAgent));
- await sayings()
-}
-
-async function sayings() {
- var res = (await (await fetch(net_mongo + 'sayings')).json()).filter(val => (val.category === 'german'));
- (await client('Gesagtes')).append(table(res, 'sayings'))
-}
-
-async function subjects() {
- var tools = 'tools'
- res = (await (await fetch(net_mongo + tools)).json()).filter(val => (val.category === 'subject' || val.category === 'language'))
- res = await (await (fetch(net_host + net_fun + 'utils', {
- method: 'post',
- body: JSON.stringify({
- type: 'sortTable',
- val: res,
- sort1: 'tool',
- })
- }))).json()
- var updatedRes = res.map(({ tool }) => ({ Fach: tool }));
- (await client('fächer')).append(table(updatedRes, tools))
-}
\ No newline at end of file
diff --git a/static/nav.js b/static/nav.js
new file mode 100644
index 0000000..e45b25c
--- /dev/null
+++ b/static/nav.js
@@ -0,0 +1,26 @@
+
+// console.log(4)
+
+var tiko = "Tiko's"
+
+var aref = document.createElement("a");
+
+// var test = document.createElement("a");
+// test.classList.add('focus')
+// test.textContent = 'test'
+// test.href = '/'
+// bottomnav.append(test)
+
+topnav.classList.add('fixed-top', 'bg-dark')
+bottomnav.classList.add('fixed-bottom', 'bg-dark')
+aref.textContent = tiko;
+aref.href = '/'
+aref.classList.add('active')
+bottomnav.append(aref)
+for (var elem of ["contact", 'imprint']) {
+ var ahref = document.createElement("a");
+ ahref.href = '/' + elem;
+ ahref.textContent = elem[0].toUpperCase() + elem.slice(1)
+ ahref.classList.add('nav')
+ bottomnav.append(ahref)
+}
\ No newline at end of file
diff --git a/static/style.css b/static/style.css
index c59358c..14b9504 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1,3 +1,7 @@
+.focus:focus {
+ color: wheat;
+}
+
/* Style the links inside the navigation bar */
#topnav a,
#bottomnav a {
@@ -23,17 +27,9 @@ a.active {
@media screen and (max-width: 650px) {
.nav {
- /* a:not(:first-child), */
- /* .nav a:not(:last-child) { */
- /* display: none; */
background-color: transparent;
}
- /* .icon {
- float: right;
- display: block;
- } */
-
.nav.responsive {
position: relative;
}
diff --git a/static/table.js b/static/table.js
deleted file mode 100644
index 7987cf1..0000000
--- a/static/table.js
+++ /dev/null
@@ -1,52 +0,0 @@
-
-function aref(elem, val) {
- var ahref = document.createElement('a')
- ahref.textContent = val
- ahref.href = elem.url
- return ahref
-}
-
-function table(arr, src) {
- var excludes = ['_id', '__v', 'category', 'name', 'url']
- var table_ = document.createElement('table')
- var thead = document.createElement('thead')
- var tr = document.createElement('tr')
- thead.appendChild(tr)
- var columns = []
- for (var elem of arr) {
- for (var key in elem) {
- if (excludes.includes(key)) continue
- if (elem.hasOwnProperty(key) && !columns.includes(key)) {
- columns.push(key);
- if (['author', 'text', 'title'].includes(key)) continue
- var th = document.createElement('th')
- th.appendChild(document.createTextNode(key[0].toUpperCase() + key.slice(1)));
- tr.appendChild(th);
- }
- }
- }
- table_.appendChild(thead);
- var tbody = document.createElement('tbody');
- for (var elem of arr) {
- var tr = document.createElement('tr')
-
- for (var elem2 of columns) {
- var val = elem[elem2]
- var td = document.createElement('td');
-
- if (src == 'index') {
- if (elem2 == 'title') {
- td.append(aref(elem, val))
- }
- else if (elem2 == 'text') td.innerHTML = val
- }
- else td.innerHTML = val
-
- tr.appendChild(td);
- }
- tbody.appendChild(tr)
- }
- table_.appendChild(tbody);
- table_.classList.add('table', 'table-bordered', 'table-striped')
- return table_;
-}
\ No newline at end of file