aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2020-12-24 12:48:58 -0600
committerMark Powers <mark@marks.kitchen>2020-12-24 12:48:58 -0600
commit572671a916335fbbe8766b37b683b8a585c49abd (patch)
tree317feb8a26a87d62977895d860c522498773a976 /src/js
parentee5600aac9548075634f51113f9b5ed078f82e12 (diff)
Add background changer and css
Diffstat (limited to 'src/js')
-rw-r--r--src/js/background.js29
1 files changed, 29 insertions, 0 deletions
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 <a href=\"https://artvee.com/artist/ivan-konstantinovich-aivazovsky/\">Ivan Konstantinovich Aivazovsky.</a>"
+ 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)
+