feat(overlay): last lap column in the OBS tower and the Open Practice leaderboard (1.89.4)

This commit is contained in:
larssand committed 2026-11-10 19:41:19 +01:00
1 parent f5ff1b9acd
commit d5f81f4290
10 files changed
+73 -16

No files matched your search

+4
View File
@@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet. No changes recorded yet.
## 1.89.4
- Overlay: a Last lap column that changes at every passing. The OBS TV tower and lower third get it (Show last lap, on by default, part of the OBS link), and in an Open Practice ranked on the best lap the leaderboard shows the last lap where the result only repeated the best lap. Ranked on laps in a row or minutes, the result stays (also in the OBS tower, which used to hide it).
## 1.89.3 ## 1.89.3
- Fix: overlays could freeze after a while when the Race Day tab was in the background. Chrome runs background timers about once a minute, and each passing reset the save timer, so laps stopped reaching the server. A waiting save is no longer pushed back, and a hidden tab saves straight away, one write at a time. - Fix: overlays could freeze after a while when the Race Day tab was in the background. Chrome runs background timers about once a minute, and each passing reset the save timer, so laps stopped reaching the server. A waiting save is no longer pushed back, and a hidden tab saves straight away, one write at a time.
+2 -1
View File
@@ -277,7 +277,8 @@ Settings → Audio:
### Overlays and OBS ### Overlays and OBS
The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus an OBS mode with layout (leaderboard, TV graphics, grid, lower third), theme (panel, transparent, chroma), rows and columns: The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus an OBS mode with layout (leaderboard, TV graphics, grid, lower third), theme (panel, transparent, chroma), rows and columns:
- Columns: laps, result, best, gap, and **places since the start** (▲/▼ in heats and finals). - Columns: laps, **last lap**, result, best, gap, and **places since the start** (▲/▼ in heats and finals).
- **Last lap** changes at every passing. In Open Practice, where the result is just the best lap, the leaderboard shows the last lap instead of the result.
- **TV graphics:** a title plate top left (event and heat) and a timing tower top right with the clock on top and real columns: place / **start position** (e.g. "2 / 3"), driver, laps, time, best and gap, in large bold type with podium colours for the top three. No backdrop of its own, so the camera image shows through. The start position can be turned off and is not shown in practice. - **TV graphics:** a title plate top left (event and heat) and a timing tower top right with the clock on top and real columns: place / **start position** (e.g. "2 / 3"), driver, laps, time, best and gap, in large bold type with podium colours for the top three. No backdrop of its own, so the camera image shows through. The start position can be turned off and is not shown in practice.
- **Live marks** in the leaderboard and the TV tower: a driver's row flashes briefly on a new time, a fuel pump badge with a ticking clock shows while the car is in the pits (then the stop time for 5 s), and a new split shows for 4 s with ± against the previous one. They run on the overlay computer's clock, and a freshly opened overlay never flashes every row. - **Live marks** in the leaderboard and the TV tower: a driver's row flashes briefly on a new time, a fuel pump badge with a ticking clock shows while the car is in the pits (then the stop time for 5 s), and a new split shows for 4 s with ± against the previous one. They run on the overlay computer's clock, and a freshly opened overlay never flashes every row.
- The TV title plate has the RaceCore look: the club logo or a red RC mark, the event in small capitals and the heat in Orbitron. - The TV title plate has the RaceCore look: the club logo or a red RC mark, the event in small capitals and the heat in Orbitron.
+2 -1
View File
@@ -290,7 +290,8 @@ Inställningar → Ljud:
### Overlays och OBS ### Overlays och OBS
Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus ett OBS-läge med layout (leaderboard, TV-grafik, grid, lower third), tema (panel, transparent, chroma), rader och kolumner: Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus ett OBS-läge med layout (leaderboard, TV-grafik, grid, lower third), tema (panel, transparent, chroma), rader och kolumner:
- Kolumner: varv, resultat, bästa, gap och **placering sedan start** (▲/▼ i heat och finaler). - Kolumner: varv, **senaste varv**, resultat, bästa, gap och **placering sedan start** (▲/▼ i heat och finaler).
- **Senaste varv** byts vid varje passering. I Open Practice, där resultatet bara är bästa varvet, visar leaderboarden senaste varv i stället för resultat.
- **TV-grafik:** rubrikskylt uppe till vänster (event och heat) och en topplista uppe till höger med klockan överst och raka kolumner: placering / **startplats** (t.ex. "2 / 3"), förare, varv, tid, bästa och gap, i stor fet text och medaljfärger för topp 3. Ingen egen bakgrund, så kamerabilden syns igenom. Startplatsen kan stängas av och visas inte i träning. - **TV-grafik:** rubrikskylt uppe till vänster (event och heat) och en topplista uppe till höger med klockan överst och raka kolumner: placering / **startplats** (t.ex. "2 / 3"), förare, varv, tid, bästa och gap, i stor fet text och medaljfärger för topp 3. Ingen egen bakgrund, så kamerabilden syns igenom. Startplatsen kan stängas av och visas inte i träning.
- **Livemarkeringar** i leaderboard och TV-topplistan: förarens rad blinkar kort vid en ny tid, en bränslepump med tickande klocka visas medan bilen är i depå (sedan stopptiden i 5 s), och en ny mellantid visas i 4 s med ± mot förra. De går på overlay-datorns klocka, och en nyöppnad overlay blinkar aldrig alla rader. - **Livemarkeringar** i leaderboard och TV-topplistan: förarens rad blinkar kort vid en ny tid, en bränslepump med tickande klocka visas medan bilen är i depå (sedan stopptiden i 5 s), och en ny mellantid visas i 4 s med ± mot förra. De går på overlay-datorns klocka, och en nyöppnad overlay blinkar aldrig alla rader.
- TV-rubrikskylten har RaceCore-utseende: klubbens logga eller ett rött RC-märke, eventet i små versaler och heatet i Orbitron. - TV-rubrikskylten har RaceCore-utseende: klubbens logga eller ett rött RC-märke, eventet i små versaler och heatet i Orbitron.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.89.3", "version": "1.89.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.89.3", "version": "1.89.4",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"better-sqlite3": "^12.11.1", "better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rc-racecore", "name": "rc-racecore",
"version": "1.89.3", "version": "1.89.4",
"private": true, "private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": { "engines": {
+8
View File
@@ -3391,6 +3391,8 @@ const TRANSLATIONS = {
"overlay.obs_show_laps": "Visa varv", "overlay.obs_show_laps": "Visa varv",
"overlay.obs_show_result": "Visa resultat/tid", "overlay.obs_show_result": "Visa resultat/tid",
"overlay.obs_show_best": "Visa bästa varv", "overlay.obs_show_best": "Visa bästa varv",
"overlay.obs_show_last": "Visa senaste varv",
"overlay.col_last": "Senaste",
"overlay.obs_show_gap": "Visa gap", "overlay.obs_show_gap": "Visa gap",
"overlay.obs_copy_url": "Kopiera OBS-url", "overlay.obs_copy_url": "Kopiera OBS-url",
"overlay.obs_layout": "OBS-layout", "overlay.obs_layout": "OBS-layout",
@@ -5651,6 +5653,8 @@ const TRANSLATIONS = {
"overlay.obs_show_laps": "Show laps", "overlay.obs_show_laps": "Show laps",
"overlay.obs_show_result": "Show result/time", "overlay.obs_show_result": "Show result/time",
"overlay.obs_show_best": "Show best lap", "overlay.obs_show_best": "Show best lap",
"overlay.obs_show_last": "Show last lap",
"overlay.col_last": "Last",
"overlay.obs_show_gap": "Show gap", "overlay.obs_show_gap": "Show gap",
"overlay.obs_copy_url": "Copy OBS URL", "overlay.obs_copy_url": "Copy OBS URL",
"overlay.obs_layout": "OBS layout", "overlay.obs_layout": "OBS layout",
@@ -5802,6 +5806,7 @@ function createDefaultObsOverlaySettings() {
showFastest: true, showFastest: true,
showGrid: true, showGrid: true,
showLaps: true, showLaps: true,
showLast: true,
showResult: true, showResult: true,
showBest: true, showBest: true,
showGap: true, showGap: true,
@@ -5829,6 +5834,7 @@ function normalizeObsOverlaySettings(raw = {}) {
showFastest: raw?.showFastest !== false, showFastest: raw?.showFastest !== false,
showGrid: raw?.showGrid !== false, showGrid: raw?.showGrid !== false,
showLaps: raw?.showLaps !== false, showLaps: raw?.showLaps !== false,
showLast: raw?.showLast !== false,
showResult: raw?.showResult !== false, showResult: raw?.showResult !== false,
showBest: raw?.showBest !== false, showBest: raw?.showBest !== false,
showGap: raw?.showGap !== false, showGap: raw?.showGap !== false,
@@ -5941,6 +5947,7 @@ function getObsOverlayConfig() {
showFastest: parseOverlayBooleanParam("showFastest", base.showFastest), showFastest: parseOverlayBooleanParam("showFastest", base.showFastest),
showGrid: parseOverlayBooleanParam("showGrid", base.showGrid), showGrid: parseOverlayBooleanParam("showGrid", base.showGrid),
showLaps: parseOverlayBooleanParam("showLaps", base.showLaps), showLaps: parseOverlayBooleanParam("showLaps", base.showLaps),
showLast: parseOverlayBooleanParam("showLast", base.showLast),
showResult: parseOverlayBooleanParam("showResult", base.showResult), showResult: parseOverlayBooleanParam("showResult", base.showResult),
showBest: parseOverlayBooleanParam("showBest", base.showBest), showBest: parseOverlayBooleanParam("showBest", base.showBest),
showGap: parseOverlayBooleanParam("showGap", base.showGap), showGap: parseOverlayBooleanParam("showGap", base.showGap),
@@ -5959,6 +5966,7 @@ function writeObsOverlayParams(url, config) {
url.searchParams.set("showFastest", normalized.showFastest ? "1" : "0"); url.searchParams.set("showFastest", normalized.showFastest ? "1" : "0");
url.searchParams.set("showGrid", normalized.showGrid ? "1" : "0"); url.searchParams.set("showGrid", normalized.showGrid ? "1" : "0");
url.searchParams.set("showLaps", normalized.showLaps ? "1" : "0"); url.searchParams.set("showLaps", normalized.showLaps ? "1" : "0");
url.searchParams.set("showLast", normalized.showLast ? "1" : "0");
url.searchParams.set("showResult", normalized.showResult ? "1" : "0"); url.searchParams.set("showResult", normalized.showResult ? "1" : "0");
url.searchParams.set("showBest", normalized.showBest ? "1" : "0"); url.searchParams.set("showBest", normalized.showBest ? "1" : "0");
url.searchParams.set("showGap", normalized.showGap ? "1" : "0"); url.searchParams.set("showGap", normalized.showGap ? "1" : "0");
+4 -2
View File
@@ -1,3 +1,5 @@
import { isOpenPracticeSession } from "./overlays.js";
let activeGuideTab = "start"; let activeGuideTab = "start";
const GUIDE_TAB_IDS = ["start", "create", "run", "series", "training", "videos", "install"]; const GUIDE_TAB_IDS = ["start", "create", "run", "series", "training", "videos", "install"];
@@ -327,7 +329,7 @@ export function renderOverlayPageView(deps) {
<div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${getVisiblePassings(result).length || 0}</div> <div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${getVisiblePassings(result).length || 0}</div>
</section> </section>
<div class="overlay-leaderboard-card overlay-leaderboard-card-tv overlay-leaderboard-card-dense"> <div class="overlay-leaderboard-card overlay-leaderboard-card-tv overlay-leaderboard-card-dense">
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta })} ${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active) })}
</div> </div>
</div> </div>
</section> </section>
@@ -343,7 +345,7 @@ export function renderOverlayPageView(deps) {
<div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${result?.passings.length || 0}</div> <div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${result?.passings.length || 0}</div>
</section> </section>
<div class="overlay-leaderboard-card overlay-leaderboard-card-dense"> <div class="overlay-leaderboard-card overlay-leaderboard-card-dense">
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta })} ${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active) })}
</div> </div>
</div> </div>
<aside class="overlay-side"> <aside class="overlay-side">
+19 -9
View File
@@ -59,13 +59,13 @@ export function renderOverlaySidePanel(panel, { t, escapeHtml }) {
// driverLinks: a click on a driver opens their training stats (RaceCore's own overlay only - never // driverLinks: a click on a driver opens their training stats (RaceCore's own overlay only - never
// the public overlay, see openDriverTrainingStats in app.js). // the public overlay, see openDriverTrainingStats in app.js).
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false } = {}) { export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false, lastLap = false } = {}) {
if (!rows.length) { if (!rows.length) {
return `<p>${t("timing.no_laps")}</p>`; return `<p>${t("timing.no_laps")}</p>`;
} }
const sortAttrs = sortable const sortAttrs = sortable
? ` data-sort-id="overlay-leaderboard" data-sort-text-columns="1" data-sort-labels="${sortValuesAttribute([t("table.pos"), t("table.driver"), t("table.laps"), t("table.result"), t("table.gap"), t("table.ahead_gap"), t("table.own_delta"), t("table.best_lap")])}"` ? ` data-sort-id="overlay-leaderboard" data-sort-text-columns="1" data-sort-labels="${sortValuesAttribute([t("table.pos"), t("table.driver"), t("table.laps"), t(lastLap ? "table.last_lap" : "table.result"), t("table.gap"), t("table.ahead_gap"), t("table.own_delta"), t("table.best_lap")])}"`
: ""; : "";
// More than 12 cars (a busy Open Practice): compact rows so all of them fit on a TV that // More than 12 cars (a busy Open Practice): compact rows so all of them fit on a TV that
// can't scroll - no per-cell labels (the header names the columns), sub-line or prediction bar. // can't scroll - no per-cell labels (the header names the columns), sub-line or prediction bar.
@@ -77,7 +77,7 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
${rows ${rows
.map((row, idx) => { .map((row, idx) => {
const posClass = idx === 0 ? "pos-1" : idx === 1 ? "pos-2" : idx === 2 ? "pos-3" : ""; const posClass = idx === 0 ? "pos-1" : idx === 1 ? "pos-2" : idx === 2 ? "pos-3" : "";
const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute([idx + 1, row.displayName || row.driverName, row.laps ?? 0, row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : ""; const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute([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])}"` : "";
const linkAttrs = driverLinks && row.driverId && !row.teamId ? ` data-training-driver="${escapeHtml(row.driverId)}" title="${escapeHtml(t("overlay.open_training_stats"))}"` : ""; 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 mark = liveMarks.get(String(row.key ?? ""));
const flash = passingFlashAttrs(mark); const flash = passingFlashAttrs(mark);
@@ -106,8 +106,8 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
<strong>${row.laps ?? 0}</strong> <strong>${row.laps ?? 0}</strong>
</div> </div>
<div class="overlay-race-metric"> <div class="overlay-race-metric">
<label>${t("table.result")}</label> <label>${t(lastLap ? "table.last_lap" : "table.result")}</label>
<strong>${escapeHtml(row.resultDisplay)}</strong> <strong>${lastLap ? (row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-") : escapeHtml(row.resultDisplay)}</strong>
</div> </div>
<div class="overlay-race-metric"> <div class="overlay-race-metric">
<label>${t("table.gap")}</label> <label>${t("table.gap")}</label>
@@ -217,9 +217,9 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
: [ : [
["pos", "2.4em"], showStart && ["start", "2.4em"], ["name", "minmax(6em, 1fr)"], ["pos", "2.4em"], showStart && ["start", "2.4em"], ["name", "minmax(6em, 1fr)"],
obsConfig.showPositionChange && !practice && ["change", "2.6em"], obsConfig.showLaps && ["laps", "max-content"], obsConfig.showPositionChange && !practice && ["change", "2.6em"], obsConfig.showLaps && ["laps", "max-content"],
showResult && ["result", "max-content"], obsConfig.showBest && ["best", "max-content"], obsConfig.showGap && ["gap", "max-content"], obsConfig.showLast && ["last", "max-content"], showResult && ["result", "max-content"], obsConfig.showBest && ["best", "max-content"], obsConfig.showGap && ["gap", "max-content"],
].filter(Boolean); ].filter(Boolean);
const label = { pos: "#", start: t("overlay.col_start"), name: t("table.driver"), change: "", laps: t("table.laps"), result: t("table.result"), best: t("table.best_lap"), gap: t("table.gap") }; const label = { pos: "#", start: t("overlay.col_start"), name: t("table.driver"), change: "", laps: t("table.laps"), last: t("overlay.col_last"), result: t("table.result"), best: t("table.best_lap"), gap: t("table.gap") };
const cell = (key, html) => `<span class="obs-tv-cell obs-tv-${key}">${html}</span>`; const cell = (key, html) => `<span class="obs-tv-cell obs-tv-${key}">${html}</span>`;
// With laps in their own column the result's "14/" prefix only repeats them. // With laps in their own column the result's "14/" prefix only repeats them.
const timeOnly = (value) => (obsConfig.showLaps ? String(value || "").replace(/^\d+\//, "") : String(value || "")); const timeOnly = (value) => (obsConfig.showLaps ? String(value || "").replace(/^\d+\//, "") : String(value || ""));
@@ -238,6 +238,7 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
name: `${escapeHtml(row.displayName || row.driverName)}${row.heatCarName ? ` <small>🚗 ${escapeHtml(row.heatCarName)}</small>` : ""}${row.suspectPending ? ' <span class="suspect-flag">⚠</span>' : ""}`, name: `${escapeHtml(row.displayName || row.driverName)}${row.heatCarName ? ` <small>🚗 ${escapeHtml(row.heatCarName)}</small>` : ""}${row.suspectPending ? ' <span class="suspect-flag">⚠</span>' : ""}`,
change: positionChangeMarkup(row, idx + 1), change: positionChangeMarkup(row, idx + 1),
laps: row.laps ?? 0, laps: row.laps ?? 0,
last: row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-",
result: escapeHtml(timeOnly(row.resultDisplay)), result: escapeHtml(timeOnly(row.resultDisplay)),
best: Number.isFinite(row.bestLapMs) ? escapeHtml(formatLap(row.bestLapMs)) : "-", best: Number.isFinite(row.bestLapMs) ? escapeHtml(formatLap(row.bestLapMs)) : "-",
gap: escapeHtml(idx === 0 ? "" : row.gapDisplay || row.gapAhead || ""), gap: escapeHtml(idx === 0 ? "" : row.gapDisplay || row.gapAhead || ""),
@@ -272,8 +273,15 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
// In practice the ranking value *is* the best lap, so "result" and "best" would print the // In practice the ranking value *is* the best lap, so "result" and "best" would print the
// same time twice - show it once. // same time twice - show it once.
// An Open Practice ranked on the best lap: its result only repeats the best-lap column, and the
// last lap is what changes at each passing. Ranked on N laps in a row or X minutes, the result
// ("2 laps 35.104") says something of its own and stays.
export function isOpenPracticeSession(session) {
return ["open_practice", "free_practice"].includes(String(session?.type || ""))
&& !["consecutive", "window"].includes(String(session?.practiceRanking || ""));
}
function obsShowsResult(session, obsConfig) { function obsShowsResult(session, obsConfig) {
return obsConfig.showResult && !(obsConfig.showBest && ["open_practice", "free_practice"].includes(String(session?.type || ""))); return obsConfig.showResult && !(obsConfig.showBest && isOpenPracticeSession(session));
} }
export function renderObsOverlay(active, leaderboard, result, sessionTiming, branding, deps) { export function renderObsOverlay(active, leaderboard, result, sessionTiming, branding, deps) {
@@ -346,7 +354,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
<h3>${showStartGrid ? t("events.start_grid") : t("overlay.leaderboard_live")}</h3> <h3>${showStartGrid ? t("events.start_grid") : t("overlay.leaderboard_live")}</h3>
<span class="pill">${t("overlay.mode_obs")}</span> <span class="pill">${t("overlay.mode_obs")}</span>
</div> </div>
${showStartGrid ? renderPositionGrid(active) : renderOverlayLeaderboard(compactRows, deps, { sortable: false })} ${showStartGrid ? renderPositionGrid(active) : renderOverlayLeaderboard(compactRows, deps, { sortable: false, lastLap: isOpenPracticeSession(active) })}
</section> </section>
</section> </section>
`; `;
@@ -371,6 +379,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
<strong>${escapeHtml(row.displayName || row.driverName)}${row.personalTimeUp ? " 🏁" : ""}${row.suspectPending ? ` <span class="suspect-flag" title="${escapeHtml(t("suspect.flag_title"))}">⚠</span>` : ""}</strong> <strong>${escapeHtml(row.displayName || row.driverName)}${row.personalTimeUp ? " 🏁" : ""}${row.suspectPending ? ` <span class="suspect-flag" title="${escapeHtml(t("suspect.flag_title"))}">⚠</span>` : ""}</strong>
${row.heatCarName ? `<span class="overlay-heat-car">🚗 ${escapeHtml(row.heatCarName)}</span>` : ""} ${row.heatCarName ? `<span class="overlay-heat-car">🚗 ${escapeHtml(row.heatCarName)}</span>` : ""}
${obsConfig.showLaps ? `<span>${t("table.laps")}: ${row.laps ?? 0}</span>` : ""} ${obsConfig.showLaps ? `<span>${t("table.laps")}: ${row.laps ?? 0}</span>` : ""}
${obsConfig.showLast && row.lastLapMs > 0 ? `<span>${t("overlay.col_last")}: ${escapeHtml(formatLap(row.lastLapMs))}</span>` : ""}
${obsShowsResult(active, obsConfig) ? `<span>${t("table.result")}: ${escapeHtml(row.resultDisplay)}</span>` : ""} ${obsShowsResult(active, obsConfig) ? `<span>${t("table.result")}: ${escapeHtml(row.resultDisplay)}</span>` : ""}
${obsConfig.showGap ? `<span>${t("table.gap")}: ${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : ""} ${obsConfig.showGap ? `<span>${t("table.gap")}: ${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : ""}
</article> </article>
@@ -407,6 +416,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
const trail = [ const trail = [
positionChangeMarkup(row, idx + 1), positionChangeMarkup(row, idx + 1),
obsConfig.showLaps ? `<span>${row.laps ?? 0}L</span>` : "", obsConfig.showLaps ? `<span>${row.laps ?? 0}L</span>` : "",
obsConfig.showLast ? `<span>${row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-"}</span>` : "",
obsShowsResult(active, obsConfig) ? `<span>${escapeHtml(row.resultDisplay)}</span>` : "", obsShowsResult(active, obsConfig) ? `<span>${escapeHtml(row.resultDisplay)}</span>` : "",
obsConfig.showBest ? `<span>${formatLap(row.bestLapMs)}</span>` : "", obsConfig.showBest ? `<span>${formatLap(row.bestLapMs)}</span>` : "",
obsConfig.showGap ? `<span>${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : "", obsConfig.showGap ? `<span>${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : "",
+2
View File
@@ -386,6 +386,7 @@ export function renderSettings(deps) {
<label class="toggle"><input id="obsShowFastest" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showFastest ? "checked" : ""} /><span>${t("overlay.obs_show_fastest")}</span></label> <label class="toggle"><input id="obsShowFastest" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showFastest ? "checked" : ""} /><span>${t("overlay.obs_show_fastest")}</span></label>
<label class="toggle"><input id="obsShowGrid" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showGrid ? "checked" : ""} /><span>${t("overlay.obs_show_grid")}</span></label> <label class="toggle"><input id="obsShowGrid" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showGrid ? "checked" : ""} /><span>${t("overlay.obs_show_grid")}</span></label>
<label class="toggle"><input id="obsShowLaps" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showLaps ? "checked" : ""} /><span>${t("overlay.obs_show_laps")}</span></label> <label class="toggle"><input id="obsShowLaps" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showLaps ? "checked" : ""} /><span>${t("overlay.obs_show_laps")}</span></label>
<label class="toggle"><input id="obsShowLast" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showLast ? "checked" : ""} /><span>${t("overlay.obs_show_last")}</span></label>
<label class="toggle"><input id="obsShowResult" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showResult ? "checked" : ""} /><span>${t("overlay.obs_show_result")}</span></label> <label class="toggle"><input id="obsShowResult" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showResult ? "checked" : ""} /><span>${t("overlay.obs_show_result")}</span></label>
<label class="toggle"><input id="obsShowBest" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showBest ? "checked" : ""} /><span>${t("overlay.obs_show_best")}</span></label> <label class="toggle"><input id="obsShowBest" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showBest ? "checked" : ""} /><span>${t("overlay.obs_show_best")}</span></label>
<label class="toggle"><input id="obsShowGap" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showGap ? "checked" : ""} /><span>${t("overlay.obs_show_gap")}</span></label> <label class="toggle"><input id="obsShowGap" type="checkbox" ${normalizeObsOverlaySettings(state.settings.obsOverlay).showGap ? "checked" : ""} /><span>${t("overlay.obs_show_gap")}</span></label>
@@ -797,6 +798,7 @@ Erik Eriksson;654321;4WD;Associated;;</code></pre>
["obsShowLaps", "showLaps", (value, el) => Boolean(el?.checked)], ["obsShowLaps", "showLaps", (value, el) => Boolean(el?.checked)],
["obsShowResult", "showResult", (value, el) => Boolean(el?.checked)], ["obsShowResult", "showResult", (value, el) => Boolean(el?.checked)],
["obsShowBest", "showBest", (value, el) => Boolean(el?.checked)], ["obsShowBest", "showBest", (value, el) => Boolean(el?.checked)],
["obsShowLast", "showLast", (value, el) => Boolean(el?.checked)],
["obsShowGap", "showGap", (value, el) => Boolean(el?.checked)], ["obsShowGap", "showGap", (value, el) => Boolean(el?.checked)],
["obsShowPositionChange", "showPositionChange", (value, el) => Boolean(el?.checked)], ["obsShowPositionChange", "showPositionChange", (value, el) => Boolean(el?.checked)],
["obsShowStart", "showStart", (value, el) => Boolean(el?.checked)], ["obsShowStart", "showStart", (value, el) => Boolean(el?.checked)],
+29
View File
@@ -22,3 +22,32 @@ test("sponsor heats: the overlay shows the driver's car for this heat", () => {
const html = renderOverlayLeaderboard([{ key: "a", driverId: "a", displayName: "Anna", heatCarName: "Rental 2", laps: 3, resultDisplay: "-", bestLapMs: 17500 }], deps); const html = renderOverlayLeaderboard([{ key: "a", driverId: "a", displayName: "Anna", heatCarName: "Rental 2", laps: 3, resultDisplay: "-", bestLapMs: 17500 }], deps);
assert.match(html, /overlay-heat-car[^>]*>🚗 Rental 2/); assert.match(html, /overlay-heat-car[^>]*>🚗 Rental 2/);
}); });
test("open practice: the last lap takes the result's place (the result only repeats the best lap)", () => {
const row = { key: "a", driverId: "a", displayName: "Anna", laps: 12, resultDisplay: "0:17.100", bestLapMs: 17100, lastLapMs: 17842 };
const practice = renderOverlayLeaderboard([row], deps, { lastLap: true });
assert.match(practice, /<label>table\.last_lap<\/label>\s*<strong>17842<\/strong>/);
assert.doesNotMatch(practice, /<label>table\.result<\/label>/);
const race = renderOverlayLeaderboard([row], deps);
assert.match(race, /<label>table\.result<\/label>\s*<strong>0:17\.100<\/strong>/);
assert.match(renderOverlayLeaderboard([{ ...row, lastLapMs: 0 }], deps, { lastLap: true }), /<label>table\.last_lap<\/label>\s*<strong>-<\/strong>/);
});
test("OBS tower: a Last column with each passing's lap time, next to laps", async () => {
const { renderObsOverlay } = await import("../src/overlays.js");
const config = { layout: "broadcast", rows: 10, showLaps: true, showLast: true, showResult: true, showBest: true, showGap: true };
const obsDeps = { ...deps, formatLap: (ms) => (ms / 1000).toFixed(3), getVisiblePassings: () => [], getEventName: () => "", getSessionTypeLabel: () => "", getStartModeLabel: () => "", getStatusLabel: () => "", getObsOverlayConfig: () => config, normalizeStartMode: (v) => v, renderPositionGrid: () => "", getSessionGridEntries: () => [], getSessionGridOrder: () => [] };
const html = renderObsOverlay({ eventId: "e", name: "Open practice", type: "open_practice", status: "running" }, [{ key: "p", driverId: "p", displayName: "Pia", laps: 23, resultDisplay: "0:15.833", bestLapMs: 15833, lastLapMs: 16120 }], {}, {}, {}, obsDeps);
assert.match(html, /obs-tv-laps">23<\/span><span class="obs-tv-cell obs-tv-last">16\.120<\/span>/);
assert.doesNotMatch(html, /obs-tv-result">0:15/, "practice still drops the result that repeats the best lap");
config.showLast = false;
assert.doesNotMatch(renderObsOverlay({ eventId: "e", name: "Q1", type: "qualification", status: "running" }, [{ key: "p", driverId: "p", displayName: "Pia", laps: 23, resultDisplay: "23/5:02", bestLapMs: 15833, lastLapMs: 16120 }], {}, {}, {}, obsDeps), /obs-tv-last/);
});
test("an Open Practice ranked on laps in a row or minutes keeps its result", async () => {
const { isOpenPracticeSession } = await import("../src/overlays.js");
assert.equal(isOpenPracticeSession({ type: "open_practice" }), true);
assert.equal(isOpenPracticeSession({ type: "open_practice", practiceRanking: "consecutive" }), false);
assert.equal(isOpenPracticeSession({ type: "free_practice", practiceRanking: "window" }), false);
assert.equal(isOpenPracticeSession({ type: "qualification" }), false);
});