From c863dd4ad3e69951ab66b160120e852fdb5dbc5e Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Sun, 17 Nov 2024 13:15:57 +0000 Subject: [PATCH] hello js --- index.php => index.html | 15 +-------------- res/js/dynamic-content.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) rename index.php => index.html (76%) create mode 100644 res/js/dynamic-content.js diff --git a/index.php b/index.html similarity index 76% rename from index.php rename to index.html index 2c8615f..96329a1 100644 --- a/index.php +++ b/index.html @@ -1,10 +1,3 @@ -format('Y'); -$startDate = new DateTime("$currentYear-11-10"); -$endDate = new DateTime(($currentYear + 1) . '-03-01'); -$christmas = ($currentDate > $startDate && $currentDate < $endDate); -?> @@ -13,9 +6,6 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate); ~floppy - - - @@ -30,11 +20,7 @@ $christmas = ($currentDate > $startDate && $currentDate < $endDate); "My life is a living nightmare!"

- -
-
-
+ diff --git a/res/js/dynamic-content.js b/res/js/dynamic-content.js new file mode 100644 index 0000000..a6b12ca --- /dev/null +++ b/res/js/dynamic-content.js @@ -0,0 +1,20 @@ +const christmas = isItChristmas(); + +if (christmas) { + var head = document.getElementsByTagName('head')[0]; + var snowJS = document.createElement("script"); + snowJS.type = "text/javascript"; + snowJS.src = "/res/js/snowstorm.js"; + head.appendChild(snowJS); + + const profileImage = document.querySelector("img.profile-image"); + profileImage.src = "/res/images/profile-christmas.jpg"; +} + +function isItChristmas() { + const currentDate = new Date(); + const currentYear = currentDate.getFullYear(); + const startDate = new Date(`${currentYear}-11-10`); + const endDate = new Date(`${currentYear + 1}-03-01`); + return currentDate > startDate && currentDate < endDate; +}