-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
70 lines (70 loc) · 3.2 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
<html>
<head>
<meta charset="utf-8">
<title>VoteChain</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<script src="js/require.js"></script>
</head>
<body>
<script type="text/javascript" src="js/blockupdated.js"></script>
<div id="text-center">
<h1>VoteChain</h1>
<p id="tagline">Chaining your votes since 2017</p>
<div id="voting_area">
<div id="userverif">
Enter your UID: <input type="text" name="uid" id="uid"/><br/><br/>
<button id="uidButton" type="submit">Enable</button>
<script>
document.getElementById("uidButton").onclick = function(e) {
if(checkUID(document.getElementById("uid").value)) {
alert("Eligible for voting!");
document.getElementById("cast").disabled = false;
} else {
alert("Not eligible for voting!");
}
}
</script>
</div>
<br/><br/>
<div id="candidates">
Choose a candidate:<br/>
<ul id="candi_list">
<input type="radio" name="candidate" class="candidate" id="c1">Candidate 1 <br>
<input type="radio" name="candidate" class="candidate" id="c2">Candidate 2 <br>
<input type="radio" name="candidate" class="candidate" id="c3">Candidate 3 <br>
<input type="radio" name="candidate" class="candidate" id="c4">Candidate 4 <br>
</ul>
</div>
<button id="cast" disabled="disabled" >Vote</button>
<div id="notif"></div>
<div id="vote_ticker"></div>
<script>
var candidateRadios = document.getElementsByClassName("candidate");
document.getElementById("cast").onclick = function(e) {
var candidateNum = 0;
for(i = 0; i < candidateRadios.length; i++) {
if(candidateRadios[i].checked) {
candidateNum = i+1;
document.getElementById("cast").disabled = true;
createBlockChain(i+1);
alert("Your vote is recorded!");
break;
}
}
for (i = 0; i < candidateRadios.length; i++) {
candidateRadios[i].checked = false;
}
if(candidateNum == 0) {
document.getElementById("notif").innerHTML = "Vote not recorded";
alert("Select a candidate from the list");
} else {
document.getElementById("notif").innerHTML = "Voted for candidate #" + candidateNum;
}
document.getElementById("vote_ticker").innerHTML = updateVotes() + " votes so far";
}
</script>
</div>
</div>
</body>
</html>