-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (58 loc) · 1.51 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Latin Square Helper</title>
<script src="assets/alpinejs.min.js" defer></script>
<script type="module" src="assets/input-spinner.webcomponent.mjs"></script>
<style>
body {
font-family: Ubuntu, sans-serif;
overflow: hidden;
}
table {
font-size: 2em;
letter-spacing: .3em;
}
</style>
</head>
<body x-data="data">
<input-spinner min="0" max="999" style="width:8em" id="participant"
:value="participant" @click="update"></input-spinner>
<table>
<tr>
<template x-for="s in square">
<td x-text="s"></td>
</template>
</tr>
</table>
<script>
const SquaresConfig4 = [
['A', 'B', 'C', 'D'],
['C', 'D', 'A', 'B'],
['B', 'A', 'D', 'C'],
['D', 'C', 'B', 'A']
]
document.addEventListener('alpine:init', () => {
Alpine.data('data', () => ({
participant: 1,
square: SquaresConfig4[this.participant - 1],
async init() {
const res = await fetch('http://localhost:3000/latest');
const r = await res.json();
this.participant = r.participant + 1;
this.setSquare();
},
update() {
console.log("FOOO");
this.participant = document.getElementById('participant').value;
this.setSquare();
},
setSquare() {
this.square = SquaresConfig4[(this.participant - 1) % 4];
}
}));
});
</script>
</body>
</html>