attribution, small fix
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Thanks to https://codepen.io/rebelchris/pen/abZRpqM
|
||||
let timer = null;
|
||||
function startCountdown(dateString) {
|
||||
if (timer) clearInterval(timer);
|
||||
@@ -7,7 +8,7 @@ function startCountdown(dateString) {
|
||||
if (dateString == "None") cd.classList.add("hide");
|
||||
}
|
||||
const end = new Date(dateString).getTime();
|
||||
const dayEl = document.getElementById('days');
|
||||
const daysEl = document.getElementById('days');
|
||||
const hoursEl = document.getElementById('hours');
|
||||
const minutesEl = document.getElementById('minutes');
|
||||
const secondsEl = document.getElementById('seconds');
|
||||
@@ -17,7 +18,7 @@ function startCountdown(dateString) {
|
||||
const days = hours * 24;
|
||||
timer = setInterval(updateTime, seconds);
|
||||
function updateTime() {
|
||||
if (dayEl) {
|
||||
if (daysEl) {
|
||||
let now = new Date().getTime();
|
||||
const difference = end - now;
|
||||
|
||||
@@ -27,7 +28,7 @@ function startCountdown(dateString) {
|
||||
return;
|
||||
}
|
||||
|
||||
dayEl.innerText = Math.floor(difference / days);
|
||||
daysEl.innerText = Math.floor(difference / days);
|
||||
hoursEl.innerText = Math.floor( (difference % days) / hours );
|
||||
minutesEl.innerText = Math.floor( (difference % hours) / minutes );
|
||||
secondsEl.innerText = Math.floor( (difference % minutes) / seconds );
|
||||
|
||||
Reference in New Issue
Block a user