WebSockets Echo

This example demonstrates the websockets
websocketsEcho/index.html.haml
!!! 5
%html
  %head
    %meta(charset="utf-8")
    %meta(content="IE=edge,chrome=1" http-equiv="X-UA-Compatible")
    %meta(name="viewport" content="width=device-width, initial-scale=1")  
    %link(rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css")
    %script(type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js")
    %script(type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js")
    %title
      WebSockets Echo
  %body
    :javascript
      var WebSocket = window.WebSocket || window.MozWebSocket;

      $(function() {
        var socket = new WebSocket('ws://echo.websocket.org/echo');
        
        $('#wsSend').click(function() {
          socket.send( $('#wsMessage').val() );
        })  
        socket.onopen = function(event) { 
          $('#console').append('<p>CONNECTED</p>');
        };
        socket.onmessage = function(event) {
          $('#console').append('<p>' + event.data + '</p>');
        }
        socket.onerror = function(event) {
          $('#console').append('<p>ERROR: ' + event.data + '</p>');
        }
      });
      
    %div(data-role="page")
      %input#wsMessage(type='text')
      %a#wsSend(data-role = 'button')
        Send
      #console