-
Notifications
You must be signed in to change notification settings - Fork 1
/
board.html
47 lines (35 loc) · 1.18 KB
/
board.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
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src='https://cdn.firebase.com/v0/firebase.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<script src='./functions.js'></script>
</head>
<body>
<title>Naughts and Crosses</title>
<p>Please visit: <b>cs290b.drew.waran.is</b></p>
<div id="boardDiv"></div>
<script>
var board = new Array(9);
for (var i = 0; i < board.length; i++){
board[i] = '<font color="C0C0C0">' + (i+1) + '</font>';
}
var queueRef = new Firebase('https://cs290b.firebaseio.com/queue');
queueRef.on('child_added', function(snapshot) {
var message = snapshot.val();
var mark = message.mark
if (mark == 'c') {
mark = '<font color="C0C0C0">' + (message.box+1) + '</font>';
};
board[message.box] = mark;
drawTable(board);
var winners = determineWinners(board);
if (! $.isEmptyObject(winners)) {
alert(stringifyWinners(winners));
};
});
drawTable(board);
</script>
</body>
</html>