diff --git a/js/timer.js b/js/timer.js index 1b43910..78d80ea 100644 --- a/js/timer.js +++ b/js/timer.js @@ -15,15 +15,22 @@ var x = setInterval(function() { var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); - var seconds = Math.floor((distance % (1000 * 60)) / 1000); + // var seconds = Math.floor((distance % (1000 * 60)) / 1000); - // Display the result in the element with id="demo" - document.getElementById("timer").innerHTML = days + "d " + hours + "h"; - // + minutes + "m " + seconds + "s "; + // Display the result in the element with id="timer" + if (days != 0 && hours != 0) { + document.getElementById("timer").innerHTML = days + "d " + hours + "h"; + } + else if (hours != 0) { + document.getElementById("timer").innerHTML = hours + "h"; + } + else { + document.getElementById("timer").innerHTML = minutes + "m"; + } // If the count down is finished, write some text if (distance < 0) { clearInterval(x); - document.getElementById("timer").innerHTML = "NOW"; + document.getElementById("timer").innerHTML = "LIVE"; } }, 1000); \ No newline at end of file