ensure number

This commit is contained in:
silverwind 2024-04-29 22:49:32 +02:00
parent 5079641d1a
commit 24c650d3ef
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
1 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,7 @@ export function initStopwatch() {
// global stop watch (in the head_navbar), it should always work in any case either the EventSource or the PeriodicPoller is used.
const seconds = stopwatchEls[0]?.getAttribute('data-seconds');
if (seconds) {
updateStopwatchTime(seconds);
updateStopwatchTime(parseInt(seconds));
}
for (const stopwatchEl of stopwatchEls) {
@ -144,6 +144,7 @@ function updateStopwatchData(data) {
}
function updateStopwatchTime(seconds) {
if (!Number.isFinite(seconds)) return;
const datetime = (new Date(Date.now() - seconds * 1000)).toISOString();
for (const parent of document.querySelectorAll('.header-stopwatch-dot')) {
const existing = parent.querySelector(':scope > relative-time');