Changed JS
This commit is contained in:
parent
fc39535e89
commit
38df9eeb39
15
js/timer.js
15
js/timer.js
@ -15,15 +15,22 @@ var x = setInterval(function() {
|
|||||||
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||||||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 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"
|
// Display the result in the element with id="timer"
|
||||||
|
if (days != 0 && hours != 0) {
|
||||||
document.getElementById("timer").innerHTML = days + "d " + hours + "h";
|
document.getElementById("timer").innerHTML = days + "d " + hours + "h";
|
||||||
// + minutes + "m " + seconds + "s ";
|
}
|
||||||
|
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 the count down is finished, write some text
|
||||||
if (distance < 0) {
|
if (distance < 0) {
|
||||||
clearInterval(x);
|
clearInterval(x);
|
||||||
document.getElementById("timer").innerHTML = "NOW";
|
document.getElementById("timer").innerHTML = "LIVE";
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
Loading…
Reference in New Issue
Block a user