fix: countdown
This commit is contained in:
parent
3a3499cd8b
commit
d636bcb3e7
|
|
@ -268,9 +268,9 @@
|
||||||
// Countdown timer
|
// Countdown timer
|
||||||
const timerEl = document.getElementById('timer');
|
const timerEl = document.getElementById('timer');
|
||||||
if (timerEl) {
|
if (timerEl) {
|
||||||
const expires = new Date(timerEl.dataset.expires).getTime();
|
let left = <%= remainingSec %>;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const left = Math.max(0, Math.floor((expires - Date.now()) / 1000));
|
left = Math.max(0, left - 1);
|
||||||
timerEl.textContent = Math.floor(left / 60) + ':' + String(left % 60).padStart(2, '0');
|
timerEl.textContent = Math.floor(left / 60) + ':' + String(left % 60).padStart(2, '0');
|
||||||
if (left <= 0) location.reload();
|
if (left <= 0) location.reload();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue