-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
430 lines (377 loc) · 11.8 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Darwin AFL Scoring - DTS V6</title>
<style>
/*import the font to use for the scoring webpage*/
@font-face {
font-family: 'NewsGoth Cn BT';
src: local('NewsGoth Cn BT'), url('NEWGOTBC_0.TTF') format('truetype');
font-weight: bold;
}
@font-face {
font-family: 'NewsGoth Cn BT';
src: local('NewsGoth Cn BT'), url('NEWSGOTC_0.TTF') format('truetype');
}
html, body{
height: 100%;
}
/*change backgound to green for keying out on video output*/
body {
background-color: #0F0;
margin: 0;
cursor: none; /*hide the cursor when it's not in the controls or scoreboard area*/
}
#controls {
cursor: default;
/*position of the controls*/
position: absolute;
top: 400px;
left: 0px;
}
#logo {
/*position of the logo*/
position: absolute;
top: 10px;
left: 600px;
}
/*set up the initial scoring area*/
#score {
line-height:22px;
width: 385px; /*width of the background image*/
cursor: default;
font-family: 'NewsGoth Cn BT';
/*position of the scoreboard*/
position: absolute;
top: 600px;
left: 40px;
}
#score > div {
float: left;
position: relative;
}
.time div {
height: 50%;
}
.tag, .time, .number, .team {
background-image: url('score-background.png');
background-position-y: -21px;
height: 47px;
padding: 1px;
}
.team, .number {
margin-left: 4px;
}
.tag {
width: 100%;
height: 19px;
padding: 0;
margin-bottom: 2px;
background-position: 0 0;
}
/*font used for displaying the time and qt/ht/3q/ft */
.time {
color:white;
width: 55px; /*width of the first section of the score widget*/
text-align: center;
font-size: 14pt;
background-clip: padding-box;
}
/*font used to display the numbers on the score widget*/
.number {
width: 38px; /* width available for each number on the scoreboard */
font-size: 18pt;
text-align: center;
font-weight: bold;
background-position-x: -254px;
background-clip: padding-box;
transition: transform 240ms ease-out;
z-index: -1;
}
.small {
transform: translateX(-89px);
}
.points {
color: white;
background-position-x: -346px;
}
/*font styling used for the team names*/
.team {
width: 182px; /*the width available for the team name*/
font-size: 15pt;
color: white;
font-weight: bold;
padding-left: 4px;
background-position-x: -63px;
}
</style>
</head>
<body>
<div id="score">
<div class="tag"></div>
<div class="time">
<div id="quarter"></div>
<div id="clock">00:00</div>
</div>
<div class="team">
<div id="home" contenteditable="true">HOME</div>
<div id="away" contenteditable="true">AWAY</div>
</div>
<div class="number">
<div id="home-goals">0</div>
<div id="away-goals">0</div>
</div>
<div class="number">
<div id="home-behinds">0</div>
<div id="away-behinds">0</div>
</div>
<div class="number points">
<div id="home-points">0</div>
<div id="away-points">0</div>
</div>
</div>
<img id='logo' src='logo.png' alt='logo' style="display: none;" />
<table id="controls"><tr><td>
<input type="button" onClick="increaseScore('home', 'goals')" value="+ Home Goal"/>
<input type="button" onClick="increaseScore('home', 'behinds')" value="+ Home Behind"/>
<input type="button" onClick="increaseScore('away', 'goals')" value="+ Away Goal"/>
<input type="button" onClick="increaseScore('away', 'behinds')" value="+ Away Behind"/>
<input type="button" id='view-clock' onClick="clockOn()" value="Time"/>
<input type="button" id='start-quarter1' onClick="startGameTime(0)" value="1st Q start"/>
<input type="button" id='start-quarter2' onClick="startGameTime(1)" value="2nd Q start"/>
<input type="button" id='start-quarter3' onClick="startGameTime(2)" value="3rd Q start"/>
<input type="button" id='start-quarter4' onClick="startGameTime(3)" value="4th Q start"/>
</td></tr>
<tr><td>
<input type="button" onClick="decreaseScore('home', 'goals')" value="- Home Goal"/>
<input type="button" onClick="decreaseScore('home', 'behinds')" value="- Home Behind"/>
<input type="button" onClick="decreaseScore('away', 'goals')" value="- Away Goal"/>
<input type="button" onClick="decreaseScore('away', 'behinds')" value="- Away Behind"/>
<input type="button" onClick="zeroClock()" value="Zero Clock"/>
<input type="button" id='stop-quarter1' onClick="stopGameTime(0)" value="1st Q stop"/>
<input type="button" id='stop-quarter2' onClick="stopGameTime(1)" value="2nd Q stop"/>
<input type="button" id='stop-quarter3' onClick="stopGameTime(2)" value="3rd Q stop"/>
<input type="button" id='stop-quarter4' onClick="stopGameTime(3)" value="4th Q stop"/>
</td></tr>
<tr><td>
<input type="button" onClick="toggleLogo()" value="Toggle Logo" />
</td></tr></table>
<script type="text/javascript">
/*-----------------------------STORAGE FUNCTIONS-----------------------------------*/
var score = {
'home': {
'goals': 0,
'points': 0,
'behinds': 0
},
'away': {
'goals': 0,
'points': 0,
'behinds': 0
}
}
var gametime = [0, 0, 0, 0]; // stores the time of each quarter in seconds
var currentQuarter = -1;
var lastScoreTime = 0; // stores the time the last goal was made
var smallDisplay = false; // whether or not the scoreboard should be small
var totalScoreInterval = 10; // the interval between displaying the full scoreboard and the mini version
// setInterval references
var runDisplayTime = null;
var runGameTime = null;
/*-----------------------------CONTROLLER FUNCTIONS-----------------------------------*/
/**
* This function is called every second to display the current system time on the screen
*/
var displayTime = function() {
var currentTime = new Date();
var timeString = currentTime.toLocaleTimeString('en-GB').slice(0,5); // get the hours and minutes part
document.getElementById('clock').innerHTML = timeString;
}
/**
* This function is called to display the current time to the screen
*/
function clockOn() {
if(runDisplayTime === null) {
displayTime();
runDisplayTime = setInterval(displayTime, 1000);
document.getElementById('quarter').innerHTML = '';
document.getElementById('view-clock').disabled = true;
}
}
/**
* This function stops displaying the current time to the screen
* replacing the current time with '0:00'
*/
function clockOff() {
clearInterval(runDisplayTime);
runDisplayTime = null;
document.getElementById('view-clock').disabled = false;
document.getElementById('clock').innerHTML = '0:00';
}
/**
* This function erases the timings for all the quarters
* and turns off the clock
*/
function zeroClock() {
clockOff();
gametime = [0,0,0,0];
}
/**
* This function displays the game time for the current quarter
* it is called every second to add one second to the timer
*/
function displayGameTime() {
gametime[currentQuarter]++;
var minutes = Math.floor(gametime[currentQuarter]/60);
var seconds = gametime[currentQuarter] % 60;
// pad seconds
if(seconds < 10) {
seconds = '0' + seconds;
}
if(gametime[currentQuarter] - lastScoreTime > totalScoreInterval && !smallDisplay) {
smallDisplay = true;
displayScore();
}
document.getElementById('clock').innerHTML = minutes + ":" + seconds;
}
/**
* This funtion starts the game time for a specific quarter
*
* @param quarter the index of the quarter that is going to start (value 0-3)
*/
function startGameTime(quarter) {
if(runGameTime === null) {
currentQuarter = quarter;
lastScoreTime = gametime[quarter];
runGameTime = setInterval(displayGameTime, 1000);
clockOff();
displayQuarterStart(quarter);
}
}
/**
* This funtion stops the game time for a specific quarter
*
* @param quarter the index of the quarter that is going to stop (value 0-3)
*/
function stopGameTime(quarter) {
clearInterval(runGameTime);
runGameTime = null;
smallDisplay = false;
displayScore();
displayQuarterStop(quarter);
}
/**
* This function increases the score for a specific team
*
* @param team this can either be 'home' or 'away' depending on which team's score to increase
* @param type this can be 'goals' or 'points' depending on what type of score to increase
*/
function increaseScore(team, type) {
score[team][type]++;
score[team].points = score[team].behinds + (score[team].goals*6);
lastScoreTime = gametime[currentQuarter];
smallDisplay = false;
displayScore();
}
/**
* This function decreases the score for a specific team
*
* @param team this can either be 'home' or 'away' depending on which team's score to decrease
* @param type this can either be 'goals' or 'points' depending on what type of score to decrease
*/
function decreaseScore(team, type) {
if(score[team][type] != 0) {
score[team][type]--;
score[team].points = score[team].behinds + (score[team].goals*6);
displayScore();
}
}
/*-----------------------------DISPLAY FUNCTIONS-----------------------------------*/
/**
* This function takes the score values and displays them to the screen
*/
function displayScore() {
const elements = document.getElementsByClassName('number');
for (let i = 0; i < elements.length; i++) {
if (smallDisplay) {
elements[i].classList.add('small');
} else {
elements[i].classList.remove('small');
}
};
//show home team score
document.getElementById('home-goals').innerHTML = score.home.goals;
document.getElementById('home-behinds').innerHTML = score.home.behinds;
document.getElementById('home-points').innerHTML = score.home.points;
// show away team score
document.getElementById('away-goals').innerHTML = score.away.goals;
document.getElementById('away-behinds').innerHTML = score.away.behinds;
document.getElementById('away-points').innerHTML = score.away.points;
}
/**
* This function displays text on the screen when a courter starts
* and disables the buttons related to other quarters
*
* @param quarter the index of the quarter (value ranging 0-3)
*/
function displayQuarterStart(quarter) {
//display text
switch(quarter) {
case 0:
document.getElementById('quarter').innerHTML = "1ST"; break;
case 1:
document.getElementById('quarter').innerHTML = "2ND"; break;
case 2:
document.getElementById('quarter').innerHTML = "3RD"; break;
case 3:
document.getElementById('quarter').innerHTML = "4TH"; break;
}
//disable buttons
for(var i=1; i <= 4; i++) {
document.getElementById('start-quarter'+i).disabled = true;
if(i == quarter+1) {
continue;
}
document.getElementById('stop-quarter'+i).disabled = true;
}
}
/**
* This function displays text on the screen when a courter stops
* and re-enables the quarter selection buttons
*
* @param quarter the index of the quarter (value ranging 0-3)
*/
function displayQuarterStop(quarter) {
//display text
switch(quarter) {
case 0:
document.getElementById('quarter').innerHTML = ("QT"); break;
case 1:
document.getElementById('quarter').innerHTML = ("HT"); break;
case 2:
document.getElementById('quarter').innerHTML = ("3Q"); break;
case 3:
document.getElementById('quarter').innerHTML = ("FT"); break;
}
// enable buttons
for(var i=1; i <= 4; i++) {
document.getElementById('start-quarter'+i).disabled = false;
document.getElementById('stop-quarter'+i).disabled = false;
}
}
/**
* This function toggles whether or not to display the logo on screen
*/
function toggleLogo() {
var element = document.getElementById('logo');
if(element.style.display === 'none') {
element.style.display = 'block';
} else {
element.style.display = 'none';
}
}
</script>
</body>
</html>