From 39cad5da44f3ee7e573d561fa4b1be9085bfb284 Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Thu, 5 Feb 2026 11:36:14 +0100 Subject: [PATCH] Share ranks across linked games in results --- wwwroot/js/ui.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wwwroot/js/ui.js b/wwwroot/js/ui.js index 02967c9..1b9d6c6 100644 --- a/wwwroot/js/ui.js +++ b/wwwroot/js/ui.js @@ -241,11 +241,19 @@ export function renderResults() { `; const tbody = table.querySelector("tbody"); - state.results.forEach((r, idx) => { + const rankByRoot = new Map(); + let nextRank = 1; + state.results.forEach((r) => { + const root = linkRootId(r); + let rank = rankByRoot.get(root); + if (!rank) { + rank = nextRank++; + rankByRoot.set(root, rank); + } + const medal = rank === 1 ? "🥇" : rank === 2 ? "🥈" : rank === 3 ? "🥉" : `${rank}`; const row = document.createElement("tr"); - const podiumClass = idx === 0 ? "podium podium-1" : idx === 1 ? "podium podium-2" : idx === 2 ? "podium podium-3" : ""; + const podiumClass = rank === 1 ? "podium podium-1" : rank === 2 ? "podium podium-2" : rank === 3 ? "podium podium-3" : ""; row.className = podiumClass; - const medal = idx === 0 ? "🥇" : idx === 1 ? "🥈" : idx === 2 ? "🥉" : `${idx + 1}`; row.innerHTML = ` ${medal}