-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
339 lines (295 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaderboard</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.15/dist/tailwind.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Poppins', sans-serif;
background: #56CCF2;
/* fallback for old browsers */
background: -webkit-linear-gradient(to right, #2F80ED, #56CCF2);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #2F80ED, #56CCF2);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.terminal-window {
background-color: #0c0c0c;
border-radius: 10px;
padding: 20px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
position: relative;
background-color: rgba(0, 0, 0, 0.7);
color: #fff;
font-family: 'Fira Code', monospace;
font-size: 18px;
line-height: 1.4;
padding: 20px;
display: flex;
}
.title-bar {
display: flex;
align-items: center;
justify-content: flex-start;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 40px;
padding: 0 10px;
background-color: #333;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.close-button,
.maximize-button,
.minimize-button {
width: 12px;
height: 12px;
margin-right: 10px;
border-radius: 50%;
}
.close-button {
background-color: #ff5f57;
}
.minimize-button {
background-color: #ffbd2e;
}
.maximize-button {
background-color: #00ff00;
}
.close-button:before,
.minimize-button:before {
content: '';
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
}
.content {
margin-top: 40px;
}
.prompt {
color: #00ff00;
margin-right: 5px;
margin-top: 5px;
}
.blink-caret {
animation: blink 1s infinite;
}
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.tables-container {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
column-gap: 50px;
}
.table {
width: 100%;
}
.table th {
padding: 10px;
font-weight: bold;
color: #fff;
text-align: start;
border-bottom: 1px solid #fff;
}
.table td {
padding: 10px;
border-bottom: 1px solid #fff;
}
.lambda {
color: #ff5f57;
}
.flash {
animation: flash 1s;
}
@keyframes flash {
0% {
background-color: magenta;
}
100% {
background-color: white;
}
}
</style>
</head>
<body class="h-screen flex flex-col" x-data="data" x-init="init">
<div id="terminals" class="flex-1 flex justify-center">
<!-- Column 1 -->
<div class="mt-8 flex">
<div></div>
<div class="terminal-window ml-5 mb-5" style="min-width: 500px;">
<div class="title-bar flex">
<div class="close-button"></div>
<div class="minimize-button"></div>
<div class="maximize-button"></div>
<div class="text-center flex-grow">Rules</div>
</div>
<div class="content">
<div class="command prompt mb-3"><span class="lambda">λ</span> cat rules.txt</div>
<div class="items-center mb-3 justify-center">
<img class="mb-2" src="assets/rwanga-white.png" style="max-height: 100px; max-width: 70%" />
<p class="pl-3">In collaboration with</p>
<img class="mb-2" src="assets/hesta-white.png" style="max-height: 100px; max-width: 70%" />
<p class="pl-3 mb-2">Sponsored By</p>
<img src="assets/revge-white.png" style="max-height: 100px; max-width: 50%" />
</div>
<ul class="list-disc pl-6">
<li>You have one hour.</li>
<li>Solve as many problems as you can.</li>
<li>No ChatGPT, Copilot, etc.</li>
<li>No Google or other search engines.</li>
<li>Have fun.</li>
</ul>
</div>
</div>
</div>
<!-- Column 2 -->
<div class="p-5 flex">
<div class="flex flex-1 mt-3">
<div class="terminal-window flex-grow">
<div class="title-bar flex">
<div class="close-button"></div>
<div class="minimize-button"></div>
<div class="maximize-button"></div>
<div class="text-center flex-grow">Rwanga Coding Competition</div>
</div>
<div class="content">
<div class="command prompt mb-1 mt-0"><span class="lambda">λ</span> python ~/scripts/leaderboard.py
</div>
<div class="tables-container">
<table class="table">
<thead>
<tr>
<th>#</th>
<th style="min-width: 200px;">Name</th>
<th style="min-width: 100px;">Time</th>
<th style="min-width: 100px;">Score</th>
</tr>
</thead>
<tbody>
<template x-for="person in people1">
<tr>
<td :class="{ 'flash': person.flash }" :style="`color: ${person.color}`" x-text="person.place"></td>
<td :style="`color: ${person.color}`" x-text="person.name"></td>
<td :style="`color: ${person.color}`" x-text="person.time"></td>
<td :style="`color: ${person.color}`" x-text="person.score"></td>
</tr>
</template>
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th>#</th>
<th style="min-width: 200px;">Name</th>
<th style="min-width: 100px;">Time</th>
<th style="min-width: 100px;">Score</th>
</tr>
</thead>
<tbody>
<template x-for="person in people2">
<tr>
<td :class="{ 'flash': person.flash }" x-text="person.place"></td>
<td x-text="person.name"></td>
<td x-text="person.time"></td>
<td x-text="person.score"></td>
</tr>
</template>
</tbody>
</table>
<div class="command mt-5"><span class="lambda">λ </span><span class="blink-caret">█</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Fixed Height Row -->
<div class="bg-white items-center flex justify-center">
<img src="assets/footer.png" style="max-height: 100px;" />
</div>
<script src="https://unpkg.com/alpinejs@3.12.2/dist/cdn.min.js" defer></script>
<script defer>
function data() {
return {
people1: [],
people2: [],
async init() {
await this.reload();
this.setupReloadTimer();
},
async reload() {
const count = 14;
const half = count / 2;
const people = await fetchLeaderboard(count);
const old1 = [...this.people1];
const old2 = [...this.people2];
this.people1 = people.slice(0, half);
this.people2 = people.slice(half);
for (i = 0; i < this.people1.length && i < old1.length; i++) {
if (old1[i].name != this.people1[i].name ||
old1[i].score != this.people1[i].score) {
this.people1[i].flash = true;
setTimeout(() => this.people1[i].flash = false, 1000);
}
}
for (i = 0; i < this.people2.length && i < old2.length; i++) {
if (old2[i].name != this.people2[i].name ||
old2[i].score != this.people2[i].score) {
this.people2[i].flash = true;
setTimeout(() => this.people2[i].flash = false, 1000);
}
}
},
setupReloadTimer() {
const seconds = 5;
this.reloadInterval = setInterval(async () => {
await this.reload();
}, seconds * 1000);
}
};
};
async function fetchLeaderboard(count) {
const spreadsheetId = "1SXWYYsveuIpmkZB9hya-SYnKHEeR7_fvHg61GqB7k2c";
const range = `Leaderboard!A2:D${count + 1}`;
const api_key = "AIzaSyD7GsvzhPMHQcLr1zs1x1M-19pjaGPlvuI";
const url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${range}?key=${api_key}`;
try {
const response = await fetch(url);
const data = await response.json();
const result = data.values.map(row => {
return {
place: row[0],
name: row[1],
time: row[2],
score: row[3],
color: row[0] == 1 ? '#00ff00' :
row[0] == 2 ? 'cyan' :
row[0] == 3 ? 'yellow' :
''
}
});
return result;
} catch (error) {
console.error('Error fetching Google Sheet data:', error);
throw error;
}
}
</script>
</body>
</html>