Retire les heures à zéro du chrono

0:02, 4:07 puis 1:04:07 ; les horloges chargées par htmx sont mises à
jour dès leur arrivée.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Romulus21andClaude Opus 5.5 committed 2026-11-13 19:07:54 +01:00
1 parent ef69462e06
commit 1de02ade1e
1 file changed
+4 -2
+4 -2
View File
@@ -3,13 +3,15 @@ function tick() {
for (const el of document.querySelectorAll(".clock[data-started]")) { for (const el of document.querySelectorAll(".clock[data-started]")) {
const secs = Math.max(0, Math.floor((Date.now() - Date.parse(el.dataset.started)) / 1000)); const secs = Math.max(0, Math.floor((Date.now() - Date.parse(el.dataset.started)) / 1000));
const h = Math.floor(secs / 3600); const h = Math.floor(secs / 3600);
const m = String(Math.floor((secs % 3600) / 60)).padStart(2, "0"); const m = Math.floor((secs % 3600) / 60);
const s = String(secs % 60).padStart(2, "0"); const s = String(secs % 60).padStart(2, "0");
el.textContent = `${h}:${m}:${s}`; // Pas d'heures à zéro : 4:07, puis 1:04:07.
el.textContent = h ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
} }
} }
tick(); tick();
setInterval(tick, 1000); setInterval(tick, 1000);
htmx.onLoad(tick); // horloges arrivées par htmx (ex. header)
// Show server errors from htmx requests in a toast. // Show server errors from htmx requests in a toast.
let toastTimer; let toastTimer;