From 3da666aa029e0da215431c72346d6be7b773a032 Mon Sep 17 00:00:00 2001 From: Sangelo Date: Mon, 8 Jul 2024 10:45:36 +0200 Subject: [PATCH] [a] countdown page additions --- static/internal/countdown/index.html | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/static/internal/countdown/index.html b/static/internal/countdown/index.html index 6f004fb..177334b 100644 --- a/static/internal/countdown/index.html +++ b/static/internal/countdown/index.html @@ -1,10 +1,14 @@ @@ -46,6 +50,7 @@ const countdownElement = document.getElementById("countdown"); const countdownDate = getDateFromUrl(); + const showCurrentTime = getTimeFromUrl(); function updateCountdown() { const now = new Date().getTime(); @@ -71,6 +76,16 @@ requestAnimationFrame(updateCountdown); } + function updateTime() { + const now = new Date(); + const hours = formatWithLeadingZeros(now.getHours(), 2); + const minutes = formatWithLeadingZeros(now.getMinutes(), 2); + const seconds = formatWithLeadingZeros(now.getSeconds(), 2); + + countdownElement.innerHTML = `${hours}:${minutes}:${seconds}`; + requestAnimationFrame(updateTime); + } + function getDateFromUrl() { const urlParams = new URLSearchParams(window.location.search); const dateParam = urlParams.get('date'); @@ -83,8 +98,16 @@ return new Date("1970-01-01T00:00:00").getTime(); } - requestAnimationFrame(updateCountdown); + function getTimeFromUrl() { + const urlParams = new URLSearchParams(window.location.search); + return urlParams.has('time'); + } + + if (showCurrentTime) { + requestAnimationFrame(updateTime); + } else { + requestAnimationFrame(updateCountdown); + } -