-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgigstats.html
232 lines (190 loc) · 4.52 KB
/
gigstats.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
<!DOCTYPE html>
<html> <head>
<title>Gigstats</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
html {
background: url(background-2025.jpg) no-repeat center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
margin: 0;
padding: 0;
}
* { box-sizing: border-box; }
#content {
max-width: 40em;
margin: auto;
padding: 0;
padding-bottom: 60px; /* must be same height as the footer */
}
#content-inner {
padding: 1em;
background-color: white;
}
#title {
padding-top: 10px;
font-size: 46px;
font-family: sans-serif;
line-height: 56px;
height: 75px;
color: white;
background: #692C2C;
background-image: linear-gradient(to bottom right, #0000FF 0%, #692C2C 100%);
}
#question {
padding-top: 16px;
font-family: sans-serif;
}
html, body {height: 100%;}
#wrap {
min-height: 100%;
}
#footer {
position: relative;
margin-top: -60px; /* negative value of footer height */
padding: 0px;
height: 60px; /* footer height */
padding-top: 4px;
clear:both;
background-color: black;
font-size: 45px;
font-family: sans-serif;
}
#about:link {text-decoration: none; color: #CCC}
#about:visited {text-decoration: none; color: #CCC}
#about:active {text-decoration: none; color: #CCC}
#about:hover {text-decoration: underline; color: #CCC}
table {
width: 100%;
}
button {
margin: 0.1em;
padding: 0.1em;
font-size: 150%;
background-color: #eee;
border-radius: 0.2em;
}
button:active, .active {
top: 2px;
left: 1px;
box-shadow: none;
position: relative;
background-color: #ccc;
}
</style>
<body>
<div id="wrap">
<div id="content">
<div id="title">
<center>Gigstats</center>
</div>
<div id="content-inner">
<div id="question">
</div>
<h2>Bands</h2>
<table id="bandlistings" border=1 cellpadding=5>
</table>
<h2>Callers</h2>
<table id="callerlistings" border=1 cellpadding=5>
</table>
</div>
</div>
</div>
<a id=about href="about.html"><div id="footer"><center>about</center></div></a>
</body>
<script>
function e(tag, text="") {
const el = document.createElement(tag);
if (text) {
el.innerText = text;
}
return el;
}
function make_table(listings, performer_counts) {
while (listings.firstChild) {
listings.removeChild(listings.firstChild);
}
const performer_counts_list = [];
for (const performer in performer_counts) {
performer_counts_list.push([performer, performer_counts[performer]]);
}
performer_counts_list.sort(function([p1, c1], [p2, c2]) {
if (c1 > c2) {
return -1;
} else if (c2 > c1) {
return 1;
}
//p1 = p1.replace(/^the /, "");
//p2 = p2.replace(/^the /, "");
if (p1 > p2) {
return 1;
} else if (p2 > p1) {
return -1;
}
return 0;
});
for (const [performer, count] of performer_counts_list) {
if (count < 2) continue;
const tr = e("tr");
tr.appendChild(e(
"td",
performer.charAt(0).toUpperCase() + performer.slice(1)));
tr.appendChild(e("td", count));
listings.appendChild(tr);
}
}
async function fetch_dances() {
const response = await fetch("events.json");
const events = await response.json();
// year -> {"bands" -> band counts,
// "callers" -> caller counts}
const data = {};
const years = [];
for (const event of events) {
if (!(event.year in data)) {
data[event.year] = {
"bands": {},
"callers": {},
}
years.push(event.year);
}
for (const band of event.bands) {
data[event.year].bands[band] =
(data[event.year].bands[band] || 0) + 1;
}
for (const caller of event.callers) {
data[event.year].callers[caller] =
(data[event.year].callers[caller] || 0) + 1;
}
}
years.sort();
years.pop();
for (const year of years) {
const year_button = e("button", year);
question.appendChild(year_button);
}
for (const button of document.querySelectorAll('button')) {
button.onclick = function() {
for (const other_button of document.querySelectorAll('button')) {
other_button.classList.remove('active');
}
button.classList.add('active');
const year_data = data[button.innerText];
make_table(bandlistings, year_data.bands);
make_table(callerlistings, year_data.callers);
};
}
for (const button of document.querySelectorAll('button')) {
if (button.innerText == years[years.length - 1]) {
button.onclick.apply(button);
}
}
}
fetch_dances();
</script>
</html>