-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.html
59 lines (56 loc) · 2.31 KB
/
player.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<title>Player | Buzzer</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='css/player.css' />
<script src='bower_components/jquery/dist/jquery.min.js'></script>
<script src='node_modules/socket.io-client/socket.io.js'></script>
<script>
var socket = io('/player');
$(document).ready(function() {
$('#playerName').on('submit', function(e) {
e.preventDefault();
socket.emit('playerJoin', $('#playerNameInput').val() != '' ? $('#playerNameInput').val() : 'Anonymous', $('#roomInput').val().toUpperCase());
$('#playerName').remove();
return false;
});
$('body').on('click', '#answer', function() {
socket.emit('answer');
});
socket.on('success', function() {
$('body').removeClass('active').addClass('success');
});
socket.on('failure', function() {
$('body').removeClass('active').addClass('failure');
});
socket.on('continue', function() {
$('body').removeClass('success').removeClass('failure').removeClass('active');
});
socket.on('guessAccepted', function() {
$('body').addClass('active');
});
socket.on('setButton', function(button){
$('#answer').css('background-color', button.color).addClass(button.class);
if($('#answer').hasClass("screen")) $('.btn').removeClass('center');
$('#buttonContainer').show();
});
socket.on('exit', function(){
location.reload();
});
});
</script>
</head>
<body>
<form id='playerName' class='center'>
<h1>Choose a name</h1>
<input id='playerNameInput' placeholder='Anonymous' />
<h1>Join a room</h1>
<input id='roomInput' required />
<input type='submit' value='submit' />
</form>
<div id='buttonContainer' class="btn center"><button id="answer">Answer</button></div>
</body>
</html>