"use strict";

var websocketConnection;
function InitWebsocket( url )
{
    if ("WebSocket" in window)
    {
        try
        {
            if (typeof MozWebSocket === 'function')
            {
                window.WebSocket = MozWebSocket;
            }
            websocketConnection = new WebSocket( url );

            websocketConnection.onopen = function (evt )
            {
                setTimeout( function ()
                        {
                            // do something when we connect
                            onWebsocketConnect();
                        }, 0);
                                
            };
            websocketConnection.onclose = function ( evt )
            {
                setTimeout( function ()
                        {
                            onWebsocketClose();
                        }, 0 );
            };
            websocketConnection.onmessage = function ( evt )
            {
                setTimeout( function ()
                        {
                            onWebsocketMessage( evt.data );
                        }, 0 );
            };
            // don't care about websocketConnection.onError
        }
        catch(err)
        {
            alert(err);
        }
    }
    else
    {
        alert( "no websocket support" );
    }
}

function onWebsocketConnect()
{
    alert("connect");
    var obj = {};
    var arrayOfRequests = [];
    arrayOfRequests.push({ // push as much as you want into here
        "id":42,                                                                              
        "repeat":false
    });
    obj.DataReq = arrayOfRequests;
    var stringToSend = JSON.stringify(obj);
    websocketConnection.send( stringToSend );
}

function onWebsocketClose()
{
    alert("close");
}

function onWebsocketMessage( data )
{
    alert(data);
    var javascriptObject = JSON.parse( data );
    if( javascriptObject.valid === true )
    {
        alert(javascriptObject.val);
    }
    else
    {
        alert(javascriptObject.val);
    }
}

@@ -1506,16 +1506,34 @@
 id%22:42, 
+// 42 is boatspeed
         
@@ -1843,20 +1843,24 @@
 essage( 
-data
+incoming
  )%0A%7B%0A   
@@ -1866,20 +1866,24 @@
   alert(
-data
+incoming
 );%0A    v
@@ -1916,20 +1916,24 @@
 .parse( 
-data
+incoming
  );%0A    
@@ -1957,83 +1957,231 @@
 ect.
-valid === true )%0A    %7B%0A        alert(javascriptObject.val);%0A    %7D%0A    else%0A
+hasOwnProperty(%22Data%22))%0A    %7B%0A        var dataArray = javascriptObject.Data;%0A        for( var i = 0; i %3C dataArray.length; i++ )%0A        %7B%0A            var data = dataArray%5Bi%5D;%0A            if( data.valid === false )%0A        
     
@@ -2194,36 +2194,168 @@
     
+ 
-alert(javascriptObject.val);
+       alert(data.id + %22 : invalid%22);%0A            %7D%0A            else%0A            %7B%0A                alert(data.id + %22 : %22 + data.val);%0A            %7D %0A%0A        %7D
 %0A   

Make it do something useful