From c770c28d669648311904f1745eb4d432d7e548b9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 31 Jan 2013 15:03:50 -0800 Subject: [PATCH] JavaScript-side refactor supporting new Connection API. --- guacamole/src/main/webapp/index.xhtml | 1 + guacamole/src/main/webapp/scripts/root-ui.js | 117 ++++++------------- guacamole/src/main/webapp/scripts/service.js | 75 ++++++++++++ 3 files changed, 109 insertions(+), 84 deletions(-) create mode 100644 guacamole/src/main/webapp/scripts/service.js diff --git a/guacamole/src/main/webapp/index.xhtml b/guacamole/src/main/webapp/index.xhtml index 5c62b81bc..3081c0160 100644 --- a/guacamole/src/main/webapp/index.xhtml +++ b/guacamole/src/main/webapp/index.xhtml @@ -136,6 +136,7 @@ Guacamole ${project.version} + diff --git a/guacamole/src/main/webapp/scripts/root-ui.js b/guacamole/src/main/webapp/scripts/root-ui.js index de0dee945..5beb8cd90 100644 --- a/guacamole/src/main/webapp/scripts/root-ui.js +++ b/guacamole/src/main/webapp/scripts/root-ui.js @@ -91,96 +91,45 @@ GuacamoleRootUI.login = function(username, password) { }; -/** - * An arbitrary Guacamole configuration, consisting of an ID/protocol pair. - * - * @constructor - * @param {String} protocol The protocol used by this configuration. - * @param {String} id The ID associated with this configuration. - */ -GuacamoleRootUI.Configuration = function(protocol, id) { - - /** - * The protocol associated with this configuration. - */ - this.protocol = protocol; - - /** - * The ID associated with this configuration. - */ - this.id = id; - -}; - -GuacamoleRootUI.getConfigurations = function(parameters) { - - // Construct request URL - var configs_url = "configs"; - if (parameters) configs_url += "?" + parameters; - - // Get config list - var xhr = new XMLHttpRequest(); - xhr.open("GET", configs_url, false); - xhr.send(null); - - // If fail, throw error - if (xhr.status != 200) - throw new Error(xhr.statusText); - - // Otherwise, get list - var configs = new Array(); - - var configElements = xhr.responseXML.getElementsByTagName("config"); - for (var i=0; i. + */ + +/** + * Main Guacamole web service namespace. + * @namespace + */ +var GuacamoleService = GuacamoleService || {}; + +/** + * An arbitrary Guacamole connection, consisting of an ID/protocol pair. + * + * @constructor + * @param {String} protocol The protocol used by this connection. + * @param {String} id The ID associated with this connection. + */ +GuacamoleService.Connection = function(protocol, id) { + + /** + * The protocol associated with this connection. + */ + this.protocol = protocol; + + /** + * The ID associated with this connection. + */ + this.id = id; + +}; + +GuacamoleService.getConnections = function(parameters) { + + // Construct request URL + var connections_url = "connections"; + if (parameters) connections_url += "?" + parameters; + + // Get connection list + var xhr = new XMLHttpRequest(); + xhr.open("GET", connections_url, false); + xhr.send(null); + + // If fail, throw error + if (xhr.status != 200) + throw new Error(xhr.statusText); + + // Otherwise, get list + var connections = new Array(); + + var connectionElements = xhr.responseXML.getElementsByTagName("connection"); + for (var i=0; i