mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-25 06:07:58 +01:00
Sort entries by votes
The entries on the result page are now ordered by the amount of votes they got. This should make discerning a winner much easier.
This commit is contained in:
parent
6764a0af63
commit
2f40091c6f
1 changed files with 1 additions and 1 deletions
|
@ -124,7 +124,7 @@ export default function init(router: Router): void {
|
||||||
).then(r => r.json()) as PollResult;
|
).then(r => r.json()) as PollResult;
|
||||||
if (!poll || poll.error) return res.redirect("/");
|
if (!poll || poll.error) return res.redirect("/");
|
||||||
const totalVotes = Object.values(poll.votes).reduce((acc, cur) => acc + cur, 0);
|
const totalVotes = Object.values(poll.votes).reduce((acc, cur) => acc + cur, 0);
|
||||||
const pollOptionsDivs = Object.entries(poll.votes).map(([option, votes]) => `
|
const pollOptionsDivs = Object.entries(poll.votes).sort((a, b) => b[1] - a[1]).map(([option, votes]) => `
|
||||||
<div class="poll-option" option="${ xss(option) }">
|
<div class="poll-option" option="${ xss(option) }">
|
||||||
<div class="poll-option-info">
|
<div class="poll-option-info">
|
||||||
<div class="poll-option-text">${ xss(option) }</div><div class="poll-option-votes">${ votes }</div>
|
<div class="poll-option-text">${ xss(option) }</div><div class="poll-option-votes">${ votes }</div>
|
||||||
|
|
Loading…
Reference in a new issue