From b2c3868619f1e530db8c3ee9b8657be9b10d01bd Mon Sep 17 00:00:00 2001 From: Niklas Ye Date: Sat, 26 Sep 2026 10:21:54 +0200 Subject: [PATCH] Fix the web UI stuck on its loading spinner format.js defined isoWeek twice. 9d1df2b added a second copy for the week numbers on the rota without noticing the first, which already exported the same function. A duplicate function declaration is legal in a plain script but an early SyntaxError in an ES module, so the browser refused format.js, every module importing it, and with them app.js. Its boot() is what hides the spinner, so nothing ever did. Keeps the first definition, whose comment explains the Thursday rule, and drops the second. Both give ISO 8601 numbers; the one kept was checked against 2026-01-01 (week 1), 2026-09-28 (40), 2026-12-31 (53) and 2024-12-30 (1). oncall.js and team.js import the name unchanged. The suite could not see this: it has no JS, and node --check reads a .js file as a script, where the redeclaration passes. Checking each file as a module (.mjs) does catch it. --- internal/web/static/js/format.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/internal/web/static/js/format.js b/internal/web/static/js/format.js index c50ba1e..8861f0a 100644 --- a/internal/web/static/js/format.js +++ b/internal/web/static/js/format.js @@ -82,15 +82,6 @@ export function addDays(d, n) { return r; } -// ISO 8601 week number. -export function isoWeek(d) { - const t = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); - const day = t.getUTCDay() || 7; - t.setUTCDate(t.getUTCDate() + 4 - day); - const yearStart = new Date(Date.UTC(t.getUTCFullYear(), 0, 1)); - return Math.ceil(((t - yearStart) / DAY + 1) / 7); -} - export const STATUS_LABEL = { triggered: 'Triggered', acknowledged: 'Acknowledged',