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:
1 parent
ef69462e06
commit
1de02ade1e
1 file changed
+4
-2
+4
-2
@@ -3,13 +3,15 @@ function tick() {
|
||||
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 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");
|
||||
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();
|
||||
setInterval(tick, 1000);
|
||||
htmx.onLoad(tick); // horloges arrivées par htmx (ex. header)
|
||||
|
||||
// Show server errors from htmx requests in a toast.
|
||||
let toastTimer;
|
||||
|
||||
Reference in new issue
Block a user