Show emoji votes and my vote in results

This commit is contained in:
2026-02-04 15:17:25 +01:00
parent e6dd64649d
commit 243377ea70
3 changed files with 24 additions and 12 deletions

View File

@@ -216,9 +216,8 @@ export function renderResults() {
<th>${t("results.rank")}</th>
<th>${t("results.game")}</th>
<th>${t("results.author")}</th>
<th>${t("results.votes")}</th>
<th>${t("results.avg")}</th>
<th>${t("results.total")}</th>
<th>${t("results.votesList")}</th>
<th>${t("results.myVote")}</th>
<th>${t("results.links")}</th>
</tr>
</thead>
@@ -240,9 +239,8 @@ export function renderResults() {
</div>
</td>
<td class="author-cell">${r.author ?? "—"}</td>
<td>${r.count}</td>
<td>${r.average.toFixed(1)}</td>
<td>${r.total}</td>
<td>${formatVotes(r.votes)}</td>
<td>${formatMyVote(r.myVote)}</td>
<td>
${r.gameUrl ? `<a class="link compact" href="${r.gameUrl}" target="_blank" rel="noopener">${t("results.link.site")}</a><br>` : ''}
${r.youtubeUrl ? `<a class="link compact" href="${r.youtubeUrl}" target="_blank" rel="noopener">${t("results.link.youtube")}</a>` : ''}
@@ -587,6 +585,17 @@ export function neutralEmoji() {
return "😐";
}
function formatVotes(votes) {
if (!Array.isArray(votes) || votes.length === 0) return "—";
const sorted = [...votes].sort((a, b) => a - b);
return sorted.map((v) => scoreToEmoji(v)).join(" ");
}
function formatMyVote(score) {
if (score == null || Number.isNaN(score)) return "—";
return `${score} ${scoreToEmoji(score)}`;
}
function isValidImageUrl(url) {
if (!url) return true;
try {