-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtv.html
187 lines (164 loc) · 4.58 KB
/
tv.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tic Tac Toe</title>
<link rel="stylesheet" href="http://cdn.foundation5.zurb.com/foundation.css">
<style>
.tv-container {
height: 100vh;
}
.top-half, .bot-half {
height: 50vh;
}
table {
margin: 10px auto;
}
.game-info {
margin-top: 12vh;
}
.club-info {
margin-top: 10vh;
}
#powercat-img {
height: 20vh;
}
.square{
width:100px;
height:100px;
text-align: center;
font-weight: bold;
}
.v{
border-left:1px solid #000;
border-right:1px solid #000;
}
.h{
border-top:1px solid #000;
border-bottom:1px solid #000;
}
</style>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="tv-container">
<div class="top-half">
<div class="top-left-col small-6 columns">
<div class="club-info text-center">
<img id="powercat-img" src="/images/powercat.png" />
<span>Web Development Club</span><br><br>
<span>Every Monday 6-7:30PM</span><br><br>
<span>Sign up for the next Tic-Tac-Toe game at <strong>localhost:8080</strong></span>
</div>
</div>
<div class="top-right-col small-6 columns">
<div id="game-info-1" class="game-info small-3 columns">
<h4 class="text-center">Game 1</h4>
</div>
<div id="board-1" class="small-9 columns">
<table>
<tr id="row1">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
<tr id="row2">
<td class="square h"></td>
<td class="square v h"></td>
<td class="square h"></td>
</tr>
<tr id="row3">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
</table>
</div>
</div>
</div>
<div class="bot-half">
<div class="bot-left-col small-6 columns">
<div id="game-info-2" class="game-info small-3 columns">
<h4 class="text-center">Game 2</h4>
</div>
<div id="board-2">
<table>
<tr id="row1">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
<tr id="row2">
<td class="square h"></td>
<td class="square v h"></td>
<td class="square h"></td>
</tr>
<tr id="row3">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
</table>
</div>
</div>
<div class="bot-right-col small-6 columns">
<div id="game-info-3" class="game-info small-3 columns">
<h4 class="text-center">Game 3</h4>
</div>
<div id="board-3" class="small-9 columns">
<table>
<tr id="row1">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
<tr id="row2">
<td class="square h"></td>
<td class="square v h"></td>
<td class="square h"></td>
</tr>
<tr id="row3">
<td class="square"></td>
<td class="square v"></td>
<td class="square"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.2.min.js" integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" crossorigin="anonymous"></script>
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script>
boardInstance('board-1', 1);
boardInstance('board-2', 2);
boardInstance('board-3', 3);
function boardInstance(board, id){
var socket = io();
$boxes = $('#' + board).find('.square');
socket.emit('display_hello', id);
socket.on('start_game', function(){
$.each($boxes, function(index, value){
set(index, '');
});
});
function set(index, contents){
$($boxes[index]).text(contents);
}
socket.on('move_made', function(msg){
set(msg.squareId, msg.symbol);
console.log('MOVE PLAYED');
});
}
// socket.emit('client_hello', function(){
//
// });
//
// var $boxes = $('.square');
//
//
</script>
</body>
</html>