From 8c4d2dfb03c22893b2a06cccc78c4aa7af84f3a7 Mon Sep 17 00:00:00 2001 From: swaggboi Date: Tue, 25 Jun 2024 17:23:54 -0400 Subject: [PATCH] Automate the background --- README.md | 4 ---- public/css/elements.css | 8 -------- public/js/background.js | 23 +++++++++++++++++++++++ templates/layouts/default.html.ep | 7 ++++--- 4 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 public/js/background.js diff --git a/README.md b/README.md index e96a53f..31d5aa9 100644 --- a/README.md +++ b/README.md @@ -60,13 +60,9 @@ tests locally: ## TODOs -1. Re-visit this TODO list because it doesn't seem like I'm gunna - bother with all new posts flagged mode lmao. There's a CAPTCHA now - so it's not as painfully open... 1. Automate the holiday backgrounds with JS 1. Test JS with LibreJS or something like that (I don't like RMS I just want free JS!!) -1. "All new posts flagged" mode (require approval for new posts) 1. Tests for mod-only user? ## Crazy future ideas diff --git a/public/css/elements.css b/public/css/elements.css index 63b173b..6a2f60b 100644 --- a/public/css/elements.css +++ b/public/css/elements.css @@ -28,14 +28,6 @@ body { background-image: url('/images/background_stars_anm.gif'); - /* Was feelin this for September idk */ - /* background-image: url('/images/topwwbackground.gif'); */ - /* Spooky time! */ - /* background-image: url('/images/halloween_background_1.gif'); */ - /* Winter/snow */ - /* background-image: url('/images/jwsfp1.gif'); */ - /* Christmas */ - /* background-image: url('/images/christmas.gif'); */ width: 95vmin; margin: 0 auto; font-family: 'w95fa', sans-serif; diff --git a/public/js/background.js b/public/js/background.js new file mode 100644 index 0000000..1ae8ca2 --- /dev/null +++ b/public/js/background.js @@ -0,0 +1,23 @@ +const bodyStyle = document.body.style; + +function setImage(url) { + bodyStyle.backgroundImage = "url('" + url + "')"; +} + +switch (new Date().getMonth()) { + case 0: + setImage('/images/jwsfp1.gif'); + break; + case 3: + setImage('/images/background2.gif'); + break; + case 9: + setImage('/images/halloween_background_1.gif'); + break; + case 10: + setImage('/images/topwwbackground.gif'); + break; + case 11: + setImage('/images/christmas.gif'); + break; +} diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index e162ea1..99cb6f8 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -29,9 +29,10 @@ content="<%= url_for('/images/logo.png')->to_abs %>"> - <%= stylesheet '/css/elements.css' %> - <%= stylesheet '/css/simple.css' %> - <%= stylesheet '/css/nested.css' %> + <%= stylesheet '/css/elements.css' %> + <%= stylesheet '/css/simple.css' %> + <%= stylesheet '/css/nested.css' %> + <%= javascript '/js/background.js', defer => undef %>