forked from tonylegrone/superbowl-squares
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
212 lines (175 loc) · 7.05 KB
/
index.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<!--[if lt IE 9]><html class="ie"><![endif]-->
<!--[if gte IE 9]><!--><html><!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Superbowl Squares</title>
<link rel="shortcut icon" href="favicon.png" type="image/vnd.microsoft.icon" />
<link rel="stylesheet" href="libraries/jquery-ui-1.9.1/css/smoothness/jquery-ui-1.9.1.custom.css" />
<link rel="stylesheet" href="styles/global.css" type="text/css" />
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="main-wrapper">
<header>
<h1>Superbowl Squares</h1>
<form id="teams" action="javascript:;">
<input class="team-home" type="text" name="team-home-name" placeholder="Home team" data-obj-path="game.teams.0" />
VS
<input class="team-away" type="text" name="team-away-name" placeholder="Away team" data-obj-path="game.teams.1"/>
</form>
</header>
<div id="page-wrapper"><section>
<table id="content">
<tbody>
<tr>
<td id="score-table-wrapper">
<section>
<table id="score-table">
<thead>
<tr id="stuff">
</tr>
</thead>
<tbody id="stuff2">
</tbody>
</table>
</section>
</td><!-- /#score-table-wrapper -->
<td class="spacer"></td>
<td id="players-wrapper">
<section>
<form id="add-player" action="javascript:;">
<input type="text" id="player-name" name="player-name" placeholder="Add player" />
<button>+</button>
</form>
<h1>Players</h1>
<ol id="player-list"></ol>
</section>
</td><!-- /#players -->
</tr>
</tbody>
</table><!-- /#content -->
</section></div><!-- /#page-wrapper -->
<footer>
<table id="quarters">
<tbody>
<tr>
<td id="q1" class="quarter">
<h2>Score: Q1</h2>
<div class="status"></div>
<div class="score">
<form action="javascript:;" id="q1-score">
<input maxlength="2" class="team-home" type="text" id="team-home-0" name="team-home-0" data-obj-path="game.scores.0.0" /> —
<input maxlength="2" class="team-away" type="text" id="team-away-0" name="team-away-0" data-obj-path="game.scores.0.1" />
</form>
</div>
</td>
<td class="spacer"></td>
<td id="q2" class="quarter">
<h2>Score: Q2</h2>
<div class="status"></div>
<div class="score">
<form action="javascript:;" id="q2-score">
<input maxlength="2" class="team-home" type="text" id="team-home-1" name="team-home-1" data-obj-path="game.scores.1.0" /> —
<input maxlength="2" class="team-away" type="text" id="team-away-1" name="team-away-1" data-obj-path="game.scores.1.1" />
</form>
</div>
</td>
<td class="spacer"></td>
<td id="q3" class="quarter">
<h2>Score: Q3</h2>
<div class="status"></div>
<div class="score">
<form action="javascript:;" id="q3-score">
<input maxlength="2" class="team-home" type="text" id="team-home-2" name="team-home-2" data-obj-path="game.scores.2.0" /> —
<input maxlength="2" class="team-away" type="text" id="team-away-2" name="team-away-2" data-obj-path="game.scores.2.1" />
</form>
</div>
</td>
<td class="spacer"></td>
<td id="q4" class="quarter">
<h2>Score: Q4</h2>
<div class="status"></div>
<div class="score">
<form action="javascript:;" id="q4-score">
<input maxlength="2" class="team-home" type="text" id="team-home-3" name="team-home-3" data-obj-path="game.scores.3.0" /> —
<input maxlength="2" class="team-away" type="text" id="team-away-3" name="team-away-3" data-obj-path="game.scores.3.1" />
</form>
</div>
</td>
</tr>
</tbody>
</table><!-- /#quarters -->
</footer>
<input name="Submit" type="submit" value="GenRowCol" onClick="JavaScript:handleClickGenRowCol()"/>
</div><!-- /#main-wrapper -->
<script type="text/javascript" src="libraries/jquery-ui-1.9.1/js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="libraries/jquery-ui-1.9.1/js/jquery-ui-1.9.1.custom.min.js"></script>
<script type="text/javascript" src="libraries/json2/json2.js"></script>
<script type="text/javascript">
GRID_SIZE = 10;
$(document).ready(function(){
tr = [];
for (i=1; i<= GRID_SIZE; i++) {
td = [];
for (j = 1;j<=GRID_SIZE; j++){
td.push("<td class='grid-" + i + "-" + j + " cell' data-obj-path='game.grid.cell." + i + "." + j + "'></td>");
}
tr.push("<tr class='row-" + i + "'>\n\t<th class='team-away' data-obj-path='game.grid.header." + i + ".0'></th>\n\t" + td.join("\n\t") + '</tr>');
}
for ($i = 0; $i <= GRID_SIZE; $i++) {
$("#stuff").append( "<th class='team-home' data-obj-path='game.grid.header.0." + $i + "'></th>");
}
$("#stuff2").html(tr.join("\n"));
});
</script>
<script type="text/javascript" src="scripts/global.js"></script>
<script type="text/javascript">
function makeRows() {
console.log("makerows")
var scores = getNumbers();
for (i=0;i<GRID_SIZE;i++){
var cur = scores.pop();
console.log("Row:" + cur)
// write code to jam cur into the DOM header - this is all that is needed and it's done!
}
var scores = getNumbers();
for (i=0;i<GRID_SIZE;i++){
var cur = scores.pop();
console.log("Col:" + cur) // replace with code to put into DOM
// write code to jam cur into the DOM header - this is all that is needed and it's done!
}
}
function getNumbers() {
var scores = [0,1,2,3,4,5,6,7,8,9];
return(shuffle(scores));
}
function shuffle(array) {
var currentIndex = array.length
, temporaryValue
, randomIndex
;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function handleClickGenRowCol()
{
makeRows();
}
</script>
</body>
</html>