-
Notifications
You must be signed in to change notification settings - Fork 1
/
shotclock.html
53 lines (40 loc) · 1.17 KB
/
shotclock.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shot Clock</title>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<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=Orbitron&display=swap" rel="stylesheet">
</head>
<body>
<h1 id="timer">60</h1>
</body>
</html>
<style>
h1 {
font-family: 'Orbitron', sans-serif;
font-size: 100px;
color:yellow;
}
</style>
<script>
const socket = io('http://localhost:3000');
let time = 60;
socket.on('connect', () => {
console.log('connected');
});
// decrease clock by 1 every second
let x = setInterval(() => {
if (time == 0) return;
time -= 1;
document.getElementById('timer').innerHTML = time;
}, 1000);
socket.on('reset clock', (data) => {
console.log(data);
time = parseInt(data.time);
});
</script>