-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (85 loc) · 3.1 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Election Calculator</title>
<style> * {font-family:sans-serif;} </style>
<link rel='shortcut icon' type='image/png' href='./favicon.png' />
</head>
<body>
<h1>Election Calculator</h1>
<h2>Step 1: Import Data</h2>
<p>To calculate the results of an election, there must be a list of candidates and a list
of votes. Both lists should be entered into the box below, with a separator of "~~~"
between the sections. An example election between pets is automatically loaded.</p>
<p>In the candidate section, each candidate is listed on a new line. In the vote section,
each vote contains a preference for each candidate in the order the candidates are listed
in the candidate section. "1" indicates the first preference, "2" indicates the second
preference, and so on. Each preference is separated by commas, and each vote is on a
new line. For example, a vote of "2,3,1" would give first preference to the candidate
listed third, second preference to the candidate listed first, and third preference to the
candidate listed second. Make sure that each vote has a preference for each candidate.</p>
<p>Edit the candidates and votes as necessary for your election, and press the "Import
Data" button to confirm the data before selecting an electoral system. The data in the box
can be changed at any time, but you'll need to confirm your changes.</p>
<textarea id="data" name="data" rows="13" cols="30">
Dog
Cat
Fish
Mouse
Hamster
~~~
1,2,3,4,5
5,1,4,3,2
5,4,3,1,2
4,3,5,2,1
4,5,1,3,2
1,5,2,3,4
2,1,3,5,4
1,5,2,4,3
5,4,3,1,2
5,1,4,3,2
5,4,2,3,1
1,3,2,4,5
5,1,2,3,4
1,4,2,5,3
5,2,4,3,1
1,5,2,3,4</textarea>
<br>
<button type="button" id="process">Import Data</button>
<p id="importStatus"></p>
<h2>Step 2: Select Electoral System</h2>
<select name="method" id="method">
<optgroup label="Single-winner systems">
<option value="fptp">First-past-the-post (Plurality voting)</option>
<option value="top2">Two-round system (Contingent vote)</option>
<option value="irv">Instant-runoff voting (Alternative vote)</option>
<option value="bucklin">Bucklin voting</option>
<option value="borda">Borda count</option>
</optgroup>
<optgroup label="Multi-winner systems">
<option value="sntv">Single non-transferable vote</option>
<option value="mntv">Multiple non-transferable vote</option>
</optgroup>
<optgroup label="More systems coming soon!"></optgroup>
</select>
<label id="winnerCountLabel" style="display: none">
Number of winners:
<input type="number" id="winnerCount" style="width: 30px" value="3">
</label>
<label id="bordaTypeLabel" style="display: none">
Point distribution:
<input type="radio" name="bordaType" id="bordaTypeA" checked>
<label for="bordaTypeA">1 to N</label>
<input type="radio" name="bordaType" id="bordaTypeB">
<label for="bordaTypeB">0 to N–1</label>
<input type="radio" name="bordaType" id="bordaTypeC">
<label for="bordaTypeC">Fractional (Dowdall system)</label>
</label>
<p id="description"></p>
<h2>Step 3: Calculate Results</h2>
<button type="button" id="calculate">Calculate results</button>
<p id="winners"></p>
<script src="./election.js"></script>
</body>
<html>