Share ranks across linked games in results
This commit is contained in:
@@ -241,11 +241,19 @@ export function renderResults() {
|
|||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
`;
|
`;
|
||||||
const tbody = table.querySelector("tbody");
|
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 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;
|
row.className = podiumClass;
|
||||||
const medal = idx === 0 ? "🥇" : idx === 1 ? "🥈" : idx === 2 ? "🥉" : `${idx + 1}`;
|
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td class="rank-cell"><span class="medal">${medal}</span></td>
|
<td class="rank-cell"><span class="medal">${medal}</span></td>
|
||||||
<td class="game-cell">
|
<td class="game-cell">
|
||||||
|
|||||||
Reference in New Issue
Block a user