diff --git a/index.html b/index.html index a6f1b16..3191919 100644 --- a/index.html +++ b/index.html @@ -45,18 +45,21 @@ let x = setInterval(function() { let now = new Date().getTime(); 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.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!"; } - 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);