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}