Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 55 lines (47 sloc) 1.473 kB
5fe0402 @whit537 Initial import of echo and top.
authored
1 <head>
2 <title>Greetings, program!</title>
3 <script src="/jquery-1.6.1.min.js"></script>
4 <script src="/socket.io-client/dist/socket.io.js"></script>
5 <script>
6 var App = {};
7
8 App.handle = undefined;
9
10 App.start = function()
11 {
12 App.socket.send('ping');
13 App.handle = setTimeout(App.start, 4000);
14 App.$button.html('Stop');
15 };
16
17 App.echo = function(e)
18 {
19 if (e.which !== 13) // return
20 return;
21 var value = $(this).val();
22 $(this).val('');
23 App.socket.send(value);
24 };
25
26 App.echoed = function(message)
27 {
28 App.$messages.append('<p>'+message+'</p>');
29 };
30
31 $(document).ready(function() {
32 App.$messages = $('#messages');
33 App.$input = $('input');
34 App.$input.keyup(App.echo);
35 App.$input.focus();
36
37 App.socket = io.connect( '/echo.sock'
38 , { "resource": "echo.sock"
39 , "transports": ["xhr-polling"]
40 }
41 );
42 App.socket.on('message', App.echoed)
43
44 });
45 </script>
46 </head>
47 <body>
48 <h1>Aspen Socket Toys</h1>
49 <a href="/">echo</a>,
50 <a href="/top.html">top</a>,
51 <a href="chat">chat</a>
52 <p><input /></p>
53 <div id="messages"></div>
54 </body>
Something went wrong with that request. Please try again.