1
0
mirror of https://git.sr.ht/~jbauer/simple-web-countdown synced 2024-11-20 05:34:51 +01:00

Fix display of !!!HYPE!!! message

This commit is contained in:
Jake Bauer 2021-07-08 20:23:36 -04:00
parent 57401a896d
commit cb9a46bd00

View File

@ -45,18 +45,21 @@
let x = setInterval(function() { let x = setInterval(function() {
let now = new Date().getTime(); let now = new Date().getTime();
distance = countdownDate - now; distance = countdownDate - now;
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 = document.getElementById("clock");
clock.innerHTML = days + "d " + ("00" + hours).slice(-2) + ":" +
("00" + minutes).slice(-2) + ":" + ("00" + seconds).slice(-2);
if (distance < 0) { if (distance < 0) {
clearInterval(x); clearInterval(x);
clock.innerHTML = "!!!HYPE!!!"; clock.innerHTML = "!!!HYPE!!!";
document.getElementById("event").innerHTML = "It's " + eventName + " time!"; 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.innerHTML = days + "d " + ("00" + hours).slice(-2) + ":" +
("00" + minutes).slice(-2) + ":" + ("00" + seconds).slice(-2);
}, 1000); }, 1000);
</script> </script>
</body> </body>