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