-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathresult.tmpl
More file actions
100 lines (95 loc) · 3.96 KB
/
Copy pathresult.tmpl
File metadata and controls
100 lines (95 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{{ template "header.tmpl" . }}
<div class="container main p-5">
{{ if .IsOpen }}
{{ if eq .CanVote 9 }}
<div id="already-voted" class="alert alert-info alert-dismissible fade show" role="alert">
<h5 class="m-0">You have already voted in this poll.</h5>
<button class="btn btn-close m-0" aria-label="Close" data-bs-dismiss="alert" />
</div>
{{ else if eq .CanVote 1 }}
<div id="db-error" class="alert alert-danger fade show d-flex flex-row align-items-center" role="alert">
<h5 class="m-0">There was an error checking your voting eligibility. Try refreshing the page or contacting the RTPs if the issue persists.</h5>
<button class="btn btn-close m-0" aria-label="Close" data-bs-dismiss="alert" />
</div>
{{ 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,
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>
<button class="btn btn-close m-0" aria-label="Close" data-bs-dismiss="alert" />
</div>
{{ end }}
{{ end }}
<h2 class="text-break">{{ .Title }}</h2>
{{ if .Description }}
<h4>{{ .Description | MakeLinks }}</h4>
{{ end }}
<br />
<br />
{{/* Displays information about required quorum and number of voters */}}
<div id="quorum-info">
<h6>Number of Eligible Voters: {{ len .EligibleVoters }}</h6>
<h6>Votes Cast: {{ .NumVotes }}</h6>
<br class="lh-1" />
<div id="votes-needed-for-quorum">
{{/* This works currently because quorum type can only be set if gatekeep is required */}}
{{ if not .Gatekeep }}
<h6>No quorum required for this poll.</h6>
{{ else }}
<h6>Quorum Type: {{ .Quorum }}%</h6>
<h6>Votes Needed For Quorum: {{ .VotesNeededForQuorum }}</h6>
{{ end }}
<br/>
<br/>
</div>
</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>
<br />
{{ end }}
{{ end }}
</div>
{{ if and (.CanModify) (not .IsHidden) }}
<br />
<br />
<form action="/poll/{{ .Id }}/hide" method="POST">
<button type="submit" class="btn btn-danger py-2 px-3">Hide Votes</button>
</form>
{{ end }}
{{ if and (and (.CanModify) (.IsOpen)) (not .Gatekeep) }}
<br />
<br />
<form action="/poll/{{ .Id }}/close" method="POST">
<button type="submit" class="btn btn-primary py-2 px-3">End Poll</button>
</form>
{{ end }}
</div>
<script>
let eventSource = new EventSource("/stream/{{ .Id }}");
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);
}
element.innerText = option + ": " + count;
}
});
</script>
</body>
</html>