-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (51 loc) · 1.86 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
<!doctype html>
<html lang="pt-br">
<head>
<title>socket.io chat</title>
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="/main.css"/>
<script src="/socket.io/socket.io.js"></script>
<script>
function onLoad() {
var socket = io.connect('http://localhost:8000');
var logBt = document.getElementById('loginButton');
logBt.onclick = function(e) {
var nameInp = document.getElementById('nameInput');
socket.emit('login', nameInp.value);
};
var sendBt = document.getElementById('sendButton');
sendBt.onclick = function(e) {
var msgTx = document.getElementById('mensagemInput');
socket.emit('mensagem', msgTx.value + '\n');
};
socket.on('ready', function (data) {
var chatTx = document.getElementById('chatTextArea');
chatTx.value += data + ' entrou\n';
});
socket.on('mensagemclient', function (msg, name) {
var chatTx = document.getElementById('chatTextArea');
chatTx.value += name + ': ' + msg;
});
}
window.onload = onLoad;
</script>
</head>
<body>
<h1>socket.io chat</h1>
<input id="nameInput" type="text"/>
<button id="loginButton">Login</button>
<br/>
<textarea id="chatTextArea" rows="5" cols="50"></textarea>
<br/>
<input id="mensagemInput" type="text"/>
<button id="sendButton">Send</button>
<img src="1.png">
<!-->snake goes here <!-->
<div id="wrapper">
<canvas id="game" height="400" width="700">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="/snake.js"></script>
</canvas>
</div>
</body>
</html>