-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (60 loc) · 2.36 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
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Jeopardy</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="main" class="main text-center d-flex justify-content-center align-items-center">
<div class="align-center">
<h1 id="player-name" class="jeopardy medium"></h1>
<h1 id="score" class="jeopardy medium"></h1>
<img id="beep" src="red-button.png" style="display: none">
</div>
</div>
<script src="socket.io.min.js"></script>
<script src="jquery-3.3.1.min.js"></script>
<script>
$(function () {
var socket = io();
var userId;
$.get('/user', function (data) {
var player = JSON.parse(data);
userId = player.id;
$("#player-name").text(player.name);
$("#score").text(player.score);
$("#beep").fadeIn();
socket.emit("hello", userId);
});
$("#beep").click(function () {
if (userId != null && !$("#beep").prop('disabled')) {
socket.emit("beep", userId);
}
});
socket.on('status', function (status) {
if (status.beepEnabled && !status.alreadyAnswered[userId]) {
$("#beep").prop('disabled', false);
$("#beep").attr('src', 'green-button.png');
} else {
$("#beep").prop('disabled', true);
$("#beep").attr('src', 'red-button.png');
}
if (userId != null) {
$("#score").text(status.scores[userId]);
}
if (userId == status.answeringPlayer || userId == status.testPlayer) {
$("#main").addClass("selected");
$("#player-name").addClass("selected");
$("#score").addClass("selected");
} else {
$("#main").removeClass("selected");
$("#player-name").removeClass("selected");
$("#score").removeClass("selected");
}
});
});
</script>
</body>
</html>