aboutsummaryrefslogtreecommitdiff
path: root/src/js/background.js
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2021-02-23 20:09:29 -0600
committerMark Powers <mark@marks.kitchen>2021-02-23 20:09:29 -0600
commit8a0a3a00e75dc2351a7218d0059b87f7e9345871 (patch)
tree180a3dc0065db849301d0e87c11f129475c02eb5 /src/js/background.js
parent4ed0b48232f2d0fdaa1ed85f243119608d2d5caf (diff)
parent5b5dc610bc0da17fd006982de50b4dc74b134a54 (diff)
Merge branch 'master' of marks.kitchen:/srv/git/markskitchen
Diffstat (limited to 'src/js/background.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)
+