Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions templates/result.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ else if gt .CanVote 1 }}
<div id="cannot-vote" class="alert alert-warning fade show d-flex flex-row align-items-center" role="alert">
<h5 class="m-0">
You are not eligible to vote in this poll. This is likely because you are not an Active Member,
You are not eligible to vote in this poll. This is likely because you are not an Active Member,
or because you did not meet the gatekeep requirements by the time the poll opened.
If you believe this is an error, please contact Evals or Opcomm.
</h5>
Expand Down Expand Up @@ -51,15 +51,17 @@
</div>
<div id="results">
{{ range $i, $val := .Results }}
{{ if eq $.VoteType "ranked" }}
<h4 class="mb-3"><u>Round {{ $i | inc }}</u></h4>
{{ end }}
{{ range $option, $count := $val }}
<div id="{{ $option }}" class="fs-5 lh-sm">
{{ $option }}: {{ $count }}
<div id="round-{{ $i }}">
{{ if eq $.VoteType "ranked" }}
<h4 class="mb-3"><u>Round {{ $i | inc }}</u></h4>
{{ end }}
{{ range $option, $count := $val }}
<div id="{{ $i }}-{{ $option }}" class="fs-5 lh-sm">
{{ $option }}: {{ $count }}
</div>
{{ end }}
</div>
<br />
{{ end }}
{{ end }}
</div>
{{ if and (.CanModify) (not .IsHidden) }}
Expand All @@ -82,17 +84,20 @@

eventSource.addEventListener("{{ .Id }}", function (event) {
let data = JSON.parse(event.data);
for (let option in data) {
let count = data[option];
let element = document.getElementById(option);
if (element == null) {
let newElement = document.createElement("div");
newElement.id = option;
newElement.style = "font-size: 1.25rem; line-height: 1.25";
newElement.innerText = option + ": " + count;
document.getElementById("results").appendChild(newElement);
for (let roundNum in data) {
for (let option in data[roundNum]) {
let count = data[roundNum][option];
let element = document.getElementById(`${roundNum}-${option}`);
if (element == null) {
let newElement = document.createElement("div");
newElement.id = option;
newElement.style = "font-size: 1.25rem; line-height: 1.25";
newElement.innerText = option + ": " + count;
console.log(`round-${roundNum}`);
document.getElementById(`round-${roundNum}`).appendChild(newElement);
}
element.innerText = option + ": " + count;
}
element.innerText = option + ": " + count;
}
});
</script>
Expand Down
Loading