/* http://www.JSON.org/json_parse.js 2009-04-18 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. This file creates a json_parse function. json_parse(text, reviver) This method parses a JSON text to produce an object or array. It can throw a SyntaxError exception. The optional reviver parameter is a function that can filter and transform the results. It receives each of the keys and values, and its return value is used instead of the original value. If it returns what it received, then the structure is not modified. If it returns undefined then the member is deleted. Example: // Parse the text. Values that look like ISO date strings will // be converted to Date objects. myData = json_parse(text, function (key, value) { var a; if (typeof value === 'string') { a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); if (a) { return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6])); } } return value; }); This is a reference implementation. You are free to copy, modify, or redistribute. This code should be minified before deployment. See http://javascript.crockford.com/jsmin.html USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO NOT CONTROL. */ /*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode, hasOwnProperty, message, n, name, push, r, t, text */ /*global json_parse */ json_parse = (function () { // This is a function that can parse a JSON text, producing a JavaScript // data structure. It is a simple, recursive descent parser. It does not use // eval or regular expressions, so it can be used as a model for implementing // a JSON parser in other languages. // We are defining the function inside of another function to avoid creating // global variables. var at, // The index of the current character ch, // The current character escapee = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }, text, error = function (m) { // Call error when something is wrong. throw { name: 'SyntaxError', message: m, at: at, text: text }; }, next = function (c) { // If a c parameter is provided, verify that it matches the current character. if (c && c !== ch) { error("Expected '" + c + "' instead of '" + ch + "'"); } // Get the next character. When there are no more characters, // return the empty string. ch = text.charAt(at); at += 1; return ch; }, number = function () { // Parse a number value. var number, string = ''; if (ch === '-') { string = '-'; next('-'); } while (ch >= '0' && ch <= '9') { string += ch; next(); } if (ch === '.') { string += '.'; while (next() && ch >= '0' && ch <= '9') { string += ch; } } if (ch === 'e' || ch === 'E') { string += ch; next(); if (ch === '-' || ch === '+') { string += ch; next(); } while (ch >= '0' && ch <= '9') { string += ch; next(); } } number = +string; if (isNaN(number)) { error("Bad number"); } else { return number; } }, string = function () { // Parse a string value. var hex, i, string = '', uffff; // When parsing for string values, we must look for " and \ characters. if (ch === '"') { while (next()) { if (ch === '"') { next(); return string; } else if (ch === '\\') { next(); if (ch === 'u') { uffff = 0; for (i = 0; i < 4; i += 1) { hex = parseInt(next(), 16); if (!isFinite(hex)) { break; } uffff = uffff * 16 + hex; } string += String.fromCharCode(uffff); } else if (typeof escapee[ch] === 'string') { string += escapee[ch]; } else { break; } } else { string += ch; } } } error("Bad string"); }, white = function () { // Skip whitespace. while (ch && ch <= ' ') { next(); } }, word = function () { // true, false, or null. switch (ch) { case 't': next('t'); next('r'); next('u'); next('e'); return true; case 'f': next('f'); next('a'); next('l'); next('s'); next('e'); return false; case 'n': next('n'); next('u'); next('l'); next('l'); return null; } error("Unexpected '" + ch + "'"); }, value, // Place holder for the value function. array = function () { // Parse an array value. var array = []; if (ch === '[') { next('['); white(); if (ch === ']') { next(']'); return array; // empty array } while (ch) { array.push(value()); white(); if (ch === ']') { next(']'); return array; } next(','); white(); } } error("Bad array"); }, object = function () { // Parse an object value. var key, object = {}; if (ch === '{') { next('{'); white(); if (ch === '}') { next('}'); return object; // empty object } while (ch) { key = string(); white(); next(':'); if (Object.hasOwnProperty.call(object, key)) { error('Duplicate key "' + key + '"'); } object[key] = value(); white(); if (ch === '}') { next('}'); return object; } next(','); white(); } } error("Bad object"); }; value = function () { // Parse a JSON value. It could be an object, an array, a string, a number, // or a word. white(); switch (ch) { case '{': return object(); case '[': return array(); case '"': return string(); case '-': return number(); default: return ch >= '0' && ch <= '9' ? number() : word(); } }; // Return the json_parse function. It will have access to all of the above // functions and variables. return function (source, reviver) { var result; text = source; at = 0; ch = ' '; result = value(); white(); if (ch) { error("Syntax error"); } // If there is a reviver function, we recursively walk the new structure, // passing each name/value pair to the reviver function for possible // transformation, starting with a temporary root object that holds the result // in an empty key. If there is not a reviver function, we simply return the // result. return typeof reviver === 'function' ? (function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); }({'': result}, '')) : result; }; }());function serialize (mixed_value) { // Returns a string representation of variable (which can later be unserialized) // // version: 909.322 // discuss at: http://phpjs.org/functions/serialize // + original by: Arpad Ray (mailto:arpad@php.net) // + improved by: Dino // + bugfixed by: Andrej Pavlovic // + bugfixed by: Garagoth // + input by: DtTvB (http://dt.in.th/2008-09-16.string-length-in-bytes.html) // + bugfixed by: Russell Walker (http://www.nbill.co.uk/) // + bugfixed by: Jamie Beck (http://www.terabit.ca/) // % note: We feel the main purpose of this function should be to ease the transport of data between php & js // % note: Aiming for PHP-compatibility, we have to translate objects to arrays // * example 1: serialize(['Kevin', 'van', 'Zonneveld']); // * returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}' // * example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'}); // * returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}' var utf8Size = function(str) { // NEW FUNCTION var size = 0; for (var i = 0; i < str.length; i++) { var code = str.charCodeAt(i); if (code < 0x0080) size += 1; else if (code < 0x0800) size += 2; else size += 3; } return size; } var _getType = function (inp) { var type = typeof inp, match; var key; if (type == 'object' && !inp) { return 'null'; } if (type == "object") { if (!inp.constructor) { return 'object'; } var cons = inp.constructor.toString(); match = cons.match(/(\w+)\(/); if (match) { cons = match[1].toLowerCase(); } var types = ["boolean", "number", "string", "array"]; for (key in types) { if (cons == types[key]) { type = types[key]; break; } } } return type; }; var type = _getType(mixed_value); var val, ktype = ''; switch (type) { case "function": val = ""; break; case "boolean": val = "b:" + (mixed_value ? "1" : "0"); break; case "number": val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value; break; case "string": val = "s:" + utf8Size(mixed_value) + ":\"" + mixed_value + "\""; // MODIFIED LINE break; case "array": case "object": val = "a"; /* if (type == "object") { var objname = mixed_value.constructor.toString().match(/(\w+)\(\)/); if (objname == undefined) { return; } objname[1] = this.serialize(objname[1]); val = "O" + objname[1].substring(1, objname[1].length - 1); } */ var count = 0; var vals = ""; var okey; var key; for (key in mixed_value) { ktype = _getType(mixed_value[key]); if (ktype == "function") { continue; } okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key); vals += this.serialize(okey) + this.serialize(mixed_value[key]); count++; } val += ":" + count + ":{" + vals + "}"; break; case "undefined": // Fall-through default: // if the JS object has a property which contains a null value, the string cannot be unserialized by PHP val = "N"; break; } if (type != "object" && type != "array") { val += ";"; } return val; } function unserialize (data) { // Takes a string representation of variable and recreates it // // version: 909.322 // discuss at: http://phpjs.org/functions/unserialize // + original by: Arpad Ray (mailto:arpad@php.net) // + improved by: Pedro Tainha (http://www.pedrotainha.com) // + bugfixed by: dptr1988 // + revised by: d3x // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + input by: Brett Zamir (http://brett-zamir.me) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Chris // + improved by: James // % note: We feel the main purpose of this function should be to ease the transport of data between php & js // % note: Aiming for PHP-compatibility, we have to translate objects to arrays // * example 1: unserialize('a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'); // * returns 1: ['Kevin', 'van', 'Zonneveld'] // * example 2: unserialize('a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'); // * returns 2: {firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'} var error = function (type, msg, filename, line){throw new this.window[type](msg, filename, line);}; var read_until = function (data, offset, stopchr){ var buf = []; var chr = data.slice(offset, offset + 1); var i = 2; while (chr != stopchr) { if ((i+offset) > data.length) { error('Error', 'Invalid'); } buf.push(chr); chr = data.slice(offset + (i - 1),offset + i); i += 1; } return [buf.length, buf.join('')]; }; var read_chrs = function (data, offset, length){ var buf; buf = []; for (var i = 0;i < length;i++){ var chr = data.slice(offset + (i - 1),offset + i); buf.push(chr); length -= utf8Overhead(chr); // NEW LINE } return [buf.length, buf.join('')]; }; var utf8Overhead = function(char) { // NEW FUNCTION var code = char.charCodeAt(0); if (code < 0x0080) return 0; if (code < 0x0800) return 1; return 2; }; var _unserialize = function (data, offset){ var readdata; var readData; var chrs = 0; var ccount; var stringlength; var keyandchrs; var keys; if (!offset) {offset = 0;} var dtype = (data.slice(offset, offset + 1)).toLowerCase(); var dataoffset = offset + 2; var typeconvert = new Function('x', 'return x'); //alert(dtype); switch (dtype){ case 'i': typeconvert = function (x) {return parseInt(x, 10);}; readData = read_until(data, dataoffset, ';'); chrs = readData[0]; readdata = readData[1]; dataoffset += chrs + 1; break; case 'b': typeconvert = function (x) {return parseInt(x, 10) !== 0;}; readData = read_until(data, dataoffset, ';'); chrs = readData[0]; readdata = readData[1]; dataoffset += chrs + 1; break; case 'd': typeconvert = function (x) {return parseFloat(x);}; readData = read_until(data, dataoffset, ';'); chrs = readData[0]; readdata = readData[1]; dataoffset += chrs + 1; break; case 'n': readdata = null; break; case 's': ccount = read_until(data, dataoffset, ':'); chrs = ccount[0]; stringlength = ccount[1]; dataoffset += chrs + 2; readData = read_chrs(data, dataoffset+1, parseInt(stringlength, 10)); chrs = readData[0]; readdata = readData[1]; dataoffset += chrs + 2; if (chrs != parseInt(stringlength, 10) && chrs != readdata.length){ error('SyntaxError', 'String length mismatch'); } break; case 'a': readdata = {}; keyandchrs = read_until(data, dataoffset, ':'); chrs = keyandchrs[0]; keys = keyandchrs[1]; dataoffset += chrs + 2; for (var i = 0; i < parseInt(keys, 10); i++){ var kprops = _unserialize(data, dataoffset); var kchrs = kprops[1]; var key = kprops[2]; dataoffset += kchrs; var vprops = _unserialize(data, dataoffset); var vchrs = vprops[1]; var value = vprops[2]; dataoffset += vchrs; readdata[key] = value; } dataoffset += 1; break; default: error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype); break; } return [dtype, dataoffset - offset, typeconvert(readdata)]; }; return _unserialize((data+''), 0)[2]; }function var_dump () { // Dumps a string representation of variable to output // // version: 909.322 // discuss at: http://phpjs.org/functions/var_dump // + original by: Brett Zamir (http://brett-zamir.me) // - depends on: echo // * example 1: var_dump(1); // * returns 1: 'int(1)' // // MODIFIED: Alert instead of echo. var output = "", pad_char = " ", pad_val = 4, lgth = 0, i = 0, d = this.window.document; var getFuncName = function (fn) { var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn); if (!name) { return '(Anonymous)'; } return name[1]; }; var repeat_char = function (len, pad_char) { var str = ""; for (var i=0; i < len; i++) { str += pad_char; } return str; }; var getScalarVal = function (val) { var ret = ''; if (val === null) { ret = 'NULL'; } else if (typeof val === 'boolean') { ret = 'bool('+val+')'; } else if (typeof val === 'string') { ret = 'string('+val.length+') "'+val+'"'; } else if (typeof val === 'number') { if (parseFloat(val) == parseInt(val, 10)) { ret = 'int('+val+')'; } else { ret = 'float('+val+')'; } } else if (val === undefined) { ret = 'UNDEFINED'; // Not PHP behavior, but neither is undefined as value } else if (typeof val === 'function') { ret = 'FUNCTION'; // Not PHP behavior, but neither is function as value } return ret; }; var formatArray = function (obj, cur_depth, pad_val, pad_char) { var someProp = ''; if (cur_depth > 0) { cur_depth++; } var base_pad = repeat_char(pad_val*(cur_depth-1), pad_char); var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char); var str = ""; var val=''; if (typeof obj === 'object' && obj !== null) { if (obj.constructor && getFuncName(obj.constructor) === 'PHPJS_Resource') { return obj.var_dump(); } lgth = 0; for (someProp in obj) { lgth++; } str += "array("+lgth+") {\n"; for (var key in obj) { if (typeof obj[key] === 'object' && obj[key] !== null) { str += thick_pad + "["+key+"] =>\n"+thick_pad+formatArray(obj[key], cur_depth+1, pad_val, pad_char); } else { val = getScalarVal(obj[key]); str += thick_pad + "["+key+"] =>\n"+thick_pad + val + "\n"; } } str += base_pad + "}\n"; } else { str = getScalarVal(obj); } return str; }; output = formatArray(arguments[0], 0, pad_val, pad_char); for (i=1; i < arguments.length; i++) { output += '\n'+formatArray(arguments[i], 0, pad_val, pad_char); } // NOTE: Other than in PHP the result will be returned instead of printed. return output; } var _GET = new Object(); if (window.location.search != "") { var pairs = window.location.search.substr(1).split("&"); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split("="); if (pair[1] != undefined) _GET[pair[0]] = pair[1]; } } pairs = pair = i = undefined; // INFO: The new functon creates an new instance of a class and calls its // construct function, which initializes the new instance. // NOTE: Adding new() to Function prototype instead of Object, because // new() should only be accessible by a class itself and not by its // instances. Function.prototype.construct = function() { var instance = new this(); if (instance.__construct) instance.__construct.apply(instance, arguments); return instance; } // INFO: sizeOf() returns the size of the string in bytes. I also handles // unicode strings correctly. String.prototype.sizeOf = function() { var str = this.valueOf(); var size = 0; for (var i = 0; i < this.length; i++) { var code = str[i].charCodeAt(0); if (code < 0x0080) size += 1; else if (code < 0x0800) size += 2; else size += 3; } return size; } function swx_IFrameRequest() { this.__construct = function() { this.responseText = ""; this.responseXML = null; this.status = 0; this.statusText = ""; this._setReadyState(0); } this._setReadyState = function(state) { this.readyState = state; if (this.onreadystatechange) this.onreadystatechange(); } this._finished = function() { if (this.readyState == 3) { this.responseText = frames[this._target].document.body.innerHTML; this.responseXML = frames[this._target].document.body.cloneNode(true); // TODO: Get real HTTP status. this.status = 200; this.statusText = "OK"; swx_IFrameRequest.slots[0] = null; this._setReadyState(4); } } this.abort = function() { this.readyState = undefined; this._action = undefined; this._actionOrg = undefined; this._method = undefined; this._methodOrg = undefined; this._target = undefined; this._targetOrg = undefined; this.responseText = undefined; this.responseXml = undefined; this.status = undefined; this.statusText = undefined; this.__construct(); } this.open = function(method, url, async, user, password) { if (swx_IFrameRequest.slots[0] == null) { swx_IFrameRequest.slots[0] = this; this._target = "swx_IFrameRequest_0"; } else { throw "swx_IFrameRequest: No free slots."; } this._action = url; this._method = method; this._setReadyState(1); } this.setRequestHeader = function(option, value) { // DUMMY } this.send = function(data) { if (data.nodeName && (data.nodeName == "FORM")) { this._actionOrg = data.action; this._methodOrg = data.method; this._targetOrg = data.target; data.action = this._action; data.method = this._method; data.target = this._target; data.encoding = "multipart/form-data"; var reflection = this; //document.getElementsByName[this._target].onload = function() {reflection._onload();}; data.submit(); } else { alert("TODO"); } this._setReadyState(3); } this.onreadystatechange = undefined; this._action = undefined; this._actionOrg = undefined; this._method = undefined; this._methodOrg = undefined; this._target = undefined; this._targetOrg = undefined; this.readyState = undefined; this.responseText = undefined; this.responseXml = undefined; this.status = undefined; this.statusText = undefined; } swx_IFrameRequest.slots = new Array(); swx_IFrameRequest.finished = function(i) { if (swx_IFrameRequest.slots[i] != null) swx_IFrameRequest.slots[i]._finished(); } swx_IFrameRequest.init = function() { swx_IFrameRequest.slots.push(null); document.body.innerHTML += ""; } function swx_XMLHTTPRequest() { this.__construct = function(url, method, async, user, password) { if (method == undefined) method = "POST"; if (async == undefined) async = true; this.async = async; this.method = method; this.password = password; this.url = url; this.user = user; } this.create = function(useiframe) { var request = null; if (useiframe) { request = swx_IFrameRequest.construct(); } else { try { request = new XMLHttpRequest(); } catch (e) { try { request = new ActiveXObject("MSXML2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { throw "swx_XMLHTTPRequest: Unable to create HTTP request object."; } } } } var reflection = this; request.onreadystatechange = function() { reflection.onreadystatechange(request); } request.open(this.method, this.url, this.async); if (this.method == "POST") request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); return request; } this.send = function(data, useiframe) { var request = this.create(useiframe); request.send(data); if ((!this.async) && (request.status != 200)) this.onerror(request); return request; } this.onerror = function(request) { var httperror = request.status+": "+request.statusText; request.abort(); delete request; throw "swx_XMLHTTPRequest: HTTP error "+httperror; } this.onreadystatechange = function(request) { // INFO: The request status is only defined at readyState 4. if ((request.readyState == 4) && (request.status != 200) && (request.status != 0)) this.onerror(request); else if (this["onreadystate"+request.readyState] != undefined) this["onreadystate"+request.readyState](request); } this.onreadystate0 = undefined; // INFO: Handler for state 'uninitialized'. this.onreadystate1 = undefined; // INFO: Handler for state 'loading'. this.onreadystate2 = undefined; // INFO: Handler for state 'loaded'. this.onreadystate3 = undefined; // INFO: Handler for state 'interactive'. this.onreadystate4 = undefined; // INFO: Handler for state 'complete'. this.async = undefined; this.method = undefined; this.password = undefined; this.url = undefined; this.user = undefined; } function swx_InterfaceClient() { this.__construct = function(script, async) { this.setScript(script, async); var reflection = this; this.request.onreadystate4 = function(request) { try { if (reflection.onreturn) reflection.onreturn(unserialize(request.responseText)); } catch (e) { reflection.onerror(request.responseText); } } } this.onerror = function(text) { throw "swx_InterfaceClient: \n"+text; } this.callFunction = function(func) { var args = new Array(); for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); try { var func = encodeURIComponent(func); var sargs = encodeURIComponent(serialize(args)); var request = this.request.send("__CALL=1&__FUNC="+func+"&__ARGS="+sargs+"&"); } catch (e) { this.onerror(e); } // alert(var_dump(request.responseText)); // DEBUG if (!this.request.async) { try { return unserialize(request.responseText); } catch (e) { this.onerror(request.responseText); } } } this.setScript = function(script, async) { if (async == undefined) async = false; this.request = swx_XMLHTTPRequest.construct(script, "POST", async); this.script = script; } this.onreturn = undefined; this.request = undefined; this.script = undefined; }function swx_HookupModule() { this.__construct = function(manager, name) { this.Manager = manager; this.Name = name; } this.execute = function() { var func = this.execute.arguments[0]; var args = new Array(); for (var i = 1; i < this.execute.arguments.length; i++) args.push(this.execute.arguments[i]); return this.Manager.execute(this.Name, func, args); } this.Manager = undefined; this.Name = undefined; } var swx_HookupManager = function() { this.__construct = function(environment) { this.Environment = unserialize(environment); swx_HookupManager.prototype.__construct.call(this, "./interface.php"+window.location.search); } this.execute = function(module, func, args) { return this.callFunction("Manager.execute", module, func, args); } this.executeAsync = function(module, rfunc, func, args) { this.onreturn = rfunc; this.setScript(this.script, true); this.callFunction("Manager.execute", module, func, args); this.setScript(this.script, false); this.onreturn = false; } this.Environment = undefined; } swx_HookupManager.prototype = new swx_InterfaceClient();var swx_Captcha = function() { // DUMMY FOR NOW }; swx_Captcha = swx_Captcha.construct();var swx_Dialog = function() { this.__construct = function() { this.DialogClasses = {}; } this.calibrate = function(id) { var dialog = document.getElementById(id); if (!dialog) throw "swx_Dialog: element '"+id+"' not found"; var offsetX = 0; var offsetY = 0; if (window.pageYOffset) { offsetX = window.pageXOffset; offsetY = window.pageYOffset; } else if (document.body.scrollTop) { offsetX = document.body.scrollLeft; offsetY = document.body.scrollTop; } else if (document.documentElement.scrollTop) { offsetX = document.documentElement.scrollLeft; offsetY = document.documentElement.scrollTop; } var windowX = 800; var windowY = 600; if (window.innerWidth) { windowX = window.innerWidth; windowY = window.innerHeight; } else if (document.documentElement.clientWidth) { windowX = document.documentElement.clientWidth; windowY = document.documentElement.clientHeight; } else if (document.body.clientWidth) { windowX = document.body.clientWidth; windowY = document.body.clientHeight; } dialog.style.display = "block"; dialog.style.left = ((windowX - dialog.offsetWidth) / 2 + offsetX) + "px"; dialog.style.top = ((windowY - dialog.offsetHeight) / 2 + offsetY) + "px"; if (dialog.elements[0]) dialog.elements[0].focus(); } this.register = function(id) { var dialog = document.getElementById(id); if (!dialog) throw "swx_Dialog: element '"+id+"' not found"; this.DialogClasses[id] = dialog; dialog.parentNode.removeChild(dialog); // alert(document.getElementById(id)); // DEBUG } this.show = function(id) { if (!this.DialogClasses[id]) throw "swx_Dialog: unknown dialog class '"+id+"'"; if (!document.getElementById(id)) { var dialog = this.DialogClasses[id].cloneNode(true); dialog.style.display = "block"; document.body.appendChild(dialog); this.calibrate(id); } } this.hide = function(id) { var dialog = document.getElementById(id); if (!dialog) throw "swx_Dialog: element '"+id+"' not found"; dialog.parentNode.removeChild(dialog); } this.update = function(id, html, action) { var dialog = document.getElementById(id); if (!dialog) throw "swx_Dialog: element '"+id+"' not found"; if (action != undefined) dialog.action = action; dialog.innerHTML = html; this.calibrate(id); } this.DialogClasses = undefined; }; swx_Dialog = swx_Dialog.construct();function swx_BackendModule() { } swx_BackendModule.prototype = new swx_HookupModule(); function swx_BackendManager() { } swx_BackendManager.prototype = new swx_HookupManager();function swx_BloxModule() { } swx_BloxModule.prototype = new swx_BackendModule(); function swx_BloxBackend() { } swx_BloxBackend.prototype = new swx_BackendManager();function swx_BloxFrontendModule() { }; swx_BloxFrontendModule.prototype = new swx_HookupModule(); var swx_BloxFrontend = function() { this.__construct = function(environment) { swx_BloxFrontend.prototype.__construct.call(this, environment); var reflection = this; window.onresize = function(event) {reflection.onresize(event);}; window.onload = function(event) {reflection.onload(event);}; } this.fixHeight = function() { //alert("fixing"); document.getElementById("swx_BloxLeft").style.minHeight = "0px"; document.getElementById("swx_BloxCenter").style.minHeight = "0px"; document.getElementById("swx_BloxRight").style.minHeight = "0px"; // NOTE: Firefox seems to round wrong. Therefore we subtract 0.5. var height = this.windowHeight - this.topHeight - this.bottomHeight - 0.5; var height_center = document.getElementById("swx_BloxCenter").offsetHeight; var height_left = document.getElementById("swx_BloxLeft").offsetHeight; var height_right = document.getElementById("swx_BloxRight").offsetHeight; if (height < height_center) height = height_center; if (height < height_left) height = height_left; if (height < height_right) height = height_right; // alert(windowY+"\n"+height_top+" - "+height_bottom+" - "+height_middle+"\n"+height_left+" - "+height_center+" - "+height_right+"\n"+height); // DEBUG document.getElementById("swx_BloxLeft").style.minHeight = height + "px"; document.getElementById("swx_BloxCenter").style.minHeight = height + "px"; document.getElementById("swx_BloxRight").style.minHeight = height + "px"; } this.onload = function() { this.topHeight = document.getElementById("swx_BloxMiddle").offsetTop; this.bottomHeight = document.body.offsetHeight - this.topHeight - document.getElementById("swx_BloxMiddle").offsetHeight; this.windowHeight = 500; if (window.innerHeight) this.windowHeight = window.innerHeight; else if (document.documentElement.clientHeight) this.windowHeight = document.documentElement.clientHeight; // TODO: module hooks this.fixHeight(); } this.onresize = function(event) { // TODO: module hooks this.fixHeight(); } this.topHeight = undefined; this.bottomHeight = undefined; }; swx_BloxFrontend.prototype = new swx_HookupManager();