mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-21 20:47:59 +01:00
Fix NaN on result refresh
With 0 total votes, the results page would show NaN after the first refresh. Don't divide by 0, children.
This commit is contained in:
parent
cfa150cc42
commit
74a0910d11
1 changed files with 2 additions and 2 deletions
|
@ -60,8 +60,8 @@ function domLoaded() {
|
|||
if (!el) return;
|
||||
|
||||
el.querySelector(".poll-option-votes").innerText = value;
|
||||
el.querySelector(".poll-bar-fill").style.width = (value / totalVotes * 100) + "%";
|
||||
el.querySelector(".poll-bar-text").innerText = Math.round(value / totalVotes * 100);
|
||||
el.querySelector(".poll-bar-fill").style.width = totalVotes ? (value / totalVotes * 100) + "%" : "0%";
|
||||
el.querySelector(".poll-bar-text").innerText = totalVotes ? Math.round(value / totalVotes * 100) : 0;
|
||||
});
|
||||
prevResult = votes;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue