-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathresult.tmpl
More file actions
131 lines (122 loc) · 5.07 KB
/
result.tmpl
File metadata and controls
131 lines (122 loc) · 5.07 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSH Vote</title>
<!-- <link rel="stylesheet" href="https://themeswitcher.csh.rit.edu/api/get" /> -->
<link
rel="stylesheet"
href="https://assets.csh.rit.edu/csh-material-bootstrap/4.3.1/dist/csh-material-bootstrap.min.css"
media="screen"
/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.container div.d-none {
display: none!important;
}
</style>
</head>
<body>
{{ template "nav" . }}
<div class="container main p-5">
{{ if eq .CanVote 9 }}
<div id="already-voted" class="alert alert-info alert-dismissible d-flex flex-row align-items-center" role="alert">
<h5 class="m-0">You have already voted in this poll.</h5>
<button class="close m-0" style="cursor: pointer;" onclick="document.getElementById('already-voted').classList.add('d-none');">
<span class="align-items-center">×</span>
</button>
</div>
{{ else if eq .CanVote 1 }}
<div id="db-error" class="alert alert-danger alert-dismissible 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="close m-0" style="cursor: pointer;" onclick="document.getElementById('db-error').classList.add('d-none');">
<span class="align-items-center">×</span>
</button>
</div>
{{ else if gt .CanVote 1 }}
<div id="cannot-vote" class="alert alert-warning alert-dismissible 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="close m-0 ml-3" style="cursor: pointer;" onclick="document.getElementById('cannot-vote').classList.add('d-none');">
<span class="align-items-center">×</span>
</button>
</div>
{{ end }}
<h2 style="white-space: normal; word-wrap: break-word;">{{ .Title }}</h2>
{{ if .Description }}
<h4>{{ .Description | MakeLinks }}</h4>
{{ end }}
<br />
<br />
{{ if and $.IsHidden $.IsOpen }}
<div id="results">
<h4>Results will be available once the poll closes</h4>
</div>
{{ else }}
{{/* Displays information about required quorum and number of voters */}}
<div id="quorum-info">
<h5>Number of Eligible Voters: {{ len .EligibleVoters }}</h5>
<div id="votes-needed-for-quorum">
{{/* This works currently because quorum type can only be set if gatekeep is required */}}
{{ if not (len .EligibleVoters) }}
<h5>No quorum required for this poll.</h5>
{{ else }}
<h5>Quorum Type: {{ .Quorum }}%</h5>
<h5>Votes Needed For Quorum: {{ .VotesNeededForQuorum }}</h5>
{{ end }}
<br/>
<br/>
</div>
</div>
<div id="results">
{{ range $i, $val := .Results }}
{{ if eq $.VoteType "ranked" }}
<h4>Round {{ $i | inc }}</h4>
{{ end }}
{{ range $option, $count := $val }}
<div id="{{ $option }}" style="font-size: 1.25rem; line-height: 1.25">
{{ $option }}: {{ $count }}
</div>
<br />
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if and (.CanModify) (not .IsHidden) }}
<br />
<br />
<form action="/poll/{{ .Id }}/hide" method="POST">
<button type="submit" class="btn btn-danger">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">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>