-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
64 lines (53 loc) · 1.98 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
<!doctype html>
<html>
<head>
<title>Who Says?</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<meta name='mobile-web-app-capable' content='yes'>
<link rel='icon' href='/public/icon.png'>
<link rel='apple-touch-icon' href='/public/icon.png'>
<link href='http://fonts.googleapis.com/css?family=Karla:400,700' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='https://storage.googleapis.com/code.getmdl.io/1.0.0/material.indigo-pink.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<link rel='stylesheet' href='/public/style.css'>
<script src='https://cdn.socket.io/socket.io-1.2.0.js'></script>
<script src='http://code.jquery.com/jquery-1.11.1.js'></script>
<script src='https://storage.googleapis.com/code.getmdl.io/1.0.0/material.min.js'></script>
</head>
<body class="player">
<div class="question">
</div>
<div class="card">
<form action="">
<textarea id="m" placeholder="Type your answer here..." ></textarea>
<button id="submit" class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored"><i class="material-icons">check</i></button>
</form>
</div>
<script>
// start the socket
var socket = io();
// show the FAB when user inputs text onto card
$('textarea').on('input', function() {
$('button').css("margin-right", "0px");
});
// on form submit
$('form').submit(function(){
socket.emit('answer', $('#m').val());
$('.question').empty();
$('#m').val('');
$('.card').addClass("played");
$('textarea').attr("disabled", true);
return false;
});
// on deal action from dealer
socket.on('deal', function(msg){
$('.question').empty();
$('.question').append(msg);
$('textarea').attr("disabled", false);
$('button').css("margin-right", "-50%");
$('.card').removeClass("played");
$('button').css("opacity",1);
});
</script>
</body>
</html>