feat(results): gold, silver and bronze medals for the top three in PDF, printouts and result tables (1.73.0)

This commit is contained in:
larssand committed 2026-11-06 23:12:29 +01:00
1 parent 7c25f23ad0
commit 41043a990d
12 files changed
+72 -12

No files matched your search

+6 -2
View File
@@ -1,3 +1,4 @@
import { medal } from "./medal.js";
import { getSyncStatus } from "./sync_status.js";
import { installListSorting } from "./list_sorting.js";
import { escapeHtml } from "./html_escape.js";
@@ -158,7 +159,7 @@ const renderRaceOverviewHeatsHtml = (event) => (getRaceOverview(event)?.phases |
<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>${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>`))}
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>`))}
</section>`)).join("");
const getSessionsForEvent = (eventId) => getSessionsForEventHelper(state, eventId);
const getModeLabel = (mode) => getModeLabelHelper(mode, { t });
@@ -1021,7 +1022,7 @@ const printSeries = (series, tables) => openPrintWindow(series.name, `
<div class="print-meta"><p>${escapeHtml(new Date().toLocaleDateString())}</p></div></div>
${tables.map((table) => `<div class="print-block"><h2>${escapeHtml(table.className)} - ${escapeHtml(t("series.counted_of", { counted: table.countedCount, completed: table.completedCount, total: table.events.length }))}</h2>
<table><thead><tr><th>${escapeHtml(t("table.pos"))}</th><th>${escapeHtml(t("table.driver"))}</th>${table.events.map((event, index) => `<th>${index + 1}</th>`).join("")}<th>${escapeHtml(t("series.starts"))}</th><th>${escapeHtml(t("series.total"))}</th></tr></thead>
<tbody>${table.rows.map((row) => `<tr><td>${row.rank}</td><td>${escapeHtml(row.driverName)}</td>${table.events.map((event) => `<td>${escapeHtml(seriesCell(table, row, event))}</td>`).join("")}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody></table>
<tbody>${table.rows.map((row) => `<tr><td>${medal(row.rank)}</td><td>${escapeHtml(row.driverName)}</td>${table.events.map((event) => `<td>${escapeHtml(seriesCell(table, row, event))}</td>`).join("")}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody></table>
<p>${table.events.map((event, index) => `${index + 1}: ${escapeHtml(event.date || "")} ${escapeHtml(event.name)}`).join(" · ")}</p></div>`).join("")}
<p>${escapeHtml(t("series.legend"))}</p>`);
const exportSeriesPdf = async (series, tables) => {
@@ -7493,6 +7494,9 @@ function openPrintWindow(title, bodyHtml) {
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 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%); }
.medal-3 { color: #3d2109; background: radial-gradient(circle at 32% 28%, #ffe2c4 0%, #e3a46a 38%, #b06a2c 75%, #84491a 100%); }
</style>
</head>
<body>
+6
View File
@@ -0,0 +1,6 @@
// 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.
export function medal(pos) {
const value = String(pos ?? "").trim();
return ["1", "2", "3"].includes(value) ? `<span class="medal medal-${value}">${value}</span>` : value;
}
+3 -2
View File
@@ -1,3 +1,4 @@
import { medal } 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,7 +8,7 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
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>${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>`)
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>`)
);
return `
<section class="panel mt-16 race-overview" id="raceDayOverview">
@@ -20,7 +21,7 @@ export function renderRaceOverviewPanel(overview, { t, escapeHtml, formatLap, re
</div>
</div>
<div class="panel-body">
${podium.length ? `<ol class="race-overview-podium">${podium.map((row, index) => `<li class="podium-${index + 1}"><span>${index + 1}</span><strong>${escapeHtml(row.driverName || "-")}</strong></li>`).join("")}</ol>` : ""}
${podium.length ? `<ol class="race-overview-podium">${podium.map((row, index) => `<li class="podium-${index + 1}">${medal(index + 1)}<strong>${escapeHtml(row.driverName || "-")}</strong></li>`).join("")}</ol>` : ""}
${phases.map((phase) => `
<details class="race-overview-phase" data-phase="${phase.type}" ${openPhases.has(phase.type) ? "open" : ""}>
<summary><strong>${escapeHtml(phaseLabel(phase.type))}</strong> <small>${t("race_overview.heats_done", { done: phase.heats.filter(({ session }) => session.status === "finished").length, total: phase.planned })}</small></summary>
+2 -1
View File
@@ -1,3 +1,4 @@
import { medal } from "./medal.js";
export function renderRaceFormatField(labelKey, hintKey, controlHtml, options = {}, { t }) {
const extraClass = options.checkbox ? " field-card-checkbox" : "";
return `
@@ -215,7 +216,7 @@ export function renderRaceStandingsTable(rows, emptyLabel, { t, renderTable, esc
rows.map(
(row) => `
<tr>
<td>${row.rank}</td>
<td>${medal(row.rank)}</td>
<td>${escapeHtml(row.driverName || t("common.unknown_driver"))}</td>
<td>
<div class="table-primary">${escapeHtml(row.score || "-")}</div>
+2 -1
View File
@@ -1,3 +1,4 @@
import { medal } from "./medal.js";
import { sortableTable, sortValuesAttribute } from "./list_sorting.js";
export function buildArchiveRows(state, { getEventName, getClassName, getTrackLayoutLabel, buildLeaderboard }) {
@@ -76,7 +77,7 @@ function renderArchiveDetail(row, deps) {
[t("table.pos"), t("table.driver"), t("table.laps"), t("table.best_lap"), t("timing.total_time")],
leaderboard.map((rowItem, index) => `
<tr>
<td>${index + 1}</td>
<td>${medal(index + 1)}</td>
<td>${escapeHtml(rowItem.displayName || rowItem.driverName || t("common.unknown_driver"))}</td>
<td>${rowItem.laps}</td>
<td>${formatLap(rowItem.bestLapMs)}</td>
+2 -1
View File
@@ -1,3 +1,4 @@
import { medal } from "./medal.js";
// "Series" page: create a series/cup, pick its classes and races (or create the races in one
// go from a list of dates), set the points table and how many results count, and follow the
// standings per class - printable and exportable as PDF. Scoring lives in series_logic.js.
@@ -183,7 +184,7 @@ function renderStandingsTable(table, { t, escapeHtml }) {
${table.rows.length ? `
<div class="table-wrap"><table class="series-table">
<thead><tr><th>${t("table.pos")}</th><th>${t("table.driver")}</th>${head}<th>${t("series.starts")}</th><th>${t("series.total")}</th></tr></thead>
<tbody>${table.rows.map((row) => `<tr><td>${row.rank}</td><td>${escapeHtml(row.driverName)}</td>${cells(row)}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody>
<tbody>${table.rows.map((row) => `<tr><td>${medal(row.rank)}</td><td>${escapeHtml(row.driverName)}</td>${cells(row)}<td>${row.starts}</td><td><strong>${row.total}</strong></td></tr>`).join("")}</tbody>
</table></div>` : `<p class="hint">${t("series.no_results")}</p>`}
</section>`;
}
+9 -2
View File
@@ -4847,8 +4847,6 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
/* Race overview (Race Day, results archive) */
.race-overview-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; list-style: none; margin: 0 0 12px; padding: 0; }
.race-overview-podium li { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-card); text-align: center; }
.race-overview-podium li span { font-size: 1.4rem; font-weight: 800; color: var(--muted); }
.race-overview-podium .podium-1 span { color: #d4a514; }
.race-overview-phase { border-top: 1px solid var(--line); padding: 8px 0; }
.race-overview-phase summary { cursor: pointer; padding: 4px 0; }
.race-overview-phase h4 { margin: 12px 0 6px; }
@@ -4883,3 +4881,12 @@ details.event-group > summary { cursor: pointer; list-style: revert; }
/* Sponsor event heats: the car each driver has in this heat, next to the name. */
.overlay-heat-car, .live-heat-car { color: var(--accent-2, #0ea5e9); font-weight: 600; white-space: nowrap; }
.live-heat-car { font-size: 0.85em; margin-left: 6px; }
/* Gold / silver / bronze medals for places 1-3 in result tables (src/medal.js). */
.medal { position: relative; display: inline-grid; place-items: center; width: 1.75em; height: 1.75em; border-radius: 50%; font-weight: 800; font-size: 0.85em; line-height: 1; color: #4a3500; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); background: radial-gradient(circle at 32% 28%, #fff7cf 0%, #f4cf55 38%, #c9971c 75%, #9c7210 100%); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.35); vertical-align: middle; }
.medal-2 { color: #33383f; background: radial-gradient(circle at 32% 28%, #ffffff 0%, #dfe3e8 38%, #a8b0ba 75%, #7d8691 100%); }
.medal-3 { color: #3d2109; background: radial-gradient(circle at 32% 28%, #ffe2c4 0%, #e3a46a 38%, #b06a2c 75%, #84491a 100%); }
.race-overview-podium .medal { width: 2.6em; height: 2.6em; font-size: 1.1rem; justify-self: center; margin-top: 10px; }
.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; }