Debian Codegraph @

examples/websocket_chat.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
5 <script>
6 window.onload = function() {
7 var data = {};
8 var s = new WebSocket("ws://127.0.0.1:%(port)s/chat");
9 s.onopen = function() {
10 s.send('New participant joined');
11 };
12 s.onmessage = function(e) {
13 $("#chat").append("<div>" + e.data + "</div>");
14 };
15 $('#chatform').submit(function (evt) {
16 var line = $('#chatform [type=text]').val()
17 $('#chatform [type=text]').val('')
18 s.send(line);
19 return false;
20 });
21 };
22 </script>
23 </head>
24 <body>
25 <h3>Chat!</h3>
26 <p>(Only tested in Chrome)</p>
27 <div id="chat" style="width: 60em; height: 20em; overflow:auto; border: 1px solid black">
28 </div>
29 <form id="chatform">
30 <input type="text" />
31 <input type="submit" />
32 </form>
33 </body>
34 </html>