-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend_vote.html
68 lines (67 loc) · 2.52 KB
/
frontend_vote.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>E-voting web application </title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="description" content="DistrictA">
<script src="https://unpkg.com/bigchaindb-driver@4.0.0/dist/browser/bigchaindb-driver.window.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://unpkg.com/jquery"></script>
</head>
<body>
<h1>E-voting web application</h1>
<form>
<div ng-app = "">
<input type="text" id="token" value="Please insert your token">
<button onclick="tokenVerification()">Verify your token</button>
<p id="token"></p>
<script>
function tokenVerification() {
var x = document.getElementById("token").value;
document.getElementById("token").innerHTML = x;
}
</script>
<p>Vote your party:</p>
<div>
<input type = "radio" ng-model = "Vote" value="White" checked>
<label for="White">White</label>
</div>
<div>
<input type = "radio" ng-model = "Vote" value="Brown" checked>
<label for="Brown">Brown</label>
</div>
<div>
<input type = "radio" ng-model = "Vote" value="Pink" checked>
<label for="Pink">Pink</label>
</div>
<div>
<input type = "radio" ng-model = "Vote" value="Abstention" checked>
<label for="Pink">Abstention</label>
</div>
</div>
<button type="submit">Submit</button>
</form>
<pre id="log">
</pre>
<script type="text/javascript" src="./vote_transaction.js"></script>
<script>
var form = document.querySelector("form");
var log = document.querySelector("#log");
form.addEventListener("submit", function(event) {
var data = new FormData(form);
var output = "";
for (const entry of data) {
output = "{ \"Vote\": \""+ entry[1]+"\"}";
};
log.innerText = output;
console.log(output);
var outputParsed = JSON.parse(output);
console.log(outputParsed);
//to do: check if send to the blockchain
sendTransatcionToBigChainDB(outputParsed);
event.preventDefault();
},false);
</script>
</body>
</html>