From f6b787bfc3474d39e463e201eaf0ff185811596c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 14 Feb 2013 02:04:20 -0800 Subject: [PATCH] Ticket #268: Mostly-implemented UI. Still need enum type. --- guacamole/src/main/webapp/scripts/admin-ui.js | 287 ++++++------------ guacamole/src/main/webapp/scripts/service.js | 19 +- 2 files changed, 111 insertions(+), 195 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/admin-ui.js b/guacamole/src/main/webapp/scripts/admin-ui.js index bc3201702..253b8a5c5 100644 --- a/guacamole/src/main/webapp/scripts/admin-ui.js +++ b/guacamole/src/main/webapp/scripts/admin-ui.js @@ -36,7 +36,6 @@ var GuacAdmin = { "fields" : { "connection_id" : document.getElementById("connection-id"), - "protocol" : document.getElementById("protocol"), "username" : document.getElementById("username") }, @@ -53,26 +52,8 @@ var GuacAdmin = { * An arbitrary input field. * * @constructor - * @param {String} title A human-readable title for the field. - * @param {String[]} available The allowed value(s), if any. - * @param {String[]} selected The selected value(s), if any. */ -GuacAdmin.Field = function(title, available, selected) { - - /** - * A human-readable title describing this field. - */ - this.title = title; - - /** - * All available values, if any. - */ - this.available = available || []; - - /** - * All selected values, if any. - */ - this.selected = selected || []; +GuacAdmin.Field = function() { /** * Returns the DOM Element representing this field. @@ -82,11 +63,18 @@ GuacAdmin.Field = function(title, available, selected) { this.getElement = function() {}; /** - * Returns the selected values of this field. + * Returns the value of this field. * - * @return {String[]} All selected values. + * @return {String} The value of this field. */ - this.getSelected = function() {}; + this.getValue = function() {}; + + /** + * Sets the value of this field. + * + * @param {String} value The value of this field. + */ + this.setValue = function(value) {}; }; @@ -95,26 +83,29 @@ GuacAdmin.Field = function(title, available, selected) { * Simple HTML input field. * * @augments GuacAdmin.Field + * @param {String} type The type of HTML field. */ -GuacAdmin.Field._HTML_INPUT = function(type, title, available, selected) { +GuacAdmin.Field._HTML_INPUT = function(type) { // Call parent constructor - GuacAdmin.Field.apply(this, [title, available, selected]); + GuacAdmin.Field.apply(this); // Create backing element var element = GuacUI.createElement("input"); element.setAttribute("type", type); - if (selected && selected.length == 1) - element.setAttribute("value", selected[0]); - this.getSelected = function() { - return [element.value]; + this.getValue = function() { + return element.value; }; this.getElement = function() { return element; }; + this.setValue = function(value) { + element.value = value; + }; + }; GuacAdmin.Field._HTML_INPUT.prototype = new GuacAdmin.Field(); @@ -125,8 +116,8 @@ GuacAdmin.Field._HTML_INPUT.prototype = new GuacAdmin.Field(); * * @augments GuacAdmin.Field._HTML_INPUT */ -GuacAdmin.Field.TEXT = function(title, available, selected) { - GuacAdmin.Field._HTML_INPUT.apply(this, ["text", title, available, selected]); +GuacAdmin.Field.TEXT = function() { + GuacAdmin.Field._HTML_INPUT.apply(this, ["text"]); }; GuacAdmin.Field.TEXT.prototype = new GuacAdmin.Field._HTML_INPUT(); @@ -137,78 +128,48 @@ GuacAdmin.Field.TEXT.prototype = new GuacAdmin.Field._HTML_INPUT(); * * @augments GuacAdmin.Field._HTML_INPUT */ -GuacAdmin.Field.PASSWORD = function(title, available, selected) { - GuacAdmin.Field._HTML_INPUT.apply(this, ["password", title, available, selected]); +GuacAdmin.Field.PASSWORD = function() { + GuacAdmin.Field._HTML_INPUT.apply(this, ["password"]); }; GuacAdmin.Field.PASSWORD.prototype = new GuacAdmin.Field._HTML_INPUT(); - /** - * Multi-select list where each element has a corresponding checkbox. + * Simple checkbox. * * @augments GuacAdmin.Field */ -GuacAdmin.Field.LIST = function(title, available, selected) { +GuacAdmin.Field.CHECKBOX = function(value) { // Call parent constructor - GuacAdmin.Field.apply(this, [title, available, selected]); + GuacAdmin.Field.apply(this); - var i; + // Create backing element + var element = GuacUI.createElement("input"); + element.setAttribute("type", "checkbox"); + element.setAttribute("value", value); - // All selected connections - var is_selected = {}; - for (i=0; i