forked from ncase/ballot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel3.html
62 lines (55 loc) · 1.35 KB
/
model3.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/model.css">
</head>
<body></body>
</html>
<script src="js/helpers.js"></script>
<script src="js/minpubsub.js"></script>
<script src="js/Loader.js"></script>
<script src="js/Mouse.js"></script>
<script src="js/Draggable.js"></script>
<script src="js/Model.js"></script>
<script src="js/Candidate.js"></script>
<script src="js/Voters.js"></script>
<script src="js/Election.js"></script>
<script>
Loader.onload = function(){
// SELF CONTAINED MODEL
window.model = new Model();
document.body.appendChild(model.dom);
model.onInit = function(){
// Voters & Candidates
model.addVoters({
dist: GaussianVoters,
type: PluralityVoter,
x:155, y:125
});
model.addCandidate("square", 50, 125);
model.addCandidate("triangle", 250, 125);
model.addCandidate("hexagon", 280, 280);
};
model.onUpdate = function(){
Election.plurality(model);
};
model.init();
// CREATE A RESET BUTTON
var resetDOM = document.createElement("div");
resetDOM.id = "reset";
resetDOM.innerHTML = "reset";
resetDOM.style.top = "415px";
resetDOM.style.left = "110px";
resetDOM.onclick = function(){
model.reset();
};
document.body.appendChild(resetDOM);
};
Loader.load([
"img/voter_face.png",
"img/square.png",
"img/triangle.png",
"img/hexagon.png"
]);
</script>