From 3c781b4265af1260d7da62f1fb3d436d993179fc Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Wed, 3 May 2023 19:39:27 -0400 Subject: [PATCH] no more mr nice countdown --- index.html | 1 - js/index.js | 67 ----------------------------------------------------- 2 files changed, 68 deletions(-) delete mode 100644 js/index.js diff --git a/index.html b/index.html index b9eae07..73c3f46 100644 --- a/index.html +++ b/index.html @@ -89,5 +89,4 @@ - diff --git a/js/index.js b/js/index.js deleted file mode 100644 index ef60feb..0000000 --- a/js/index.js +++ /dev/null @@ -1,67 +0,0 @@ -const title = document.getElementById("title"); - -// This is for the AP exam timer. -const examStart = new Date("May 3, 2023 12:00"); -const examEnd = new Date("May 3, 2023 15:30"); - -const examElement = document.createElement("h3"); -const examLink = document.createElement("a"); -examElement.append(examLink); -examLink.href = "/news/ap-exam.html"; -examLink.id = "ap-timer"; -examLink.target = "_blank"; -if (title != undefined) -{ - // Add the newly created AP exam countdown element. - title.append(examElement); - - // Enable the AP exam countdown. - updateCountdown(); - setInterval(updateCountdown, 1000); -} - -function updateCountdown() -{ - // Difference between now and the desired date in milliseconds. - const now = new Date(Date.now()); - var mode = "waiting"; - - var difference = examStart - now; - if (difference < 0) - { - difference = examEnd - now; - mode = "doing"; - } - if (difference < 0) - { - difference = -difference; - mode = "done"; - } - - // Get minutes and seconds from decimal hours. - var deciHours = difference / (1000 * 60 * 60); - var deciMinutes = (deciHours % 1) * 60; - var deciSeconds = (deciMinutes % 1) * 60; - - var hours = Math.floor(deciHours); - var minutes = Math.floor(deciMinutes); - var seconds = Math.floor(deciSeconds); - - // Construct string and assign it. - var string = `${hours}:${("0" + minutes).slice(-2)}:${("0" + seconds).slice(-2)}`; - switch (mode) - { - case "waiting": - string += " until the AP exam begins!"; - break; - - case "doing": - string += " until the AP exam ends!"; - break; - - case "done": - string += " since the AP exam has been completed!"; - break; - } - examLink.textContent = string; -}