-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
854 lines (755 loc) · 32.1 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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Croquet Tracker</title>
<!--//
Notes
Almost all prior notes transferred as Git issues
8.1 Fixed bugs in hoops, which was using "8" as the value to rescind a hoop shot, resulting in player unable to get past hoop 8. Replaced with 17
//-->
<script>
// <!-- hitter of ball -->
var htr=0
// <!-- hit object -->
var ht=0
// <!-- total hoops in game -->
var totHoops=16
// <!-- holds player names -->
var names = [];
// <!-- holds ball colours; not currently alterable. could offer ability in setup -->
// <!-- I added in a pink background for the out of bounds button -->
var balls = ["blue","red","black","yellow","green","orange","pink"];
// <!-- The validation is now working. Now I need to consider 1 stripping out single and double quotes 2 adding the names to the array -->
function validateForm() {
for (var i = 1; i < 7; i++) {
if (i < 6) {
var j = i+1
}
var a = document.getElementById("player" + [i] ).value;
var b = document.getElementById("player" + [j] ).value;
if (a=="" || a==null) {
if ( b=="" || b==null ) {
if (i < 3) {
window.alert("You need at least a couple of players.");
return false;
}
}
else {
window.alert("Please populate player fields in order. You can't skip a colour. Player " + [j-1] + " is missing. If you have different coloured balls, change the colours by selecting them." );
return false;
break;
}
}
else {
// <!-- I add the value to the names array -->
// <!-- i-1 would be the name array value -->
names.push(a);
}
}
// <!-- The openBalls array includes information on balls, as well as on whether player is inbounds, and what hoop shooting for -->
// 2017 What is with this second array?
openBalls = [["owns","live","live","live","live","live","in",1],
["live","owns","live","live","live","live","in",1],
["live","live","owns","live","live","live","in",1],
["live","live","live","owns","live","live","in",1],
["live","live","live","live","owns","live","in",1],
["live","live","live","live","live","owns","in",1]];
startGame()
}
// <!-- Didn't write. Using to timestamp the game log -->
function displayTime() {
var str = "";
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
if (minutes < 10) {
minutes = "0" + minutes
}
if (seconds < 10) {
seconds = "0" + seconds
}
str += hours + ":" + minutes + ":" + seconds + " ";
if(hours > 11){
str += "PM"
} else {
str += "AM"
}
return str;
}
function preGame() {
document.getElementById("shooting").style.display="none";
document.getElementById("newshooting").style.display="none";
document.getElementById("field").style.display="none";
document.getElementById("summary").style.display="none";
document.getElementById("bounds").style.display="none";
document.getElementById("actionmenu").style.display="none";
for (var j = 0; j < balls.length; j++)
{
document.getElementById("ball" + [j]).style.display="none";
}
}
function startGame() {
trn=0 ;
// trn=names.length;
// <!-- Hide the Setup and open the game view-->
document.getElementById("setup").style.display="none";
// document.getElementById("shooting").style.display="inline";
document.getElementById("newshooting").style.display="flex";
document.getElementById("secondary").style.display="none";
document.body.style.backgroundImage="none";
document.getElementById("summary").style.display="inline";
document.getElementById("playbyplay").style.display="none";
document.getElementById("bounds").style.display="inline";
document.getElementById("bounds").disabled=false;
document.getElementById("bounds").style.color="Black";
// 2017 Hoop is something that can be done with svg and text
// <!-- Populate hoop value -->
var select = document.getElementById("hps");
totHoops= select.options[select.selectedIndex].value;
// // 2017 Play by play could be done a lot more elegantly
// <!-- Populate "playbyplay" log -->
var starttime = displayTime();
document.getElementById("playbyplay").innerHTML="<h2>Game Summary</h2>";
document.getElementById("playbyplay").innerHTML+= [starttime] + ": ";
document.getElementById("playbyplay").innerHTML +="Game begins, hoops/pegs: " + [totHoops] + "<br />";
// <!-- Populate the actions menu -->
buildActionsMenu();
// <!-- Enable Next Player function, now that we've started -->
// 2017 This is where I put in svg for next player
document.getElementById("mainaction").src="images/" + balls[trn+1] + "live.png";
document.getElementById("mainaction").value="Next turn, " +balls[trn+1];
document.getElementById("mainaction").title="Next turn, " +names[trn+1];
document.getElementById("mainaction").alt="Next turn, " +names[trn+1];
document.getElementById("mainaction").onclick = nextTurn;
// <!-- Put trn value to the max so that the nextTurn function trips the else statement -->
trn=names.length
nextTurn([trn])
// <!-- Set focus to top -->
document.getElementById("hoopsvg").focus();
}
function nextTurn() {
if (trn < names.length-1) {
trn++ ;
}
else {
trn=0 ;
}
<!-- Check to see if the player is out of bounds -->
if (openBalls[trn][6]=="out")
{
window.alert( names[trn] + " lost turn. Place ball back in play.");
openBalls[trn][6]="in"
var timestamp = displayTime();
document.getElementById("playbyplay").innerHTML += [timestamp] + ": ";
document.getElementById("playbyplay").innerHTML += "<img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " + names[trn] + " forfeits turn. Ball is put back in play<br />";
nextTurn()
}
else
{
<!-- Set up action menu for player -->
buildActionsMenu()
<!-- Populate new player and log values -->
var timestamp = displayTime();
document.getElementById("playbyplay").innerHTML += [timestamp] + ": ";
document.getElementById("current").innerHTML="<p align='center'><input type='image' src='images/" + balls[trn] + "live.png' aria-haspopup='true' width='60' height='60' value='" + balls[trn] + "ball active' title = '" + balls[trn] + "ball active' onclick='showMenu();' alt='" + balls[trn] + " ball active'> " + "<br /><strong>" + names[trn] + " shooting</strong></p>";
document.getElementById("playbyplay").innerHTML +="<img style='width:1em; height:1em; vertical-align: middle;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " +names[trn] + " is up, shooting for <img style='width:1em; height:1em; vertical-align: middle;' src='images/" + openBalls[trn][7] + "hoop.png' alt='hoop " + openBalls[trn][7] + "'><br />";
document.getElementById("hoopsvg").innerHTML=openBalls[trn][7];
// document.getElementById("nexthoop").src="images/" + openBalls[trn][7] + "hoop.png";
// document.getElementById("nexthoop").value='hoop' + openBalls[trn][7];
<!-- do I need to put in an ALT and TITLE, or is the value considered acceptable? -->
// Need to add in this aria for hoopsvg?
// document.getElementById("nexthoop").setAttribute('aria-describedby','current');
document.getElementById("status").innerHTML = ""
<!-- Get the balls displayed with appropriate status -->
setupBalls([trn])
<!-- Update the next player ball colour -->
if (trn < names.length-1) {
document.getElementById("mainaction").src="images/" + balls[trn+1] + "live.png";
document.getElementById("mainaction").value="Next turn, " +balls[trn+1];
document.getElementById("mainaction").title="Next turn, " +names[trn+1];
document.getElementById("mainaction").alt="Next turn, " +names[trn+1];
}
else {
document.getElementById("mainaction").src="images/" + balls[0] + "live.png";
document.getElementById("mainaction").value="Next turn, " +balls[0];
document.getElementById("mainaction").title="Next turn, " +names[0];
document.getElementById("mainaction").alt="Next turn, " +names[0];
}
<!-- Set focus on hoop -->
document.getElementById("hoopsvg").focus();
}
}
function showShooting(){
<!-- document.getElementById("current").style.display="inline"; -->
// document.getElementById("shooting").style.display="inline";
document.getElementById("newshooting").style.display="flex";
<!-- alter controls -->
document.getElementById("summary").style.display="inline";
document.getElementById("controls").style.display="inline";
document.getElementById("playbyplay").style.display="none";
// document.getElementById("playbyplay").style.display="inline";
document.getElementById("bounds").style.display="inline";
document.getElementById("bounds").disabled=false;
document.getElementById("bounds").style.color="Black";
if (trn < names.length-1) {
document.getElementById("mainaction").src="images/" + balls[trn+1] + "live.png";
document.getElementById("mainaction").value="Next turn, " +balls[trn+1];
document.getElementById("mainaction").alt="Next turn, " +balls[trn+1];
document.getElementById("mainaction").title="Next turn, " +balls[trn+1];
}
else {
document.getElementById("mainaction").src="images/" + balls[0] + "live.png";
document.getElementById("mainaction").value="Next turn, " +balls[0];
document.getElementById("mainaction").alt="Next turn, " +balls[0];
document.getElementById("mainaction").title="Next turn, " +balls[0];
}
document.getElementById("mainaction").onclick = nextTurn;
<!-- turn off other regions -->
document.getElementById("field").style.display="none";
<!-- Update display -->
document.getElementById("setup").style.display="none";
document.getElementById("secondary").style.display="none";
document.body.style.backgroundImage="none";
<!-- Set focus on hoop -->
document.getElementById("hoopsvg").focus();
}
function showMenu(){
<!-- alter view -->
document.getElementById("shooting").style.display="none";
document.getElementById("newshooting").style.display="none";
document.getElementById("field").style.display="none";
document.getElementById("controls").style.display="none";
document.getElementById("playbyplay").style.display="none";
document.getElementById("actionmenu").style.display="inline";
<!-- alter main control -->
document.getElementById("summary").style.display="none";
document.getElementById("bounds").style.display="none";
}
function hideMenu() {
document.getElementById("actionmenu").style.display="none";
showShooting();
}
function setupBalls(trn) {
for (var j = 0; j < names.length; j++) {
var circlex = document.getElementById("circle" + [j] );
var titx = "title" + [j];
if (openBalls[trn][j]=="live")
{
document.getElementById("ball" + [j]).style.display="inline";
circlex.style.fill= balls[j];
circlex.style.stroke= balls[j];
document.getElementById([titx]).textContent = balls[j] + " live";
document.getElementById("pos" + [j]).style.display="inline";
document.getElementById("text" + [j]).innerHTML= names[j] ;
document.getElementById("ball" + [j]).disabled=false;
document.getElementById("ball" + [j]).src="images/" + balls[j] + "live.png";
document.getElementById("ball" + [j]).value= balls[j] + " ball alive";
document.getElementById("ball" + [j]).alt= balls[j] + " ball alive";
document.getElementById("ball" + [j]).title= balls[j] + " ball alive";
document.getElementById("pos" + [j]).alt= balls[j] + " ball alive";
document.getElementById("pos" + [j]).title= balls[j] + " ball alive";
}
else if (openBalls[trn][j]=="owns")
{
document.getElementById("ball" + [j]).style.display="none";
document.getElementById("pos" + [j]).style.display="none";
}
else {
document.getElementById("ball" + [j]).style.display="inline";
document.getElementById("pos" + [j]).style.display="inline";
circlex.style.fill= "white";
circlex.style.stroke= balls[j];
document.getElementById([titx]).textContent = balls[j] + " dead";
<!-- document.getElementById("ball" + [j]).disabled=true; -->
document.getElementById("ball" + [j]).src="images/" + balls[j] + "dead.png";
document.getElementById("ball" + [j]).value= balls[j] + " ball dead";
document.getElementById("ball" + [j]).alt= balls[j] + " ball dead";
document.getElementById("ball" + [j]).title= balls[j] + " ball dead";
document.getElementById("pos" + [j]).alt= balls[j] + " ball dead";
document.getElementById("pos" + [j]).title= balls[j] + " ball dead";
}
}
}
<!-- Takes hitter htr and hoop hp values from openBalls values based on who and what is active when the respective buttons are clicked -->
function clearHoop(htr,hp) {
if (hp==17)
<!-- Manually Cancel hoop via menu -->
{
if (openBalls[trn][7]==1)
{
window.alert("Player is shooting for the first hoop");
}
else
{
openBalls[trn][7]=openBalls[trn][7]-1
// document.getElementById("nexthoop").src="images/" + openBalls[trn][7] + "hoop.png";
// document.getElementById("nexthoop").value="hoop" + openBalls[trn][7];
// document.getElementById("nexthoop").title="hoop" + openBalls[trn][7];
document.getElementById("hoopsvg").innerHTML= openBalls[trn][7];
<!--mg this will break? add: + openBalls[trn][7] then I changed 'hoop' to 'spinach' -->
document.getElementById("playbyplay").innerHTML +="<img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " +names[trn] + " put back to <img style='width:1em; height:1em; vertical-align: middle;' src='images/" + openBalls[trn][7] + "hoop.png' alt='hoop " + openBalls[trn][7] + "'> <br />";
}
}
else
{
var hp = 7
var hoopPassed = openBalls[htr][hp];
openBalls[htr][hp]=openBalls[htr][hp]+1
var timestamp = displayTime();
document.getElementById("playbyplay").innerHTML += [timestamp] + ": ";
<!-- check to see if this is the last hoop -->
if (openBalls[htr][hp]>[totHoops])
{
window.alert(names[htr] + " has finished!");
document.getElementById("playbyplay").innerHTML +="<img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " + names[htr] + " pegs out" + "<br />";
}
// <!-- Check if the hitter is pushing someone else's ball through the hoop -->
else if ([trn]!=htr)
{
window.alert(names[trn] + " pushed player through; " + names[htr] + " will be shooting for " + openBalls[htr][hp]);
document.getElementById("playbyplay").innerHTML +="<img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " +names[trn] + " pushed " + names[htr] + " through <img style='width:1em; height:1em; vertical-align: middle;' src='images/" + hoopPassed + "hoop.png' alt='hoop " + hoopPassed + "'> <br />";
}
// <!-- Advanced the hitter's hoop -->
else
{
document.getElementById("hoopsvg").innerHTML= openBalls[trn][7];
if (openBalls[trn][7]>9) {
document.getElementById("hoopsvg").style.textIndent = "-20px";
}
document.getElementById("playbyplay").innerHTML +="<img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " +names[trn] + " clears <img style='width:1em; height:1em; vertical-align: middle;' src='images/" + hoopPassed + "hoop.png' alt='hoop " + hoopPassed + "'> <br />";
for (var j = 0; j < names.length; j++) {
if (openBalls[trn][j]=="dead")
{
openBalls[trn][j]="live";
<!-- This next line assigns colour based on balls variable name -->
// 2017 These 4 lines can get taken out
document.getElementById("ball" + [j]).src="images/" + balls[j] + "live.png";
<!-- document.getElementByID("ball" + [j]).value=balls[j] + "live"; -->
document.getElementById("ball" + [j]).style.color="White";
document.getElementById("ball" + [j]).disabled=false;
var circlex = document.getElementById("circle" + [j] );
var titx = "title" + [j];
document.getElementById([titx]).textContent = balls[j] + " live";
var circlestate = circlex.style.fill.value;
// 2017 shouldn't this be circlestate, otherwise, what is point of prior line
circlex.style.fill= balls[j];
}
}
}
}
}
function hitBall(htr,ht) {
var timestamp = displayTime();
if ([ht]==6)
{
document.getElementById("playbyplay").innerHTML += [timestamp] + ": <img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " + names[trn] + " goes out of bounds <br \>";
<!-- document.getElementById("playbyplay").innerHTML += names[trn] +" goes out of bounds" + "<br />"; -->
openBalls[htr][ht]="out";
window.alert( names[trn] + " loses next turn. Proceed to next player.");
}
else if (openBalls[htr][ht]=="dead")
<!-- manually put ball back to live -->
{
var r=window.confirm("Do you want to set the ball active again?");
if (r==true)
{
openBalls[htr][ht]="live";
document.getElementById("playbyplay").innerHTML += [timestamp] + ": " + names[ht] + " <img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[ht] + "live.png' alt='" + balls[ht] + "'> reset to live for <img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> "+ names[trn] + "<br \>";
document.getElementById("ball" + [ht]).src="images/" + balls[ht] + "live.png";
document.getElementById("ball" + [ht]).title= balls[ht] + " ball alive";
document.getElementById("ball" + [ht]).value= balls[ht] + " ball alive";
document.getElementById("ball" + [ht]).alt= balls[ht] + " ball alive";
var circlex = document.getElementById("circle" + [ht] );
// var titx = document.getElementById("title" + [ht]);
var titx = "title" + [ht];
document.getElementById([titx]).textContent = balls[ht] + " live";
// titx.textContent = balls[ht] + "hit live";
// 2017 where is circlestate used?
var circlestate = circlex.style.fill.value;
circlex.style.fill= balls[ht];
}
else
{
}
}
else
{
document.getElementById("playbyplay").innerHTML += [timestamp] + ": <img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[trn] + "live.png' alt='" + balls[trn] +"'> " +names[trn] + " hits " + names[ht] + " <img style='width:1em; height:1em; vertical-align: bottom;' src='images/" + balls[ht] + "live.png' alt='" + balls[ht] + "'><br \>";
<!-- document.getElementById("playbyplay").innerHTML += "hit" + "<br />"; -->
openBalls[htr][ht]="dead";
<!-- document.getElementById("ball" + [ht]).disabled=true; -->
document.getElementById("ball" + [ht]).src="images/" + balls[ht] + "dead.png";
document.getElementById("ball" + [ht]).style.color="white";
var circlex = document.getElementById("circle" + [ht] );
var titx = "title" + [ht];
document.getElementById([titx]).textContent = balls[ht] + " dead";
circlex.style.fill="white";
}
}
<!-- Show summary was an added in function. It can be cleaner in the final, since it will be a separate, visual page. -->
<!-- Need to make sure I handle the adjustments to the ALT text for all the ball and hoop values and states -->
function showStatus() {
if (names[1]==null)
{
window.alert("Let's get at least a couple of people playing before we worry about status!");
}
else
{
<!-- alter view -->
document.getElementById("shooting").style.display="none";
document.getElementById("newshooting").style.display="none";
document.getElementById("field").style.display="inline";
document.getElementById("playbyplay").style.display="inline";
document.body.style.backgroundImage="url('images/stake.png')";
<!-- alter main control -->
document.getElementById("summary").style.display="none";
document.getElementById("bounds").style.display="none";
document.getElementById("mainaction").src="images/" + balls[trn] + "live.png";
document.getElementById("mainaction").value="Show shooting, " +balls[trn] + " playing";
document.getElementById("mainaction").title="Show shooting, " +balls[trn] + " playing";
document.getElementById("mainaction").alt="Show shooting, " +balls[trn] + " playing";
document.getElementById("mainaction").onclick = showShooting;
<!-- document.getElementById("status").innerHTML = "<h2>Status:</h2>"; -->
document.getElementById("status0").innerHTML = ""
document.getElementById("status1").innerHTML = ""
document.getElementById("status2").innerHTML = ""
document.getElementById("status3").innerHTML = ""
document.getElementById("status4").innerHTML = ""
document.getElementById("status5").innerHTML = ""
for (var i = 0; i < names.length; i++) {
var liveballs = ". Live balls: ";
var IsLiveBall = false;
document.getElementById("status" + [i]).innerHTML += " <img src='images/" + balls[i] + "stake.png' alt='" + balls[i] +" player'> ";
document.getElementById("status" + [i]).innerHTML += " <img src='images/" + openBalls[i][7] + "hoop.png' height='36' alt='shooting for hoop " + openBalls[i][7] + "'> ";
for (var j = 0; j < names.length; j++) {
if (openBalls[i][j]=="live")
{
document.getElementById("status" + [i]).innerHTML += " <img src='images/" + balls[j] + "live.png' width='40' height='40' alt='" + balls[j] +" alive'> ";
if (IsLiveBall===false)
{
var liveballs = [liveballs] + balls[j];
}
else
{
var liveballs = [liveballs] + ", " + balls[j];
}
IsLiveBall = true;
}
else if (openBalls[i][j]=="owns")
{
}
else
{
document.getElementById("status" + [i]).innerHTML += " <img src='images/" + balls[j] + "dead.png' width='40' height='40' alt='" + balls[j] +" dead'> ";
}
}
if (IsLiveBall === true)
{
}
else
{
}
}
}
}
// 2017 Want to make this menu look way better and hopefully include some ball icons
function buildActionsMenu() {
document.getElementById("actionmenu").innerHTML="";
document.getElementById("actionmenu").innerHTML+="<ul><li><a href=# onclick='hitBall(trn,6);hideMenu()' />Shooter out of bounds</a></li>";
<!-- now populate the menu choices for this player -->
for (var j = 0; j < names.length; j++) {
if (openBalls[trn][j]!="owns") {
document.getElementById("actionmenu").innerHTML+="<ul><li><a href=# onclick='clearHoop(" + [j] + ",openBalls[trn][7]);hideMenu()' /> Shooter puts " + balls[j] + " through hoop</a></li>";
}
}
document.getElementById("actionmenu").innerHTML+="<ul><li><a href=# onclick='clearHoop(0,17);hideMenu()' />Shooter's last cleared hoop rescinded</a></li>";
document.getElementById("actionmenu").innerHTML+="<ul><li><a href=# onclick='hideMenu()' />Return to prior screen</a></li>";
}
</script>
<style>
body {
background-image: url(images/stake.png);
background-position: 475px 80px;
background-repeat: no-repeat;
background-attachment: fixed;
max-width: 320px;
margin: 0 auto;
}
.page {
max-width: 320px;
}
.menu {
width: 100%;
background-color: #white;
}
.menu ul{
margin: 0; padding: 0;
float: left;
}
.menu ul li{
display: block;
}
.menu ul li a{
float: left; text-decoration: none;
color: black;
padding: 10.5px 11px;
background-color: #white;
}
.menu ul li a:visited{
color: black;
}
.menu ul li a:hover, .menu ul li .current{
color: #black;
background-color:#white;
}
.menu {
font-size: 120%;
}
h1,h2 {
font-family: kailasa;
}
circle {
stroke-width: 8;
}
circle.circle0 {
stroke: blue;
fill: blue;
/* display: none;*/
}
circle.circle1 {
stroke: red;
fill: red;
}
circle.circle2 {
stroke: black;
fill: black;
}
circle.circle3 {
stroke: yellow;
fill: yellow;
}
circle.circle4 {
stroke: green;
fill: green;
}
circle.circle5 {
stroke: orange;
fill: orange;
}
text {
/* fill: none;*/
stroke: black;
stroke-width:.2px;
stroke-linejoin: round;
}
text.text0 {
/*display: none;*/
}
.flex-group {
margin: auto;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
min-width: 200px;
max-width: 400px;
flex-basis: auto; /* default value */
flex-grow: 1;
-webkit-flex-flow: row wrap;
justify-content: center;
/* justify-content: space-around;*/
}
.flex-item {
/*background: tomato;*/
padding: 10px;
width: 80px;
height: 80px;
/*margin-top: 10px;*/
line-height: 150px;
color: white;
/*text-align: center;*/
}
/*Start with no balls displayed*/
#pos0, #pos1, #pos2, #pos3, #pos4, #pos5
{
display: none;
}
#hoopsvg {
border-radius: 25px 25px 0px 0px;
border: 15px solid SaddleBrown;
border-bottom-style: none;
padding: 20px;
width: 10px;
height: 70px;
color: SaddleBrown;
font-size: 300%;
font-weight: 900;
text-indent: -5px;
text-align: center;
}
/* #pos4 {
padding-left: 55px;
}
#pos5 {
padding-right: 55px;
}*/
</style>
<!-- Forcing mobile devices to use my display properties -->
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Croquet Tracker</title>
</head>
<body onload="preGame()">
<div role="main">
<div id="setup">
<h1>Croquet Tracker</h1>
<form name="myForm">
<img class="band" src="images/bluestake.png" alt=""><label for="player1">Player 1: </label><input type="text" maxlength="10" placeholder="Player 1" name="Player 1" id="player1"><br>
<img class="band" src="images/redstake.png" alt=""><label for="player2">Player 2: </label><input type="text" maxlength="10" placeholder="Player 2" name="Player 2" id="player2"><br>
<img class="band" src="images/blackstake.png" alt=""><label for="player3">Player 3: </label><input type="text" maxlength="10" placeholder="Player 3" name="Player 3" id="player3"><br>
<img class="band" src="images/yellowstake.png" alt=""><label for="player4">Player 4: </label><input type="text" maxlength="10" placeholder="Player 4" name="Player 4" id="player4"><br>
<img class="band" src="images/greenstake.png" alt=""><label for="player5">Player 5: </label><input type="text" maxlength="10" placeholder="Player 5" name="Player 5" id="player5"><br>
<img class="band" src="images/orangestake.png" alt=""><label for="player6">Player 6: </label><input type="text" maxlength="10" placeholder="Player 6" name="Player 6" id="player6"><p>
<label for "hps">Hoops/pegs:</label>
<select name="hps" id="hps">
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16" Selected>16</option>
</select>
</form>
</div>
<div id="shooting">
<!-- I believe I can just lift the colour values out of the array, and form this whole thing that way; I'm not sure the balls are even used here... Isn't it now done in setupBalls? -->
<br>
<input type="image" src="images/bluelive.png" id="ball0" style="color:white" title="Blue Ball" alt="Blue ball" value="Blue ball" onclick="hitBall(trn,0);" />
<input type="image" src="images/redlive.png" id="ball1" style="color:white" title= "Red ball" alt="Red ball" value="Red ball" onclick="hitBall(trn,1);" />
<input type="image" src="images/blacklive.png" id="ball2" style="color:white" value="Black ball" onclick="hitBall(trn,2);" />
<!-- secondary location for the second line -->
<img src="shim.png" alt="" height="1" width="50" id="secondary" border="0">
<input type="image" src="images/yellowlive.png" id="ball3" style="color:white" value="Yellow ball" onclick="hitBall(trn,3);" />
<!-- prime location for the second line -->
<img src="shim.png" alt="" height="1" width="50" id="prime" border="0">
<input type="image" src="images/greenlive.png" id="ball4" style="color:white" value="Green ball" onclick="hitBall(trn,4);" />
<input type="image" src="images/orangelive.png" id="ball5" style="color:white" value="Orange ball" onclick="hitBall(trn,5);" />
<p />
</div>
<div id="newshooting" class="flex-group" role="region" aria-live="polite">
<div class="flex-container" id="current">
</div>
<div class="flex-container" align="center">
<a href="#" role="button" id="hoopsvg" title="hoop" onclick="clearHoop(trn,openBalls[trn][7]);"></a>
<!-- <input type="image" src="images/1hoop.png" id="nexthoop" value="Hoop 1" onclick="clearHoop(trn,openBalls[trn][7]);" /> -->
</div>
<div class="flex-container" >
<div id="pos0" class="flex-item" >
<svg aria-labelledby="title0">
<title id="title0">title0</title>
<circle role="button" id="circle0" class="flex-item circle0" cx="40" cy="40" r="34" aria-labelledby="title0" onclick="hitBall(trn,0);" />
<a xlink:href="#" onclick="hitBall(trn,0);" >
<text id="text0" class="text0" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="blue">Albus Dumbledore</text>
</a>
</svg>
</div>
<div id="pos1" class="flex-item">
<svg aria-labelledby="title1" role="img">
<circle role="button" id="circle1" class="flex-item circle1" cx="40" cy="40" r="34" onclick="hitBall(trn,1);" />
<title id="title1">title1</title>
<a xlink:href="#" onclick="hitBall(trn,1);" >
<text id="text1" class="text1" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="red">Albus Dumbledore</text>
</a>
</svg>
</div>
<div id="pos2" class="flex-item">
<svg aria-labelledby="title2" role="img">
<circle id="circle2" class="flex-item circle2" cx="40" cy="40" r="34" onclick="hitBall(trn,2);" />
<title id="title2">title2</title>
<a xlink:href="#" onclick="hitBall(trn,2);" >
<text id="text2" class="text2" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="black">Albus Dumbledore</text>
</a>
</svg>
</div>
<div id="pos3" class="flex-item">
<svg aria-labelledby="title3" role="img">
<circle role="button" id="circle3" class="flex-item circle3" cx="40" cy="40" r="34" onclick="hitBall(trn,3);" />
<title id="title3">title3</title>
<a xlink:href="#" onclick="hitBall(trn,3);" >
<text id="text3" class="text3" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="yellow">Albus Dumbledore</text>
</a>
</svg>
</div>
<div id="pos4" class="flex-item">
<svg aria-labelledby="title4" role="img">
<circle role="button" id="circle4" class="flex-item circle4" cx="40" cy="40" r="34" onclick="hitBall(trn,4);" />
<title id="title4">title4</title>
<a xlink:href="#" onclick="hitBall(trn,4);" >
<text id="text4" class="text4" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="green">Albus Dumbledore</text>
</a>
</svg>
</div>
<div id="pos5" class="flex-item">
<svg aria-labelledby="title5" role="img">
<circle role="button" id="circle5" class="flex-item circle5" cx="40" cy="40" r="34" onclick="hitBall(trn,5);" />
<title id="title5">title5</title>
<a xlink:href="#" onclick="hitBall(trn,5);" >
<text id="text5" class="text5" x="14%" y="60%" alignment-baseline="middle" text-anchor="middle" fill="orange">Albus Dumbledore</text>
</a>
</svg>
</div>
</div>
</div>
<p>
<div id="field">
<h2>Field</h2>
<p id="status"></p>
<p id="status0"></p>
<p id="status1"></p>
<p id="status2"></p>
<p id="status3"></p>
<p id="status4"></p>
<p id="status5"></p>
</div>
<div id="controls" align="center" role="navigation" aria-label="actions">
<table role="presentation">
<tr>
<td>
<input type="image" id="summary" src="images/stats.png" width="60" height="60" Value="Show field" TITLE="Show field" ALT="Show field" onclick="showStatus();" />
</td>
<td>
<input type="image" id="bounds" src="images/shim.png" width="60" height="60" TITLE="" ALT="" onclick="showMenu();" />
</td>
<td>
<input type="image" id="mainaction" src="images/bluelive.png" width="60" height="60" Value="Start play" TITLE="Start play" ALT="Start play" onclick="validateForm();" />
</td>
</tr>
</table>
</div>
<div id="actionmenu" class="menu">
</div>
</div>
<div role="complementary">
<br>
<p id="playbyplay"</p>
<!-- menu fiddling -->
</div>
</body>
</html>