var wsUri = "ws://connectfourweb.herokuapp.com/socket";
var output;



function init()
{
    output = document.getElementById("output");
    testWebSocket();

}

function testWebSocket()
{

    websocket = new WebSocket(wsUri);
    websocket.onopen = function(evt) { onOpen(evt) };
    websocket.onclose = function(evt) { onClose(evt) };
    websocket.onmessage = function(evt) { onMessage(evt) };
    websocket.onerror = function(evt) { onError(evt) };
}

function onOpen(evt)
{
    //writeToScreen("CONNECTED");
    doSend(current_cell);
}

function onClose(evt)
{
    //writeToScreen("DISCONNECTED");
}

function onMessage(evt)
{
    current_matrix = evt.data;
    //writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data+'</span>');
    websocket.close();
    showMatrix();
}

function onError(evt)
{
    writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data);
}

function doSend(message)
{
    //writeToScreen("SENT: " + message);
    websocket.send(message);
}

function writeToScreen(message)
{
    var pre = document.createElement("p");
    pre.style.wordWrap = "break-word";
    pre.innerHTML = message;
    output.appendChild(pre);
}

//window.addEventListener("load", init, false);
//window.addEventListener("click", init, false);
//window.addEventListener("click", function(){ alert("Hello World!"); });
@@ -62,16 +62,132 @@
 utput;%0A%0A
+function set_ws_uri()%7B%0A    var scheme   = %22ws://%22;%0A    wsUri =  scheme + window.document.location.host + %22/socket%22%0A%7D
 %0A%0Afuncti
@@ -242,24 +242,42 @@
 (%22output%22);%0A
+    set_ws_uri();%0A
     testWebS

Fix JavaScript