-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsoccer.html
More file actions
710 lines (615 loc) · 29 KB
/
Copy pathsoccer.html
File metadata and controls
710 lines (615 loc) · 29 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>STEMcoding Bracket Builder</title>
<script src="qrcode.min.js"></script>
<link href="./img/stemcoding_favicon_final.png" rel="icon" type="image/png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap"
rel="stylesheet">
<style>
:root {
--bg: #f8f9fa;
--surface: #ffffff;
--gold-color: #b8860b;
--gold-light: #d4af37;
--green-accent: #1a5c38;
--green-light: #e8f5ee;
--text-dark: #1a1a2e;
--text-muted: #5a6472;
--border: #dde2ea;
--border-hover: #1a5c38;
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.07);
--shadow-md: 0 4px 18px rgba(0, 0, 0, 0.10);
--transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background: #f8f9fa;
margin: 0;
padding: 30px 20px;
color: #1a1a2e;
min-height: 100vh;
}
h1 {
font-family: 'Outfit', sans-serif;
text-align: center;
font-size: 42px;
font-weight: 800;
background: gray;
color: black;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 5px;
letter-spacing: 1.5px;
text-transform: uppercase;
}
.instructions {
text-align: center;
margin-bottom: 40px;
font-size: 16px;
color: #5a6472;
line-height: 1.6;
}
.instructions input[type="text"] {
padding: 8px 12px;
border: 1px solid #dde2ea;
border-radius: 6px;
font-family: monospace;
font-size: 14px;
width: 300px;
background: #ffffff;
color: #1a1a2e;
outline: none;
}
.instructions button {
padding: 8px 18px;
background: rgb(188, 31, 67);
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
font-size: 14px;
}
.instructions button:hover {
background: rgb(150, 24, 53);
}
.bracket-wrapper {
display: flex;
overflow-x: auto;
padding-bottom: 40px;
justify-content: center;
}
.bracket {
display: flex;
flex-direction: row;
align-items: center;
}
.half {
display: flex;
flex-direction: row;
}
.round {
display: flex;
flex-direction: column;
justify-content: space-around;
width: 200px;
margin: 0 10px;
}
.match {
background: #ffffff;
border: 1px solid #dde2ea;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
overflow: hidden;
margin: 15px 0;
transition: all 0.25s ease;
}
.match:hover {
border-color: #1a5c38;
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.10);
transform: translateY(-1px);
}
.team {
padding: 10px 12px;
cursor: pointer;
font-size: 13px;
font-weight: 500;
border-bottom: 1px solid #dde2ea;
transition: all 0.25s ease;
user-select: none;
min-height: 20px;
display: flex;
align-items: center;
color: #1a1a2e;
}
.team:last-child {
border-bottom: none;
}
.team:hover {
background-color: #e8f5ee;
color: #1a5c38;
}
.team.empty {
color: #bcc4ce;
font-style: italic;
cursor: default;
}
.team.empty:hover {
background-color: transparent;
color: #bcc4ce;
}
/* Specific round styling */
.center-column {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 270px;
margin: 0 20px;
background: #ffffff;
border: 2px solid #1a5c38;
border-radius: 12px;
padding: 25px 10px;
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.10);
}
.center-column h2 {
font-family: 'Outfit', sans-serif;
font-size: 13px;
color: gray;
margin-bottom: 15px;
text-transform: uppercase;
letter-spacing: 1.2px;
text-align: center;
font-weight: 700;
}
.champ-match {
width: 90%;
margin-bottom: 25px;
}
.winner-box {
background: linear-gradient(135deg, #fce97a 0%, #d4af37 100%);
border: 2px solid #b8860b;
color: #3d2b00;
padding: 14px;
text-align: center;
font-weight: 800;
font-size: 15px;
font-family: 'Outfit', sans-serif;
border-radius: 8px;
width: 180px;
min-height: 24px;
box-shadow: 0 6px 20px rgba(184, 134, 11, 0.2);
text-transform: uppercase;
letter-spacing: 0.5px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.25s ease;
}
.privacy-link {
// position: absolute;
text-align: center;
// top: 10px;
// left: 15px;
font-size: 17px;
color: #5a6472;
cursor: help;
transition: all 0.25s ease;
}
.privacy-link:hover {
color: #1a5c38;
}
@media print {
@page {
size: landscape;
margin: 0.5cm;
}
body {
background: white !important;
color: black !important;
zoom: 0.75;
-moz-transform: scale(0.75);
-moz-transform-origin: top center;
padding: 0;
}
.bracket-wrapper {
overflow: visible !important;
}
button,
input {
display: none !important;
}
.center-column {
background: white !important;
border: 1px solid #ccc !important;
}
.match {
background: white !important;
border: 1px solid #aaa !important;
box-shadow: none !important;
}
.team {
color: black !important;
border-bottom: 1px solid #eee !important;
}
.team:hover {
background: none !important;
color: black !important;
}
.winner-box {
background: #ffd700 !important;
color: black !important;
border: 1px solid #daa520 !important;
box-shadow: none !important;
}
#code-display {
background: white !important;
border: 1px solid #ccc !important;
color: black !important;
}
#code-display p,
#code-display span,
#code-display strong {
color: black !important;
}
}
</style>
</head>
<body>
<div class="privacy-link"
title="No student data is collected by this site! No cookies are stored! No IP addresses are accessed or saved! There are no trackers of how many visitors are accessing this site! No database of any kind is storing information of any kind regarding this site. Feel free to ask an AI chatbot to analyze the source code of this page to verify. Enjoy your privacy!"
onclick="alert(this.title)">Privacy Information</div>
<a href="http://go.osu.edu/stemcoding" target="_blank">
<img src="img/stemcoding_data_science_icon_2026.png" alt="STEMcoding Data Science"
style="position: absolute; top: 15px; left: 15px; height: 200px; width: auto; object-fit: contain;"></a>
<a href="http://osumarion.osu.edu" target="_blank">
<img src="img/OSU_Marion_logo.png" alt="Ohio State University at Marion"
style="position: absolute; top: 15px; right: 15px; height: 200px; width: auto; object-fit: contain;"></a>
<h1>STEMcoding Bracket Builder</h1>
<div class="instructions">
Click on a team to advance them to the next round
<div style="margin-top: 20px; display: flex; justify-content: center; gap: 10px; align-items: center;">
<input type="text" id="restore-code" placeholder="Paste Binary, Hex, or Base 10 Code">
<button onclick="restoreFromCode()">Load Bracket</button>
</div>
<br>
Disclaimer: This site is for educational use only! This site is not affiliated with, endorsed by, or associated
with FIFA or any official soccer federation
</div>
<div class="bracket-wrapper">
<div class="bracket" id="bracket-container">
</div>
</div>
<script>
const leftHalfMatches = [
["🇩🇪 Germany", "🇵🇾 Paraguay"],
["🇫🇷 France", "🇸🇪 Sweden"],
["🇿🇦 S. Africa", "🇨🇦 Canada"],
["🇳🇱 Netherlands", "🇲🇦 Morocco"],
["🇵🇹 Portugal", "🇭🇷 Croatia"],
["🇪🇸 Spain", "🇦🇹 Austria"],
["🇺🇸 USA", "🇧🇦 Bosnia"],
["🇧🇪 Belgium", "🇸🇳 Senegal"]
];
const rightHalfMatches = [
["🇧🇷 Brazil", "🇯🇵 Japan"],
["🇨🇮 Côte d'Ivoire", "🇳🇴 Norway"],
["🇲🇽 Mexico", "🇪🇨 Ecuador"],
["🏴 England", "🇨🇩 DR Congo"],
["🇦🇷 Argentina", "🇨🇻 Cape Verde"],
["🇦🇺 Australia", "🇪🇬 Egypt"],
["🇨🇭 Switzerland", "🇩🇿 Algeria"],
["🇨🇴 Colombia", "🇬🇭 Ghana"]
];
const rounds = 4; // Rounds per half (R32, R16, QF, SF)
window.matchChoices = new Array(32).fill(null);
function updateCode() {
let complete = true;
let missing = [];
for (let i = 0; i < 32; i++) {
if (window.matchChoices[i] === null) {
complete = false;
missing.push(i);
}
}
console.log("Checking if bracket is complete...");
console.log("Complete status:", complete);
console.log("Current choices Array:", window.matchChoices);
if (!complete) {
console.log("Missing choices for the following match indices:", missing);
return;
}
let binStr = "";
for (let i = 0; i < 32; i++) {
binStr += (window.matchChoices[i] === null ? "0" : window.matchChoices[i]);
}
let hexStr = "";
for (let i = 0; i < 32; i += 4) {
hexStr += parseInt(binStr.substring(i, i + 4), 2).toString(16).toUpperCase();
}
let base10Str = BigInt("0b" + binStr).toString(10);
console.log("Bracket is complete! Generated Code:");
console.log("Binary:", binStr);
console.log("Hex:", hexStr);
console.log("Base 10:", base10Str);
let displayEl = document.getElementById("code-display");
if (!displayEl) {
displayEl = document.createElement("div");
displayEl.id = "code-display";
displayEl.style.textAlign = "center";
displayEl.style.marginBottom = "30px";
displayEl.style.padding = "24px";
displayEl.style.background = "#ffffff";
displayEl.style.border = "1px solid #dde2ea";
displayEl.style.borderRadius = "10px";
displayEl.style.boxShadow = "0 4px 18px rgba(0,0,0,0.08)";
document.querySelector(".instructions").after(displayEl);
}
let dateTimeStr = "";
if (window.loadedDateStr) {
dateTimeStr = window.loadedDateStr;
} else {
let now = new Date();
dateTimeStr = now.toLocaleString();
}
let hexDate = Array.from(dateTimeStr).map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('');
let shareUrl = `${window.location.origin}${window.location.pathname}?code=${base10Str}&date=${hexDate}`;
displayEl.style.position = "relative";
displayEl.innerHTML = `
<div style="position: absolute; left: 20px; top: 20px; display: flex; flex-direction: column; align-items: center; gap: 5px;">
<div id="qrcode-container" style="width: 156px; height: 156px; border: 1px solid #dde2ea; border-radius: 6px; padding: 6px; background: white; box-sizing: border-box; display: flex; justify-content: center; align-items: center;"></div>
<span style="font-size: 11px; font-weight: bold; color: #1a5c38; letter-spacing: 0.5px;">QR to Share URL</span>
</div>
<div style="position: relative; margin-bottom: 20px;">
<h3 style="color: #1a5c38; margin: 0; text-align: center; padding-top: 10px; font-size: 20px; font-family: 'Outfit', sans-serif; text-transform: uppercase; letter-spacing: 1px;">Your Bracket Code</h3>
<button onclick="window.print()" style="position: absolute; right: 0; top: 10px; padding: 8px 18px; background: #1a5c38; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-family: 'Outfit', sans-serif;">Print Bracket</button>
</div>
<div style="margin: 15px auto; padding: 15px; border: 1px dashed #bcc4ce; border-radius: 6px; width: fit-content; min-width: 50%; display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; font-size: 15px; gap: 40px; color: #1a1a2e;">
<div><strong>Name:</strong> ___________________________________</div>
<div><strong>Date / Time:</strong> ${dateTimeStr}</div>
</div>
<div style="margin-left: 170px; display: flex; flex-direction: column; gap: 10px;">
<p style="margin: 0; display: flex; align-items: center; justify-content: flex-start; gap: 10px; color: #1a1a2e;">
<strong style="width: 100px; text-align: right;">Binary:</strong> <span style="word-break: break-all; font-family: monospace; color: #1a5c38;">${binStr}</span>
<button onclick="navigator.clipboard.writeText('${binStr}'); let btn=this; btn.innerText='Copied!'; setTimeout(()=>btn.innerText='Copy', 2000);" style="cursor: pointer; padding: 4px 10px; border: 1px solid #dde2ea; border-radius: 4px; background: #f1f4f8; color: #1a1a2e; font-size: 11px;">Copy</button>
</p>
<p style="margin: 0; display: flex; align-items: center; justify-content: flex-start; gap: 10px; color: #1a1a2e;">
<strong style="width: 100px; text-align: right;">Base 10:</strong> <span style="word-break: break-all; font-family: monospace; color: #b8860b;">${base10Str}</span>
<button onclick="navigator.clipboard.writeText('${base10Str}'); let btn=this; btn.innerText='Copied!'; setTimeout(()=>btn.innerText='Copy', 2000);" style="cursor: pointer; padding: 4px 10px; border: 1px solid #dde2ea; border-radius: 4px; background: #f1f4f8; color: #1a1a2e; font-size: 11px;">Copy</button>
</p>
<p style="margin: 0; display: flex; align-items: center; justify-content: flex-start; gap: 10px; color: #1a1a2e;">
<strong style="width: 100px; text-align: right;">Hexadecimal:</strong> <span style="word-break: break-all; font-family: monospace; color: #1a4a7c;">${hexStr}</span>
<button onclick="navigator.clipboard.writeText('${hexStr}'); let btn=this; btn.innerText='Copied!'; setTimeout(()=>btn.innerText='Copy', 2000);" style="cursor: pointer; padding: 4px 10px; border: 1px solid #dde2ea; border-radius: 4px; background: #f1f4f8; color: #1a1a2e; font-size: 11px;">Copy</button>
</p>
<p style="margin: 0; display: flex; align-items: center; justify-content: flex-start; gap: 10px; color: #1a1a2e;">
<strong style="width: 100px; text-align: right;">Share URL:</strong> <a href="${shareUrl}" target="_blank" style="word-break: break-all; font-size: 13.5px; max-width: 60%; color: #1a4a7c; text-decoration: none; border-bottom: 1px dashed #85c1e9;">${shareUrl}</a>
<button onclick="navigator.clipboard.writeText('${shareUrl}'); let btn=this; btn.innerText='Copied!'; setTimeout(()=>btn.innerText='Copy URL', 2000);" style="cursor: pointer; padding: 4px 10px; border: 1px solid #dde2ea; border-radius: 4px; background: #f1f4f8; color: #1a1a2e; font-size: 11px;">Copy URL</button>
</p>
</div>
`;
if (typeof QRCode !== 'undefined') {
document.getElementById("qrcode-container").innerHTML = "";
new QRCode(document.getElementById("qrcode-container"), {
text: shareUrl,
width: 144,
height: 144,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.L
});
} else {
document.getElementById("qrcode-container").innerText = "QR library failed to load.";
}
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function buildHalf(side, matchesData) {
let html = `<div class="half" id="${side}-half">`;
let roundOrder = side === 'left' ? [0, 1, 2, 3] : [3, 2, 1, 0];
roundOrder.forEach(roundIndex => {
let numMatches = 8 / Math.pow(2, roundIndex);
html += `<div class="round round-${roundIndex}" id="${side}-round-${roundIndex}">`;
for (let i = 0; i < numMatches; i++) {
let team1 = "TBD";
let team2 = "TBD";
let classes = "team empty";
if (roundIndex === 0) {
team1 = matchesData[i][0];
team2 = matchesData[i][1];
classes = "team";
}
let nextRound = roundIndex + 1;
let nextMatch = Math.floor(i / 2);
let slot = i % 2 === 0 ? 0 : 1;
html += `
<div class="match">
<div class="${classes}" onclick="advance('${side}', ${roundIndex}, ${i}, 0, '${team1.replace(/'/g, "\\'")}', ${nextRound}, ${nextMatch}, ${slot})" id="${side}-r${roundIndex}-m${i}-t0">${team1}</div>
<div class="${classes}" onclick="advance('${side}', ${roundIndex}, ${i}, 1, '${team2.replace(/'/g, "\\'")}', ${nextRound}, ${nextMatch}, ${slot})" id="${side}-r${roundIndex}-m${i}-t1">${team2}</div>
</div>
`;
}
html += `</div>`;
});
html += `</div>`;
return html;
}
function buildCenter() {
return `
<div class="center-column">
<h2>Final Game</h2>
<div class="round" style="width: 100%; align-items: center; justify-content: center;">
<div class="match champ-match">
<div class="team empty" onclick="advanceToWinner('left')" id="final-left">Left Semifinalist</div>
<div class="team empty" onclick="advanceToWinner('right')" id="final-right">Right Semifinalist</div>
</div>
<h2 style="margin-top: 15px; color: var(--gold-color);">Champion</h2>
<div class="winner-box" id="champion" style="margin-bottom: 25px;">TBD</div>
<h2 style="color: var(--gold-color);">Bronze Match</h2>
<div class="match champ-match">
<div class="team empty" onclick="advanceToThirdPlace('left')" id="bronze-left">Left SF Loser</div>
<div class="team empty" onclick="advanceToThirdPlace('right')" id="bronze-right">Right SF Loser</div>
</div>
<h2 style="margin-top: 15px; color: var(--gold-color);">Third Place</h2>
<div class="winner-box" id="third-place" style="background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%); border: 1px solid #dcb590; box-shadow: 0 8px 25px rgba(184, 115, 51, 0.25);">TBD</div>
</div>
</div>
`;
}
let resizeListenerAdded = false;
function renderBracket() {
const container = document.getElementById('bracket-container');
container.innerHTML = buildHalf('left', leftHalfMatches) + buildCenter() + buildHalf('right', rightHalfMatches);
const scaleBracket = () => {
const scale = Math.min(1, (window.innerWidth - 40) / 2100);
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
container.style.transform = `scale(${scale})`;
container.style.transformOrigin = 'top center';
} else {
container.style.zoom = scale;
}
};
scaleBracket();
if (!resizeListenerAdded) {
window.addEventListener('resize', scaleBracket);
resizeListenerAdded = true;
}
}
function advance(side, currentRound, currentMatch, currentSlot, teamName, nextRound, nextMatch, nextSlot) {
if (!window.isRestoring) window.loadedDateStr = null;
let currentEl = document.getElementById(`${side}-r${currentRound}-m${currentMatch}-t${currentSlot}`);
let actualTeamName = currentEl.innerText;
if (actualTeamName === "TBD") return;
let sideOffset = side === 'left' ? 0 : 15;
let roundOffsets = [0, 8, 12, 14];
if (currentRound < 3) {
let mIndex = sideOffset + roundOffsets[currentRound] + currentMatch;
window.matchChoices[mIndex] = currentSlot;
} else if (currentRound === 3) {
let ffIndex = side === 'left' ? 14 : 29;
window.matchChoices[ffIndex] = currentSlot;
}
if (nextRound === 4) {
let finalEl = document.getElementById(`final-${side}`);
finalEl.innerText = actualTeamName;
finalEl.classList.remove('empty');
let loserSlot = 1 - currentSlot;
let loserEl = document.getElementById(`${side}-r3-m0-t${loserSlot}`);
let loserTeamName = loserEl ? loserEl.innerText : "TBD";
let bronzeEl = document.getElementById(`bronze-${side}`);
if (bronzeEl) {
bronzeEl.innerText = loserTeamName;
bronzeEl.classList.remove('empty');
}
updateCode();
return;
}
let targetId = `${side}-r${nextRound}-m${nextMatch}-t${nextSlot}`;
let targetEl = document.getElementById(targetId);
if (targetEl) {
targetEl.innerText = actualTeamName;
targetEl.classList.remove('empty');
}
updateCode();
}
function advanceToWinner(side) {
let finalEl = document.getElementById(`final-${side}`);
let actualTeamName = finalEl.innerText;
if (actualTeamName === "Left Semifinalist" || actualTeamName === "Right Semifinalist" || actualTeamName === "TBD") {
return;
}
let champEl = document.getElementById('champion');
champEl.innerText = actualTeamName;
window.matchChoices[30] = side === 'left' ? 0 : 1;
updateCode();
}
function advanceToThirdPlace(side) {
let bronzeEl = document.getElementById(`bronze-${side}`);
let actualTeamName = bronzeEl.innerText;
if (actualTeamName === "Left SF Loser" || actualTeamName === "Right SF Loser" || actualTeamName === "TBD") {
return;
}
let thirdEl = document.getElementById('third-place');
thirdEl.innerText = actualTeamName;
window.matchChoices[31] = side === 'left' ? 0 : 1;
updateCode();
}
function restoreFromCode() {
window.isRestoring = true;
let input = document.getElementById('restore-code').value.trim();
if (!input) {
window.isRestoring = false;
return;
}
let binStr = "";
if (/^[01]{32}$/.test(input)) {
binStr = input;
} else if (/^[0-9A-Fa-f]{8}$/.test(input)) {
for (let i = 0; i < input.length; i++) {
binStr += parseInt(input[i], 16).toString(2).padStart(4, '0');
}
} else if (/^\d+$/.test(input)) {
try {
binStr = BigInt(input).toString(2).padStart(32, '0');
if (binStr.length > 32) throw new Error("Number too large");
} catch (e) {
alert("Invalid Base 10 Code.");
window.isRestoring = false;
return;
}
} else {
alert("Invalid code format. Please provide a valid 32-bit binary string, 8-character hex string, or Base 10 integer.");
window.isRestoring = false;
return;
}
window.matchChoices = new Array(32).fill(null);
renderBracket();
let choices = binStr.split('').map(Number);
let roundOffsets = [0, 8, 12, 14];
let matchesPerSide = [8, 4, 2, 1];
for (let roundIndex = 0; roundIndex <= 3; roundIndex++) {
for (let i = 0; i < matchesPerSide[roundIndex]; i++) {
let mIndex = roundIndex === 3 ? 14 : (0 + roundOffsets[roundIndex] + i);
let teamEl = document.getElementById(`left-r${roundIndex}-m${i}-t${choices[mIndex]}`);
if (teamEl && teamEl.innerText !== "TBD") teamEl.click();
}
for (let i = 0; i < matchesPerSide[roundIndex]; i++) {
let mIndex = roundIndex === 3 ? 29 : (15 + roundOffsets[roundIndex] + i);
let teamEl = document.getElementById(`right-r${roundIndex}-m${i}-t${choices[mIndex]}`);
if (teamEl && teamEl.innerText !== "TBD") teamEl.click();
}
}
if (choices[30] === 0 || choices[30] === 1) {
let finalEl = document.getElementById(`final-${choices[30] === 0 ? 'left' : 'right'}`);
if (finalEl) finalEl.click();
}
if (choices[31] === 0 || choices[31] === 1) {
let bronzeEl = document.getElementById(`bronze-${choices[31] === 0 ? 'left' : 'right'}`);
if (bronzeEl) bronzeEl.click();
}
window.isRestoring = false;
}
// Initialize the bracket
renderBracket();
window.addEventListener('DOMContentLoaded', () => {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('code')) {
document.getElementById('restore-code').value = urlParams.get('code');
if (urlParams.has('date')) {
let hexDate = urlParams.get('date');
let str = "";
for (let i = 0; i < hexDate.length; i += 2) {
str += String.fromCharCode(parseInt(hexDate.substr(i, 2), 16));
}
window.loadedDateStr = str;
}
restoreFromCode();
}
});
</script>
</body>
</html>