fix: countdown

This commit is contained in:
nate 2026-03-25 23:08:10 +04:00
parent 3a3499cd8b
commit d636bcb3e7
1 changed files with 2 additions and 2 deletions

View File

@ -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);