From 572671a916335fbbe8766b37b683b8a585c49abd Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Thu, 24 Dec 2020 12:48:58 -0600 Subject: Add background changer and css --- src/css/styles.css | 12 +++++++++++- src/icon/favicon.ico | Bin 1150 -> 0 bytes src/icon/favicon.svg | 1 - src/js/background.js | 29 +++++++++++++++++++++++++++++ src/res/change.jpg | Bin 0 -> 4689611 bytes src/res/day.jpg | Bin 0 -> 3710493 bytes src/res/favicon.ico | Bin 0 -> 1150 bytes src/res/favicon.svg | 1 + src/res/night.jpg | Bin 0 -> 4125007 bytes src/server.js | 9 ++++++--- src/templates/footer.html | 6 +++++- src/templates/navigation.html | 18 ++++++++---------- 12 files changed, 60 insertions(+), 16 deletions(-) delete mode 100644 src/icon/favicon.ico delete mode 100644 src/icon/favicon.svg create mode 100644 src/js/background.js create mode 100644 src/res/change.jpg create mode 100644 src/res/day.jpg create mode 100644 src/res/favicon.ico create mode 100644 src/res/favicon.svg create mode 100644 src/res/night.jpg diff --git a/src/css/styles.css b/src/css/styles.css index ab634ec..3a555cb 100644 --- a/src/css/styles.css +++ b/src/css/styles.css @@ -11,11 +11,16 @@ body { - width: 80%; + width: 60%; + min-width: 500px; margin: auto; /* margin: 0px; */ background-color: var(--background); font-family: Arial, Helvetica, sans-serif; + height: 100%; + background-position: center; + background-repeat: no-repeat; + background-size: cover; } h1, h2 { @@ -119,12 +124,17 @@ p { border-top: 1px solid var(--light-text); border-bottom: 1px solid var(--light-text); background-color: var(--background-accent); + display: flex; + flex-wrap: wrap; + justify-content: space-evenly; } + .titlebar a{ margin: auto; max-width: 10%; min-width: 100px; + flex-grow: 1; } .btn { diff --git a/src/icon/favicon.ico b/src/icon/favicon.ico deleted file mode 100644 index 7646b67..0000000 Binary files a/src/icon/favicon.ico and /dev/null differ diff --git a/src/icon/favicon.svg b/src/icon/favicon.svg deleted file mode 100644 index ad339b8..0000000 --- a/src/icon/favicon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/js/background.js b/src/js/background.js new file mode 100644 index 0000000..f8a7684 --- /dev/null +++ b/src/js/background.js @@ -0,0 +1,29 @@ +function set_background_image(){ + let date = new Date(); + let current_hour = date.getHours() + if(current_hour <= 8 || current_hour >= 20){ + var photo = "night.jpg" + } else if(current_hour <= 10 || current_hour > 17){ + var photo = "change.jpg" + } else { + var photo = "day.jpg" + } + let btn = document.getElementById("loadBtn") + if(btn){ + btn.remove() + } + if(!document.getElementById("backgroundId")){ + document.body.style.backgroundImage = `url('/res/${photo}')`; + let desc = document.createElement("p") + desc.id = "backgroundId" + desc.innerHTML = "Background images in the public domain, painted by Ivan Konstantinovich Aivazovsky." + footer.appendChild(desc) + } +} +let el = document.createElement("a") +el.id = "loadBtn" +el.innerText = "load background" +el.onclick = set_background_image +let footer = document.getElementsByTagName("footer")[0] +footer.appendChild(el) + diff --git a/src/res/change.jpg b/src/res/change.jpg new file mode 100644 index 0000000..0d0b1c3 Binary files /dev/null and b/src/res/change.jpg differ diff --git a/src/res/day.jpg b/src/res/day.jpg new file mode 100644 index 0000000..13c115c Binary files /dev/null and b/src/res/day.jpg differ diff --git a/src/res/favicon.ico b/src/res/favicon.ico new file mode 100644 index 0000000..7646b67 Binary files /dev/null and b/src/res/favicon.ico differ diff --git a/src/res/favicon.svg b/src/res/favicon.svg new file mode 100644 index 0000000..ad339b8 --- /dev/null +++ b/src/res/favicon.svg @@ -0,0 +1 @@ + diff --git a/src/res/night.jpg b/src/res/night.jpg new file mode 100644 index 0000000..9b9471c Binary files /dev/null and b/src/res/night.jpg differ diff --git a/src/server.js b/src/server.js index 81f1edb..d820cd7 100644 --- a/src/server.js +++ b/src/server.js @@ -324,8 +324,8 @@ function setUpRoutes(models, jwtFunctions, database, templates) { }) - server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/icon/favicon.ico")) - server.get('/favicon.svg', (req, res) => res.sendFile(__dirname + "/icon/favicon.svg")) + server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/res/favicon.ico")) + server.get('/favicon.svg', (req, res) => res.sendFile(__dirname + "/res/favicon.svg")) server.get('/css/:id', (req, res) => { res.sendFile(__dirname + "/css/" + req.params.id); }); @@ -338,6 +338,9 @@ function setUpRoutes(models, jwtFunctions, database, templates) { server.get('/js/:id', (req, res) => { res.sendFile(__dirname + "/js/" + req.params.id); }); + server.get('/res/:id', (req, res) => { + res.sendFile(__dirname + "/res/" + req.params.id); + }); server.get('/feed.xml', async (req, res) => { var feed = new rss({ @@ -345,7 +348,7 @@ function setUpRoutes(models, jwtFunctions, database, templates) { description: "Posts from marks.kitchen", feed_url: "https://marks.kitchen/rss", site_url: "https://marks.kitchen", - webMaster: "webmaster@marks.kitchen", + webMaster: "webmaster@marks.kitchen (Mark Powers)", copyright: "Mark Powers" }) var posts = await models.posts.findAll({ diff --git a/src/templates/footer.html b/src/templates/footer.html index 617b5fa..6dc5a48 100644 --- a/src/templates/footer.html +++ b/src/templates/footer.html @@ -11,4 +11,8 @@
- \ No newline at end of file +
+ + +
+ diff --git a/src/templates/navigation.html b/src/templates/navigation.html index ab53b13..b101bab 100644 --- a/src/templates/navigation.html +++ b/src/templates/navigation.html @@ -1,12 +1,10 @@ -- cgit v1.2.3