-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
71 lines (68 loc) · 2.4 KB
/
index2.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
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href={{ static_url("style.css") }} />
</head>
<script>
var ws = new WebSocket("ws://localhost:8888/ws");
var client_id;
ws.onopen = function() {
// pass row and col here
console.log("Index 2 in")
ws.send(JSON.stringify({type: 2}));
};
ws.onmessage = function (evt) {
data = JSON.parse(evt.data);
if(data.type == 0) {
console.log("id assigned")
client_id = data.client_id;
}
else if(data.type == 1) {
console.log()
var algo1 = document.getElementById("algo1");
var algo2 = document.getElementById("algo2");
var options = data.algoList;
console.log(data.algoList)
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
var el2 = document.createElement("option");
el2.textContent = opt;
el2.value = opt;
algo1.appendChild(el);
algo2.appendChild(el2);
}
}
};
window.onbeforeunload = function() {
ws.send(JSON.stringify({type: 1, client_id: client_id}));
ws.onclose = function () {}; // disable onclose handler first
ws.close()
};
</script>
<body>
<header id="header">
<h1>Battleground</h1>
<div id="tag">
<div id="tagline">AI Challenge</div>
</div>
<div id="game-info">Source code: <a href="https://github.com/SpanishArmada/Battleground">Our Code Here!</a>
</div>
</header>
<div class="block h-center v-center">
<form id="algoForm" method="POST" action="simulate" enctype="multipart/form-data" class="form-dropdown">
<h3 style="display:inline">First Algorithm</h3>
<select id="algo1" name="algo1" class="form-dropdown">
</select></br>
<h3>Vs</h3>
<h3 style="display:inline">Second Algorithm</h3>
<select id="algo2" name="algo2">
</select>
<br/><br/>
<input type="submit" value="Go!" class="btn btn-default" style="margin:5px"/>
</div>
</form>
</body>
</html>