-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jade
44 lines (42 loc) · 1.16 KB
/
index.jade
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
!!! 5
html
head
title zombiejs socket.io example
body
div
span events:
span#events
button#delay Send
ul#history
script(src="/jquery-1.7.1.js")
script(src="/socket.io/socket.io.js")
script
jQuery(function($) {
var eventId = 0;
var events = $('#events');
var history = $('#history');
var delay = $('#delay');
events.text(eventId);
var output = function(message) {
var li = $('<li></li>');
li.id = 'event-' + eventId;
li.text(eventId + ': ' + message);
history.append(li);
++eventId;
events.text(eventId);
}
var url = window.location.protocol + '//' + window.location.hostname;
if (window.location.port) {
url += ':' + window.location.port;
}
window.socket = io.connect(url + '/test');
socket.on('connect', function() {
output('connected');
});
socket.on('message', function(data) {
output(data.message);
});
delay.click(function() {
socket.emit('delay', { time: 500 });
});
});