From df8e8b83550c11e594090c0d7994f7602cb10ecf Mon Sep 17 00:00:00 2001 From: a Date: Sun, 18 Dec 2022 12:53:49 -0600 Subject: [PATCH] config file --- config/config.json | 35 +++++++++++++++++++++ index.html | 23 ++------------ src/script.js | 76 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 97 insertions(+), 37 deletions(-) create mode 100644 config/config.json diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..981c1d2 --- /dev/null +++ b/config/config.json @@ -0,0 +1,35 @@ +{ + "search_engine": "https://www.google.com/search", + "categories": [ + { + "image": "res/4chan.png", + "links": [ + {"href":"https://boards.4chan.org/w/", "label":"walls"}, + {"href":"https://boards.4chan.org/g/", "label":"tech"}, + {"href":"https://boards.4chan.org/a/", "label":"anime"}, + {"href":"https://boards.4chan.org/mu/", "label":"music"} + ] + }, + { + "image": "res/social.png", + "links": [ + {"href":"https://facebook.com", "label":"facebook"}, + {"href":"https://youtube.com/", "label":"youtube"}, + {"href":"https://tumblr.com", "label":"tumblr"} + ] + }, + { + "image": "res/music.png", + "links": [ + {"href":"https://last.fm", "label":"last.fm"}, + {"href":"https://bandcamp.com/", "label":"bandcamp"} + ] + }, + { + "image": "res/mail.png", + "links": [ + {"href":"https://mail.google.com", "label":"gmail"} + ] + } + ] +} diff --git a/index.html b/index.html index d37aadf..6778321 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@  - + @@ -12,25 +12,6 @@

-
- - walls - tech - anime - music -
- - facebook - youtube - tumblr -
- - last.fm - bandcamp -
- - gmail -
-
+
diff --git a/src/script.js b/src/script.js index a3cf8af..217ba5e 100644 --- a/src/script.js +++ b/src/script.js @@ -1,28 +1,72 @@ +const updateTime = () => { + const n = (new Date()).getHours() + var imgName = "goodnight" + if ( n == 23 || n == 0) { + imgName = "goodnight" + } else if ( n >= 1 && n <= 4 ) { + imgName = "goodnight" + } else if ( n >= 5 && n <= 11 ) { + imgName = "goodmorning" + } else if ( n >= 12 && n <= 17 ) { + imgName = "goodafternoon" + } else if ( n >= 18 && n <= 22 ) { + imgName = "goodevening" + } + //$("#message").html(imgName) + $("#message").html(``) +} -var d = new Date(); -var n = d.getHours(); -var message = "" +const renderCategoryLink = (link, first) => { + if(first) { + return `${link.label} +` + } + return `${link.label} +` +} +const renderCategoryLinks = (links) => { + let out = "" + for(let i = 0; i < links.length; i++) { + out = out + renderCategoryLink(links[i], i==0) + } + return out +} -if ( n == 23 || n == 0) { - message = ""; -} else if ( n >= 1 && n <= 4 ) { - message = ""; -} else if ( n >= 5 && n <= 11 ) { - message = ""; -} else if ( n >= 12 && n <= 17 ) { - message = ""; -} else if ( n >= 18 && n <= 22 ) { - message = ""; +const renderCategory =(obj) => { + return ` +${renderCategoryLinks(obj.links)}
+` +} +const renderCategories =(objs) => { + let out = "" + for(let i = 0; i < objs.length; i++) { + out = out + renderCategory(objs[i]) + } + return out +} + +const renderCategoriesBox = (data) => { + return `${renderCategories(data.categories)} + +` +} + +const loadUI = () => { + $.getJSON("config/config.json", (data)=>{ + let drawn = renderCategoriesBox(data) + console.log(drawn) + $("#categories").html(drawn) + }) } $(()=>{ - document.getElementById("message").innerHTML = message; + loadUI(); + updateTime(); + setInterval(updateTime, 1000 * 60) }) - $(window).scroll(function() { $('#animatedElement').each(function(){ var imagePos = $(this).offset().top; - var topOfWindow = $(window).scrollTop(); if (imagePos < topOfWindow+400) { $(this).addClass("slideUp");