fix: countdown
This commit is contained in:
@@ -268,9 +268,9 @@
|
||||
// Countdown timer
|
||||
const timerEl = document.getElementById('timer');
|
||||
if (timerEl) {
|
||||
const expires = new Date(timerEl.dataset.expires).getTime();
|
||||
let left = <%= remainingSec %>;
|
||||
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');
|
||||
if (left <= 0) location.reload();
|
||||
}, 1000);
|
||||
|
||||
Reference in New Issue
Block a user