-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (34 loc) · 883 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
31
32
33
34
35
36
37
38
39
<!doctype html>
<html>
<head>
<title>SaveBot</title>
</head>
<body>
<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off" />
<button>Send</button>
</form>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
let context = null;
$(function () {
var socket = io();
$('form').submit(function () {
socket.emit('chat message', {
context: context,
msg: $('#m').val(),
});
$('#messages').append($('<li>').text($('#m').val()));
$('#m').val('');
return false;
});
socket.on('chat message', function (response) {
context = response.context;
$('#messages').append($('<li>').text(response.msg));
});
});
</script>
</body>
</html>