/[projects]/miscJava/Test3/WebContent/WebsockTest.html
ViewVC logotype

Diff of /miscJava/Test3/WebContent/WebsockTest.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2106 by torben, Mon Feb 10 21:54:54 2014 UTC revision 2107 by torben, Tue Feb 11 08:33:52 2014 UTC
# Line 25  $( function() { Line 25  $( function() {
25                  }                  }
26                                    
27                  socket.onmessage = function(msg){                  socket.onmessage = function(msg){
28                      append(msg); //Awesome!                      append(msg.data); //Awesome!
29                  }                  }
30                    
31                  socket.onclose = function(){                  socket.onclose = function(){
# Line 42  $( function() { Line 42  $( function() {
42                                                    
43                          socket.send(txt);                          socket.send(txt);
44                                                    
45                            $("#txt").val("");
46                            
47                  } catch(exception) {                  } catch(exception) {
48                          append(exception);                          append(exception);
49                  }                  }
50          });          });
51                    
52            $(document).keypress(function(e) {
53                    if(e.which == 13) {
54                            try {
55                                    var txt = $("#txt").val();
56                                    append(txt);
57                                    
58                                    socket.send(txt);
59                                    $("#txt").val("");
60                                    
61                            } catch(exception) {
62                                    append(exception);
63                            }
64                    }
65            });
66            
67  });  });
68    
69    
70  </script>  </script>
71    
72  </head>  </head>
# Line 55  $( function() { Line 74  $( function() {
74    
75  <h2>Websocket test chat</h2>  <h2>Websocket test chat</h2>
76    
77  <textarea rows="30" cols="160" id="log"></textarea>  <textarea rows="30" cols="160" id="log" readonly></textarea>
78  <br>  <br>
79  <input size=120  type="text" name="txt" id="txt">  <input size=120  type="text" name="txt" id="txt">
80  <button id="btn">Submit</button>  <button id="btn">Submit</button>

Legend:
Removed from v.2106  
changed lines
  Added in v.2107

  ViewVC Help
Powered by ViewVC 1.1.20