feat(results): qualifying place (TQ) next to final results and podium bands for the top three (1.74.0)
This commit is contained in:
1 parent
41043a990d
commit
fee9f8073d
12 files changed
+149
-38
No files matched your search
+31
-12
@@ -1,4 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
import { medal, qualCell } from "./medal.js";
|
||||
import { getSyncStatus } from "./sync_status.js";
|
||||
import { installListSorting } from "./list_sorting.js";
|
||||
import { escapeHtml } from "./html_escape.js";
|
||||
@@ -10,7 +10,7 @@ import { recordTransponderSighting, buildWarmupCheck, createPrologue, getPrologu
|
||||
import { findTransponderConflict, getDriverProfileId } from "./driver_profile_logic.js";
|
||||
import { renderRaceDayView, refreshRaceDayWarmup, refreshRaceDayPrologueClock, updateRaceDayStartDisplay, refreshRaceDayLive } from "./race_day_view.js";
|
||||
import { normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate, getDueCall } from "./day_schedule_logic.js";
|
||||
import { buildRaceOverview, buildRaceOverviewCsvRows } from "./race_overview_logic.js";
|
||||
import { buildRaceOverview, buildRaceOverviewCsvRows, withQualifyingPlaces } from "./race_overview_logic.js";
|
||||
import { renderRaceOverviewPanel, bindRaceOverviewPanel } from "./race_overview_view.js";
|
||||
import { renderSpeakerPanel, bindSpeakerPanel } from "./speaker_panel_view.js";
|
||||
import { renderDaySchedulePanel, bindDaySchedulePanel, buildDaySchedulePrintHtml, renderDriverBoard, formatClockTime, renderDayCallBanner, bindDayCallBanner } from "./day_schedule_view.js";
|
||||
@@ -130,7 +130,12 @@ const buildTeamStintLog = (session, row) => buildTeamStintLogLogic(session, row,
|
||||
const getSessionGridEntries = (session) => getSessionGridEntriesLogic(session, { state, t, getEventTeams, getDriverDisplayById, getSessionGridOrder });
|
||||
const getSessionGridOrder = (session) => getSessionGridOrderLogic(session);
|
||||
const ensureSessionDriverOrder = (session) => ensureSessionDriverOrderLogic(session, { getSessionEntrants });
|
||||
const buildFinalStandings = (event) => buildFinalStandingsLogic(event, { getSessionsForEvent, buildLeaderboard, getSessionEntrants, t });
|
||||
// Final standings carry each driver's qualifying place (qual, "TQ" for the top qualifier).
|
||||
const buildFinalStandings = (event) => {
|
||||
const rows = buildFinalStandingsLogic(event, { getSessionsForEvent, buildLeaderboard, getSessionEntrants, t });
|
||||
const qualified = rows.length && getSessionsForEvent(event.id).some((session) => session.type === "qualification" && session.status !== "ready");
|
||||
return qualified ? withQualifyingPlaces(rows, buildQualifyingStandings(event)) : rows;
|
||||
};
|
||||
|
||||
const getManualCorrectionSummary = (row) => getManualCorrectionSummaryLogic(row, { formatLap });
|
||||
const renderTeamStintLog = (session, rows) => renderTeamStintLogHelper(session, rows, { t, escapeHtml, buildTeamStintLog, formatTeamActiveMemberLabel, renderTable, formatRaceClock });
|
||||
@@ -158,8 +163,8 @@ const bindRaceOverviewFor = (root, event) => event && bindRaceOverviewPanel(root
|
||||
const renderRaceOverviewHeatsHtml = (event) => (getRaceOverview(event)?.phases || []).flatMap((phase) => phase.heats.map(({ session, rows }) => `
|
||||
<section class="print-block">
|
||||
<h2>${escapeHtml(raceOverviewPhaseLabel(phase.type))} • ${escapeHtml(session.name)}</h2>
|
||||
${renderTable([t("table.pos"), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
${renderTable([t("table.pos"), ...(rows.some((row) => row.qual) ? [t("table.qual")] : []), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td>${rows.some((item) => item.qual) ? qualCell(row.qual, escapeHtml) : ""}<td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
</section>`)).join("");
|
||||
const getSessionsForEvent = (eventId) => getSessionsForEventHelper(state, eventId);
|
||||
const getModeLabel = (mode) => getModeLabelHelper(mode, { t });
|
||||
@@ -2867,6 +2872,7 @@ const TRANSLATIONS = {
|
||||
"table.loop": "Loop",
|
||||
"table.strength": "Signal",
|
||||
"table.pos": "Pos",
|
||||
"table.qual": "Kval",
|
||||
"table.laps": "Varv",
|
||||
"table.last_lap": "Senaste varv",
|
||||
"table.best_lap": "Bästa varv",
|
||||
@@ -4993,6 +4999,7 @@ const TRANSLATIONS = {
|
||||
"table.loop": "Loop",
|
||||
"table.strength": "Strength",
|
||||
"table.pos": "Pos",
|
||||
"table.qual": "Qual.",
|
||||
"table.laps": "Laps",
|
||||
"table.last_lap": "Last Lap",
|
||||
"table.best_lap": "Best Lap",
|
||||
@@ -7438,8 +7445,8 @@ function decoratePrintTables(doc) {
|
||||
});
|
||||
if (/^(pos|plac|placering|place|#)\.?$/i.test(headers[0]?.textContent.trim() || "")) {
|
||||
rows.forEach((row) => {
|
||||
const pos = row.children[0]?.textContent.trim();
|
||||
if (["1", "2", "3"].includes(pos)) row.classList.add(`podium-${pos}`);
|
||||
const place = /^A?([1-3])$/.exec(row.children[0]?.textContent.trim() || "")?.[1];
|
||||
if (place) row.classList.add(`podium-${place}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -7492,7 +7499,12 @@ function openPrintWindow(title, bodyHtml) {
|
||||
tbody tr:nth-child(even) td { background: ${theme.zebra}; }
|
||||
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
td.pos, th.pos { text-align: center; width: 1%; white-space: nowrap; }
|
||||
tr.podium-1 td:first-child { box-shadow: inset 4px 0 #d4af37; } tr.podium-2 td:first-child { box-shadow: inset 4px 0 #a9b0bb; } tr.podium-3 td:first-child { box-shadow: inset 4px 0 #c27c3e; }
|
||||
tr.podium-1 { background: linear-gradient(90deg, rgba(240, 197, 63, 0.35), rgba(240, 197, 63, 0) 70%); }
|
||||
tr.podium-2 { background: linear-gradient(90deg, rgba(170, 180, 192, 0.35), rgba(170, 180, 192, 0) 70%); }
|
||||
tr.podium-3 { background: linear-gradient(90deg, rgba(205, 127, 60, 0.32), rgba(205, 127, 60, 0) 70%); }
|
||||
tbody tr.podium-1 td, tbody tr.podium-2 td, tbody tr.podium-3 td { background: transparent !important; }
|
||||
td.qual-cell, th.qual-cell { text-align: center; color: #6b7486; }
|
||||
.tq-badge { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 9.5px; font-weight: 800; color: #1d2330; background: linear-gradient(135deg, #ffe58a, #f2b705); }
|
||||
tr.podium-1 td, tr.podium-2 td, tr.podium-3 td { font-weight: 700; }
|
||||
.medal { display: inline-block; width: 20px; height: 20px; line-height: 20px; border-radius: 50%; text-align: center; font-weight: 800; font-size: 11px; color: #4a3500; background: radial-gradient(circle at 32% 28%, #fff7cf 0%, #f4cf55 38%, #c9971c 75%, #9c7210 100%); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); }
|
||||
.medal-2 { color: #33383f; background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe3e8 38%, #a8b0ba 75%, #7d8691 100%); }
|
||||
@@ -7640,15 +7652,22 @@ async function exportRaceResultsPdf(event) {
|
||||
),
|
||||
buildPdfSection(
|
||||
t("events.final_standings"),
|
||||
[t("table.pos"), t("table.driver"), t("table.score")],
|
||||
buildFinalStandings(event).map((row) => [String(row.rank), row.driverName || "-", row.score || "-"])
|
||||
...(() => {
|
||||
const rows = buildFinalStandings(event);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return [
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), t("table.score")],
|
||||
rows.map((row) => [String(row.rank), ...(withQual ? [row.qual || "-"] : []), row.driverName || "-", row.score || "-"]),
|
||||
];
|
||||
})()
|
||||
),
|
||||
...(getRaceOverview(event)?.phases || []).flatMap((phase) => phase.heats.map(({ session, rows }) => {
|
||||
const withCar = rows.some((row) => row.car);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return buildPdfSection(
|
||||
`${raceOverviewPhaseLabel(phase.type)} • ${session.name}`,
|
||||
[t("table.pos"), t("table.driver"), ...(withCar ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => [String(row.pos), row.name, ...(withCar ? [row.car || "-"] : []), String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "-"])
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), ...(withCar ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => [String(row.pos), ...(withQual ? [row.qual || "-"] : []), row.name, ...(withCar ? [row.car || "-"] : []), String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "-"])
|
||||
);
|
||||
})),
|
||||
...buildTeamRaceStandings(event).map(({ session, rows }) =>
|
||||
|
||||
+11
-3
@@ -1,6 +1,14 @@
|
||||
// Gold / silver / bronze medal for places 1-3 in result tables; other places stay a plain number.
|
||||
// The medal still holds the number, so text, CSV and the print table decoration keep working.
|
||||
// Gold / silver / bronze medal for places 1-3 in result tables (also A1-A3 in the finals);
|
||||
// other places stay as they are. The medal still holds the text, so CSV, sorting and the print
|
||||
// table decoration keep working.
|
||||
export function medal(pos) {
|
||||
const value = String(pos ?? "").trim();
|
||||
return ["1", "2", "3"].includes(value) ? `<span class="medal medal-${value}">${value}</span>` : value;
|
||||
const place = /^A?([1-3])$/.exec(value)?.[1];
|
||||
return place ? `<span class="medal medal-${place}">${value}</span>` : value;
|
||||
}
|
||||
|
||||
// The driver's qualifying place next to a final result; the top qualifier gets a "TQ" badge.
|
||||
export function qualCell(qual, escapeHtml) {
|
||||
const value = String(qual || "").trim();
|
||||
return `<td class="qual-cell">${value === "TQ" ? '<span class="tq-badge">TQ</span>' : escapeHtml(value || "-")}</td>`;
|
||||
}
|
||||
@@ -3,6 +3,22 @@
|
||||
// Works for race events and sponsor events (their heats carry carAssignments).
|
||||
const PHASES = ["practice", "qualification", "final"];
|
||||
|
||||
// Where each driver ended up in qualifying ("TQ" for the top qualifier), shown next to the
|
||||
// final result so you can see who climbed or dropped - like House of RC's "Qual." column.
|
||||
export function qualifyingPlaces(qualifyingRows = []) {
|
||||
const places = new Map();
|
||||
qualifyingRows.forEach((row) => {
|
||||
if (row?.driverId && row.rank) places.set(row.driverId, String(row.rank) === "1" ? "TQ" : String(row.rank));
|
||||
});
|
||||
return places;
|
||||
}
|
||||
|
||||
export function withQualifyingPlaces(rows = [], qualifyingRows = []) {
|
||||
const places = qualifyingPlaces(qualifyingRows);
|
||||
if (!places.size) return rows;
|
||||
return rows.map((row) => ({ ...row, qual: places.get(row.driverId) || "" }));
|
||||
}
|
||||
|
||||
export function buildRaceOverview(event, deps) {
|
||||
const { sessions = [], cars = [], buildLeaderboard, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings } = deps;
|
||||
if (!event) return null;
|
||||
@@ -11,6 +27,9 @@ export function buildRaceOverview(event, deps) {
|
||||
return carId ? cars.find((car) => car.id === carId)?.name || "" : "";
|
||||
};
|
||||
const standingsOf = { practice: buildPracticeStandings, qualification: buildQualifyingStandings, final: buildFinalStandings };
|
||||
const qualPlaces = sessions.some((session) => session.type === "qualification" && session.status !== "ready")
|
||||
? qualifyingPlaces(buildQualifyingStandings(event) || [])
|
||||
: new Map();
|
||||
const phases = PHASES.map((type) => {
|
||||
const heats = sessions
|
||||
.filter((session) => session.type === type && session.status !== "ready")
|
||||
@@ -18,6 +37,8 @@ export function buildRaceOverview(event, deps) {
|
||||
session,
|
||||
rows: buildLeaderboard(session).map((row, index) => ({
|
||||
pos: index + 1,
|
||||
driverId: row.driverId,
|
||||
qual: type === "final" ? qualPlaces.get(row.driverId) || "" : "",
|
||||
name: row.displayName || row.driverName || row.transponder || "-",
|
||||
car: carName(session, row.driverId),
|
||||
laps: Number(row.laps || 0),
|
||||
@@ -26,7 +47,8 @@ export function buildRaceOverview(event, deps) {
|
||||
})),
|
||||
}));
|
||||
const planned = sessions.filter((session) => session.type === type).length;
|
||||
return { type, planned, heats, standings: heats.length ? standingsOf[type](event) || [] : [] };
|
||||
const standings = heats.length ? standingsOf[type](event) || [] : [];
|
||||
return { type, planned, heats, standings: type === "final" && qualPlaces.size ? standings.map((row) => ({ ...row, qual: qualPlaces.get(row.driverId) || "" })) : standings };
|
||||
}).filter((phase) => phase.planned);
|
||||
const finals = phases.find((phase) => phase.type === "final");
|
||||
const podium = finals ? finals.standings.filter((row) => /^A?[1-3]$/.test(String(row.rank))).slice(0, 3) : [];
|
||||
@@ -35,14 +57,14 @@ export function buildRaceOverview(event, deps) {
|
||||
|
||||
// One CSV for the whole race: the standings ("Total") and every heat, one row per driver.
|
||||
export function buildRaceOverviewCsvRows(overview, { t, formatLap, phaseLabel }) {
|
||||
const rows = [["event", "phase", "heat", "pos", "driver", "car", "laps", "result", "best_lap"]];
|
||||
const rows = [["event", "phase", "heat", "pos", "qual", "driver", "car", "laps", "result", "best_lap"]];
|
||||
if (!overview) return rows;
|
||||
const eventName = overview.event.name || "";
|
||||
overview.phases.forEach((phase) => {
|
||||
const label = phaseLabel(phase.type);
|
||||
phase.standings.forEach((row) => rows.push([eventName, label, t("race_overview.total"), String(row.rank), row.driverName || "-", "", "", row.score || "-", ""]));
|
||||
phase.standings.forEach((row) => rows.push([eventName, label, t("race_overview.total"), String(row.rank), row.qual || "", row.driverName || "-", "", "", row.score || "-", ""]));
|
||||
phase.heats.forEach(({ session, rows: heatRows }) => heatRows.forEach((row) => rows.push([
|
||||
eventName, label, session.name, String(row.pos), row.name, row.car, String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "",
|
||||
eventName, label, session.name, String(row.pos), row.qual || "", row.name, row.car, String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "",
|
||||
])));
|
||||
});
|
||||
return rows;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
import { medal, qualCell } from "./medal.js";
|
||||
// Race Day → Race overview panel: podium, then practice / qualifying / finals with standings
|
||||
// and every heat. Logic in race_overview_logic.js; print, PDF and CSV come in as deps.
|
||||
const openPhases = new Set();
|
||||
@@ -7,8 +7,8 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
|
||||
if (!overview || !overview.phases.length) return "";
|
||||
const { event, phases, podium } = overview;
|
||||
const heatTable = (rows) => renderTable(
|
||||
[t("table.pos"), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td><td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`)
|
||||
[t("table.pos"), ...(rows.some((row) => row.qual) ? [t("table.qual")] : []), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td>${rows.some((item) => item.qual) ? qualCell(row.qual, escapeHtml) : ""}<td>${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`)
|
||||
);
|
||||
return `
|
||||
<section class="panel mt-16 race-overview" id="raceDayOverview">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { medal } from "./medal.js";
|
||||
import { medal, qualCell } from "./medal.js";
|
||||
export function renderRaceFormatField(labelKey, hintKey, controlHtml, options = {}, { t }) {
|
||||
const extraClass = options.checkbox ? " field-card-checkbox" : "";
|
||||
return `
|
||||
@@ -211,12 +211,14 @@ export function renderRaceStandingsTable(rows, emptyLabel, { t, renderTable, esc
|
||||
return `<p>${emptyLabel}</p>`;
|
||||
}
|
||||
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return renderTable(
|
||||
[t("table.pos"), t("table.driver"), t("table.score")],
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), t("table.score")],
|
||||
rows.map(
|
||||
(row) => `
|
||||
<tr>
|
||||
<td>${medal(row.rank)}</td>
|
||||
${withQual ? qualCell(row.qual, escapeHtml) : ""}
|
||||
<td>${escapeHtml(row.driverName || t("common.unknown_driver"))}</td>
|
||||
<td>
|
||||
<div class="table-primary">${escapeHtml(row.score || "-")}</div>
|
||||
|
||||
@@ -4890,3 +4890,12 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
|
||||
.race-overview-podium .medal::before { content: ""; position: absolute; top: -12px; left: 50%; width: 18px; height: 14px; transform: translateX(-50%); background: linear-gradient(90deg, #2f6fde 0 38%, #f4cf55 38% 62%, #2f6fde 62%); clip-path: polygon(0 0, 100% 0, 75% 100%, 25% 100%); z-index: -1; }
|
||||
.race-overview-podium .podium-1 { border-color: #e2bd45; }
|
||||
.race-overview-podium li { position: relative; z-index: 0; }
|
||||
|
||||
/* House of RC style: the qualifying place next to a final result, and the top three rows
|
||||
tinted gold / silver / bronze, fading out to the right. */
|
||||
.qual-cell { color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
|
||||
.tq-badge { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 0.75em; font-weight: 800; letter-spacing: 0.04em; color: #1d2330; background: linear-gradient(135deg, #ffe58a, #f2b705); }
|
||||
tr:has(> td > .medal-1) { background: linear-gradient(90deg, rgba(240, 197, 63, 0.28), rgba(240, 197, 63, 0) 70%); }
|
||||
tr:has(> td > .medal-2) { background: linear-gradient(90deg, rgba(190, 199, 210, 0.26), rgba(190, 199, 210, 0) 70%); }
|
||||
tr:has(> td > .medal-1) > td, tr:has(> td > .medal-2) > td, tr:has(> td > .medal-3) > td { background: transparent; }
|
||||
tr:has(> td > .medal-3) { background: linear-gradient(90deg, rgba(205, 127, 60, 0.26), rgba(205, 127, 60, 0) 70%); }
|
||||
Reference in new issue
Block a user