/* * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /** * Main Guacamole admin namespace. * @namespace */ var GuacAdmin = GuacAdmin || {}; /** * An arbitrary input field. Note that this object is not a component, and has * no corresponding element. Other objects which use GuacAdmin.Field may * interpret its values and render an element, however. * * @constructor * @param {String} title A human-readable title for the field. * @param {String} type The type of the input field. * @param {String} value The default value, if any. */ GuacAdmin.Field = function(title, type, value) { /** * A human-readable title describing this field. */ this.title = title; /** * The type of this field. Possible values are "text", "password", and * "checkbox". */ this.type = type; /** * The default value of this field. */ this.value = value; }; /** * An arbitrary button. Note that this object is not a component, and has * no corresponding element. Other objects which use GuacAdmin.Button may * interpret its values and render an element, however. * * @constructor * @param {String} title A human-readable title for the button. */ GuacAdmin.Button = function(title) { /** * A human-readable title describing this button. */ this.title = title; }; /** * An arbitrary table-based form. Given an array of fields and an array * of buttons, GuacAdmin.Form constructs a clean HTML form using DOM Elements. * * @constructor * @param {GuacAdmin.Field[]} fields An array of all fields to include in the * form. * @param {GuacAdmin.Button[]} buttons An array of all buttons to include in the * form. */ GuacAdmin.Form = function(fields, buttons) { // Main div and fields var element = GuacUI.createElement("div", "form"); var field_table = GuacUI.createChildElement(element, "table", "fields"); // Buttons var button_div = GuacUI.createChildElement(element, "div", "object-buttons"); /** * Returns the DOM element representing this form. */ this.getElement = function() { return element; }; /* * Add all fields */ var i; for (i=0; i