From: Michael Jumper Date: Wed, 9 Mar 2011 05:42:43 +0000 (-0800) Subject: Added missing semicolons, improved state handling X-Git-Url: http://git.alex.org.uk Added missing semicolons, improved state handling --- diff --git a/src/main/resources/guacamole.js b/src/main/resources/guacamole.js index 2506579..0d35ead 100644 --- a/src/main/resources/guacamole.js +++ b/src/main/resources/guacamole.js @@ -43,7 +43,7 @@ function GuacamoleClient(display, tunnel) { this.setOnStateChangeHandler = function(handler) { stateChangeHandler = handler; - } + }; function isConnected() { return currentState == STATE_CONNECTED @@ -89,7 +89,7 @@ function GuacamoleClient(display, tunnel) { return; tunnel.sendMessage("key:" + keysym + "," + pressed + ";"); - } + }; this.sendMouseState = function(mouseState) { @@ -115,7 +115,7 @@ function GuacamoleClient(display, tunnel) { // Send message tunnel.sendMessage("mouse:" + mouseState.getX() + "," + mouseState.getY() + "," + buttonMask + ";"); - } + }; this.setClipboard = function(data) { @@ -123,8 +123,8 @@ function GuacamoleClient(display, tunnel) { if (!isConnected()) return; - tunnel.sendMessage("clipboard:" + tunnel.escapeGuacamoleString(data) + ";"); - } + tunnel.sendMessage("clipboard:" + escapeGuacamoleString(data) + ";"); + }; // Handlers @@ -153,7 +153,7 @@ function GuacamoleClient(display, tunnel) { this.getLayers = function() { return layers; - } + }; function getLayer(index) { @@ -217,16 +217,16 @@ function GuacamoleClient(display, tunnel) { var instructionHandlers = { "error": function(parameters) { - if (errorHandler) errorHandler(tunnel.unescapeGuacamoleString(parameters[0])); + if (errorHandler) errorHandler(unescapeGuacamoleString(parameters[0])); disconnect(); }, "name": function(parameters) { - if (nameHandler) nameHandler(tunnel.unescapeGuacamoleString(parameters[0])); + if (nameHandler) nameHandler(unescapeGuacamoleString(parameters[0])); }, "clipboard": function(parameters) { - if (clipboardHandler) clipboardHandler(tunnel.unescapeGuacamoleString(parameters[0])); + if (clipboardHandler) clipboardHandler(unescapeGuacamoleString(parameters[0])); }, "size": function(parameters) { @@ -319,17 +319,8 @@ function GuacamoleClient(display, tunnel) { handler(parameters); } - - this.connect = function() { - setState(STATE_CONNECTING); - tunnel.connect(); - setState(STATE_WAITING); - - }; - - function disconnect() { // Only attempt disconnection not disconnected. @@ -344,6 +335,67 @@ function GuacamoleClient(display, tunnel) { } + function escapeGuacamoleString(str) { + + var escapedString = ""; + + for (var i=0; i= 2) { - pollResponse = 0; + pollingMode = POLLING_DISABLED; xmlhttprequest.onreadystatechange = parseResponse; } } @@ -212,13 +222,13 @@ function GuacamoleHTTPTunnel(tunnelURL) { connect_xmlhttprequest.send(null); // Start reading data - connected = 1; + currentState = STATE_CONNECTED; handleResponse(makeRequest()); } function disconnect() { - connected = 0; + currentState = STATE_DISCONNECTED; } // External API @@ -227,57 +237,6 @@ function GuacamoleHTTPTunnel(tunnelURL) { this.sendMessage = sendMessage; this.setInstructionHandler = function(handler) { instructionHandler = handler; - } - - this.escapeGuacamoleString = function(str) { - - var escapedString = ""; - - for (var i=0; i