-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
30 lines (28 loc) · 840 Bytes
/
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Treasure Island</title>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
</head>
<body>
<h1>Treasure Island</h1>
<ul id="sent"></ul>
<ul id="received"></ul>
<form action="">
<input id="m" autocomplete="off" /><button id="b">Send</button>
</form>
<script>
var socket = io();
$('#b').click(function(){
socket.emit('chat message', $('#m').val());
$('#sent').append($('<li>').text($('#m').val()));
$('#m').val('');
return false;
});
socket.on('chat message', function (msg) {
$('#received').append($('<li>').text(msg));
});
</script>
</body>
</html>