diff --git a/CHANGELOG.md b/CHANGELOG.md index 6249180..e8dcc4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.54 - 2026-11-16 + +- Overlay and OBS: the Gap column showed the gap to the car in front, the same as Gap ahead. It now shows the gap to the leader (e.g. +1L for a lapped car), and the leader shows -. + ## 1.89.53 - 2026-11-16 - The lap times table in a heat's print and PDF is now a choice: **Lap times in 🖨/PDF** next to Print / PDF / CSV in the race overview (remembered, off by default). Off, a heat prints on one page with the result and the lap chart, as before. diff --git a/package-lock.json b/package-lock.json index 3ff0988..c8d1205 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.53", + "version": "1.89.54", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.53", + "version": "1.89.54", "hasInstallScript": true, "license": "AGPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index b166210..9ca49f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.53", + "version": "1.89.54", "private": true, "license": "AGPL-3.0-or-later", "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", diff --git a/src/overlays.js b/src/overlays.js index 4fbe810..0e0b46b 100644 --- a/src/overlays.js +++ b/src/overlays.js @@ -2,6 +2,10 @@ import { rowFlag } from "./country_flags.js"; import { sortValuesAttribute } from "./list_sorting.js"; import { escapeHtml as escapeHtmlLocal } from "./html_escape.js"; import { overlayLiveMarks, passingFlashAttrs, renderLiveMarkBadges } from "./overlay_live_marks.js"; + +// Gap = to the leader, Gap ahead = to the car in front (both from buildLeaderboard). The leader +// itself shows "-". gapDisplay is only set by older callers and tests. +const leaderGapOf = (row) => row.leaderGap || row.gapDisplay || ""; export function getOverlayModeLabel(mode, { t }) { return t(`overlay.mode_${String(mode || "leaderboard").toLowerCase()}`); } @@ -82,7 +86,7 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive const posClass = idx === 0 ? "pos-1" : idx === 1 ? "pos-2" : idx === 2 ? "pos-3" : ""; const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute(practiceRank ? [idx + 1, row.displayName || row.driverName, row.practiceMetric?.comparableMs ?? null, row.gapDisplay || null, row.bestLapMs || null] - : [idx + 1, row.displayName || row.driverName, row.laps ?? 0, lastLap ? row.lastLapMs || null : row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : ""; + : [idx + 1, row.displayName || row.driverName, row.laps ?? 0, lastLap ? row.lastLapMs || null : row.resultDisplay, (idx === 0 ? null : leaderGapOf(row) || null), row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : ""; const linkAttrs = driverLinks && row.driverId && !row.teamId ? ` data-training-driver="${escapeHtml(row.driverId)}" title="${escapeHtml(t("overlay.open_training_stats"))}"` : ""; const mark = liveMarks.get(String(row.key ?? "")); const flash = passingFlashAttrs(mark); @@ -116,7 +120,7 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
- ${escapeHtml(row.gapDisplay || row.gapAhead || "-")} + ${escapeHtml(idx === 0 ? "-" : leaderGapOf(row) || "-")}
${practiceRank ? "" : `
@@ -246,7 +250,7 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa last: row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-", result: escapeHtml(timeOnly(row.resultDisplay)), best: Number.isFinite(row.bestLapMs) ? escapeHtml(formatLap(row.bestLapMs)) : "-", - gap: escapeHtml(idx === 0 ? "" : row.gapDisplay || row.gapAhead || ""), + gap: escapeHtml(idx === 0 ? "" : leaderGapOf(row) || ""), }; // Pit clock and split at the end of the name column, the one flexible column - in // the time columns they would push every other column out of line. @@ -395,7 +399,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra ${obsConfig.showLaps ? `${t("table.laps")}: ${row.laps ?? 0}` : ""} ${obsConfig.showLast && row.lastLapMs > 0 ? `${t("overlay.col_last")}: ${escapeHtml(formatLap(row.lastLapMs))}` : ""} ${obsShowsResult(active, obsConfig) ? `${t("table.result")}: ${escapeHtml(row.resultDisplay)}` : ""} - ${obsConfig.showGap ? `${t("table.gap")}: ${escapeHtml(row.gapDisplay || row.gapAhead || "-")}` : ""} + ${obsConfig.showGap ? `${t("table.gap")}: ${escapeHtml(idx === 0 ? "-" : leaderGapOf(row) || "-")}` : ""} `; }).join("")} @@ -433,7 +437,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra obsConfig.showLast ? `${row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-"}` : "", obsShowsResult(active, obsConfig) ? `${escapeHtml(row.resultDisplay)}` : "", obsConfig.showBest ? `${formatLap(row.bestLapMs)}` : "", - obsConfig.showGap ? `${escapeHtml(row.gapDisplay || row.gapAhead || "-")}` : "", + obsConfig.showGap ? `${escapeHtml(idx === 0 ? "-" : leaderGapOf(row) || "-")}` : "", ] .filter(Boolean) .join(""); diff --git a/tests/overlay_leaderboard.test.js b/tests/overlay_leaderboard.test.js index abf9168..1bb8181 100644 --- a/tests/overlay_leaderboard.test.js +++ b/tests/overlay_leaderboard.test.js @@ -62,7 +62,9 @@ test("practice ranked on 3 laps in a row: only result, gap and best lap as times assert.equal(isPracticeRankedSession({ type: "qualification" }), false, "qualifier on laps and time: full view, like a final"); assert.equal(isPracticeRankedSession({ type: "final" }), false); const row = { key: "a", driverId: "a", displayName: "Anna", laps: 12, resultDisplay: "3 varv 55.123", gapDisplay: "+0.747s", gapAhead: "+0.2", lapDelta: "-0.1", bestLapMs: 18201, lastLapMs: 18777, predictedRemainingMs: 9000 }; - const html = renderOverlayLeaderboard([row], deps, { practiceRank: true }); + // The leader shows "-" as its gap; the gap is checked on the driver behind it. + const leader = { key: "l", driverId: "l", displayName: "Lea", laps: 12, resultDisplay: "3 varv 54.376", leaderGap: "Leader", bestLapMs: 18001 }; + const html = renderOverlayLeaderboard([leader, { ...row, leaderGap: "+0.747s" }], deps, { practiceRank: true }); assert.match(html, /overlay-race-list-ranked/); assert.match(html, /pos-pill pos-1">1table\.result<\/label>\s*3 varv 55\.123<\/strong>/); @@ -77,3 +79,17 @@ test("a driver's country: a small local flag before the name on the overlay; non assert.match(withFlag, /]*\/>Roy/); assert.doesNotMatch(renderOverlayLeaderboard(rows(1), deps), /country-flag/); }); + +test("overlay Gap is the gap to the leader and Gap ahead the gap to the car in front", () => { + const rows = [ + { key: "a", driverId: "a", displayName: "A", laps: 16, resultDisplay: "16/4:47.959", leaderGap: "Leader", gapAhead: "-" }, + { key: "b", driverId: "b", displayName: "B", laps: 15, resultDisplay: "15/4:31.848", leaderGap: "+1L", gapAhead: "+1L" }, + { key: "c", driverId: "c", displayName: "C", laps: 15, resultDisplay: "15/4:36.430", leaderGap: "+1L", gapAhead: "+4.582s" }, + ]; + const html = renderOverlayLeaderboard(rows, deps, {}); + const third = html.slice(html.indexOf('data-overlay-competitor="c"')); + assert.match(third, /