-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
131 lines (117 loc) · 5.85 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Buzzy</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body>
<script>
function host(){
document.getElementById("right").classList.add("shrink");
document.getElementById("left").classList.add("expand");
document.getElementById("lbutton").classList.add("goaway");
document.getElementById("rbutton").classList.add("goaway");
document.getElementById("roomid").classList.add("goaway");
document.getElementById("name").classList.add("goaway");
document.getElementById("host_form").classList.add("godown");
document.getElementById("logo").classList.add("goleft");
}
function join(){
document.getElementById("left").classList.add("shrink");
document.getElementById("right").classList.add("expand");
document.getElementById("lbutton").classList.add("goaway");
document.getElementById("rbutton").classList.add("goaway");
document.getElementById("roomid").classList.add("goaway");
document.getElementById("name").classList.add("goaway");
document.getElementById("join_form").classList.add("godown");
document.getElementById("logo").classList.add("goleft");
}
</script>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
hosting=false;
socket = io();
socket.on('number', function(msg){
$("#number").text(msg);
host();
});
socket.on('buzz', function(msg){
if(hosting){
currentNum += 1;
var audio = new Audio('ding.mp3');
audio.play();
//var speech = new SpeechSynthesisUtterance('Hey, guess what? '+msg+' just buzzed.');
//window.speechSynthesis.speak(speech);
$("#list").append('<li class="mdl-list__item">\
<span class="mdl-list__item-primary-content">\
<span class="mdl-list__item-avatar" style="text-align:center">'+currentNum+'</span>'+msg+'</span>\
</li>');
}
});
socket.on('name',function(msg){
$("#nametag").text(msg);
join();
});
socket.on('reset', function(msg){
console.log("hi");
$("#list").empty();
currentNum=0;
})
function hostGame(){
socket.emit('host',{});
hosting=true;
currentNum=0;
}
function joinGame(){
socket.emit('join',{number:document.getElementById("sample2").value,name:document.getElementById("sample3").value});
}
function resetGame(){
socket.emit('reset',{});
}
function buzzGame(){
socket.emit('buzz',{});
}
</script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.1/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.1.1/material.min.js"></script>
<link rel="stylesheet" href="index.css">
<img id="logo" src="buzzy.png"/>
<div id="left" class="split">
<button id="lbutton" class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mainbutton" onclick="hostGame()">Host</button>
</div>
<div id="right" class="split" style="display:flex; flex-direction: column">
<div id="roomid" class="mdl-textfield mdl-js-textfield mainbutton">
<input maxlength="6" style="background-color:#FAFAFA; border-radius: 3px; text-align: center" class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="sample2">
<label class="mdl-textfield__label" for="sample2">Room ID</label>
</div>
<div id="name" class="mdl-textfield mdl-js-textfield mainbutton">
<input style="background-color:#FAFAFA; border-radius: 3px; text-align: center" class="mdl-textfield__input" type="text" id="sample3">
<label class="mdl-textfield__label" for="sample3">Name</label>
</div>
<button id="rbutton" style="self-align:center" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mainbutton" onclick="joinGame()">Join</button>
</div>
<div id="join_form">
<h1 id="nametag" style="color:#fafafa; min-height:10vh; max-height:10vh; width: 100vw; max-width: 100vw; text-align: center; font-size:10vh; white-space: nowrap;"></h1>
<button id="buzz" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored" style="background-color:#4051B5; max-height: 80vh; max-width: 100vw; height: 80vh; width: 80vh" onclick="buzzGame();">
</button>
</div>
<div id="wrapper">
<div id="host_form">
<h1 id="number" style="color:#fafafa; min-height:20vh; max-height:20vh; font-size:20vh;"></h1>
<ul class='mdl-list' id="list" style="min-height:75vh; max-height:75vh; display: flex; flex-wrap: wrap; flex-direction: column; align-content:center;">
</ul>
<button style="position:absolute; bottom:10vh; right:5vw" class="mdl-button mdl-js-button mdl-button--fab mdl-button--colored" onclick="resetGame();">
<i class="material-icons">clear</i>
</button>
</div>
</div>
<footer style="bottom: 0; position:fixed; z-index: 100">
<!-- Place this tag where you want the button to render. -->
<a aria-label="Star jordanbuchman/buzzy on GitHub" data-count-aria-label="# stargazers on GitHub" data-count-api="/repos/jordanbuchman/buzzy#stargazers_count" data-count-href="/jordanbuchman/buzzy/stargazers" data-style="mega" href="https://github.com/jordanbuchman/buzzy" class="github-button">Star</a>
</footer>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>