-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
152 lines (146 loc) · 5.31 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Scoreboard Demo</title>
<meta name="description" content="The HTML5 Herald" />
<meta name="author" content="SitePoint" />
<style>
#test {
margin-bottom: 20px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
}
#radioControls {
display: flex;
align-items: center;
}
#radioControls label {
margin-right: 18px;
}
#radioControls input {
margin: 0 6px 0 0;
}
</style>
</head>
<body>
<div id="root">
<div id="test"></div>
<div id="controls">
<div><button id="previous" disabled>Previous</button> <button id="next">Next</button></div>
<div id="radioControls">
<input type="radio" name="variant" id="baseballVariant" />
<label for="baseballVariant">Baseball-style</label>
<input type="radio" name="variant" id="clubVariant" checked /> <label for="clubVariant">Club-style</label>
<input type="radio" name="variant" id="simpleVariant" /> <label for="simpleVariant">Simple</label>
</div>
</div>
</div>
<script src="dist/scoreboard.js"></script>
<script>
const {render, gameStateReducer} = scoreboard;
const testRoot = document.getElementById("test");
const previous = document.getElementById("previous");
const next = document.getElementById("next");
const baseballVariant = document.getElementById("baseballVariant");
const clubVariant = document.getElementById("clubVariant");
const simpleVariant = document.getElementById("simpleVariant");
const team1 = {
name: "Henderson",
};
const team2 = {
name: "Bailey",
};
const scores = [
{ // 1
team: 0,
points: 0,
},
{ // 2
team: 1,
points: 2,
},
{ // 3
team: 0,
points: 3,
},
{ // 4
team: 1,
points: 3,
},
{ // 5
team: 0,
points: 2,
},
{ // 6
team: 0,
points: 6,
},
{ // 7
team: 0,
points: 0,
},
{ // 8
team: 0,
points: 0,
},
{ // 9
team: 0,
points: 1,
},
{ // 10
team: 0,
points: 2,
},
{ // 11
team: 1,
points: 1,
},
];
const initialState = {
LSFE: 1,
ends: [],
complete: false,
};
let currentState = initialState;
let endIndex = 0;
const scoreboardOptions = {
team1,
team2,
variant: "club",
sheetName: "B",
additionalCssRules: [`:is(.scoreboard-end-cell,.scoreboard-end-label-cell):nth-child(odd) {background-color: #ddd !important;}`],
style: {
//team2Color: "rgb(114, 186, 255)",
},
showTenEnds: true
};
render(testRoot, initialState, scoreboardOptions);
previous.addEventListener("click", () => {
currentState = gameStateReducer(currentState, { type: "noop" });
currentState.ends.pop();
--endIndex;
render(testRoot, currentState, scoreboardOptions);
next.disabled = endIndex === scores.length;
previous.disabled = endIndex === 0;
});
next.addEventListener("click", () => {
const payload = scores[endIndex++];
currentState = gameStateReducer(currentState, { type: "score", payload });
render(testRoot, currentState, scoreboardOptions);
next.disabled = endIndex === scores.length;
previous.disabled = endIndex === 0;
});
function variantChange() {
const variant = baseballVariant.checked ? "baseball" : clubVariant.checked ? "club" : "simple";
scoreboardOptions.variant = variant;
render(testRoot, currentState, scoreboardOptions);
}
baseballVariant.addEventListener("change", variantChange);
clubVariant.addEventListener("change", variantChange);
simpleVariant.addEventListener("change", variantChange);
</script>
</body>
</html>