File size: 793 Bytes
3af6d41 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | (() => {
const timer = document.querySelector("[data-assignment-timer]");
if (!timer) return;
const expiresAt = Date.parse(timer.dataset.expiresAt || "");
if (!Number.isFinite(expiresAt)) return;
const render = () => {
const remaining = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000));
const minutes = Math.floor(remaining / 60);
const seconds = remaining % 60;
timer.textContent = `${minutes}:${String(seconds).padStart(2, "0")} remaining`;
if (remaining === 0) {
document.querySelectorAll(".assignment-form input, .assignment-form button").forEach((control) => {
control.disabled = true;
});
window.location.reload();
return true;
}
return false;
};
if (!render()) window.setInterval(render, 1000);
})();
|