simple-web-countdown

A simple, configurable web page which counts down to a particular time.
git clone https://git.sr.ht/~jbauer/simple-web-countdown
Log | Files | Refs | README | LICENSE

commit cb9a46bd00106ab192fa24e85caf70b7f3ddd741
parent 57401a896d0e2031295b98a0510077697dd58599
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu,  8 Jul 2021 20:23:36 -0400

Fix display of !!!HYPE!!! message

Diffstat:
Mindex.html | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/index.html b/index.html @@ -45,18 +45,21 @@ let x = setInterval(function() { let now = new Date().getTime(); distance = countdownDate - now; - clock = document.getElementById("clock"); - if (distance < 0) { - clearInterval(x); - clock.innerHTML = "!!!HYPE!!!"; - document.getElementById("event").innerHTML = "It's " + eventName + " time!"; - } + let days = Math.floor(distance / (1000 * 60 * 60 * 24)); let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); let seconds = Math.floor((distance % (1000 * 60)) / 1000); + + clock = document.getElementById("clock"); clock.innerHTML = days + "d " + ("00" + hours).slice(-2) + ":" + ("00" + minutes).slice(-2) + ":" + ("00" + seconds).slice(-2); + + if (distance < 0) { + clearInterval(x); + clock.innerHTML = "!!!HYPE!!!"; + document.getElementById("event").innerHTML = "It's " + eventName + " time!"; + } }, 1000); </script> </body>