summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/extra
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/extra')
-rw-r--r--framework/Web/Javascripts/extra/behaviour.js68
-rw-r--r--framework/Web/Javascripts/extra/getElementsBySelector.js176
-rw-r--r--framework/Web/Javascripts/extra/json.js340
-rw-r--r--framework/Web/Javascripts/extra/logger.js753
4 files changed, 0 insertions, 1337 deletions
diff --git a/framework/Web/Javascripts/extra/behaviour.js b/framework/Web/Javascripts/extra/behaviour.js
deleted file mode 100644
index ac9adeda..00000000
--- a/framework/Web/Javascripts/extra/behaviour.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
- of Simon Willison (see comments by Simon below).
-
- Description:
-
- Uses css selectors to apply javascript behaviours to enable
- unobtrusive javascript in html documents.
-
- Usage:
-
- var myrules = {
- 'b.someclass' : function(element){
- element.onclick = function(){
- alert(this.innerHTML);
- }
- },
- '#someid u' : function(element){
- element.onmouseover = function(){
- this.innerHTML = "BLAH!";
- }
- }
- };
-
- Behaviour.register(myrules);
-
- // Call Behaviour.apply() to re-apply the rules (if you
- // update the dom, etc).
-
- License:
-
- This file is entirely BSD licensed.
-
- More information:
-
- http://ripcord.co.nz/behaviour/
-
-*/
-
-var Behaviour = {
- list : new Array,
-
- register : function(sheet){
- Behaviour.list.push(sheet);
- },
-
- start : function(){
- Event.OnLoad(Behaviour.apply);
- },
-
- apply : function(){
- for (h=0;sheet=Behaviour.list[h];h++){
- for (selector in sheet){
- list = document.getElementsBySelector(selector);
-
- if (!list){
- continue;
- }
-
- for (i=0;element=list[i];i++){
- sheet[selector](element);
- }
- }
- }
- }
-}
-
-Behaviour.start(); \ No newline at end of file
diff --git a/framework/Web/Javascripts/extra/getElementsBySelector.js b/framework/Web/Javascripts/extra/getElementsBySelector.js
deleted file mode 100644
index 592872fc..00000000
--- a/framework/Web/Javascripts/extra/getElementsBySelector.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/** document.getElementsBySelector(selector)
- - returns an array of element objects from the current document
- matching the CSS selector. Selectors can contain element names,
- class names and ids and can be nested. For example:
-
- elements = document.getElementsBySelect('div#main p a.external')
-
- Will return an array of all 'a' elements with 'external' in their
- class attribute that are contained inside 'p' elements that are
- contained inside the 'div' element which has id="main"
-
- New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
- See http://www.w3.org/TR/css3-selectors/#attribute-selectors
-
- Version 0.4 - Simon Willison, March 25th 2003
- -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
- -- Opera 7 fails
-*/
-
-/**
- * Returns all children of element. Workaround required for IE5/Windo
- */
-function getAllChildren(e) {
- // Returns all children of element. Workaround required for IE5/Windows. Ugh.
- return e.all ? e.all : e.getElementsByTagName('*');
-}
-
-/**
- * returns an array of element objects from the current document
- matching the CSS selector. Selectors can contain element names,
- class names and ids and can be nested. For example:
-
- <pre><tt>elements = $CSS('div#main p a.external')</tt></pre>
-
- Will return an array of all 'a' elements with 'external' in their
- class attribute that are contained inside 'p' elements that are
- contained inside the 'div' element which has id="main"
- */
-$CSS = function(selector) {
- // Attempt to fail gracefully in lesser browsers
- if (!document.getElementsByTagName) {
- return new Array();
- }
- // Split selector in to tokens
- var tokens = selector.split(' ');
- var currentContext = new Array(document);
- for (var i = 0; i < tokens.length; i++) {
- token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
- if (token.indexOf('#') > -1) {
- // Token is an ID selector
- var bits = token.split('#');
- var tagName = bits[0];
- var id = bits[1];
- var element = document.getElementById(id);
- if (tagName && element.nodeName.toLowerCase() != tagName) {
- // tag with that ID not found, return false
- return new Array();
- }
- // Set currentContext to contain just this element
- currentContext = new Array(element);
- continue; // Skip to next token
- }
- if (token.indexOf('.') > -1) {
- // Token contains a class selector
- var bits = token.split('.');
- var tagName = bits[0];
- var className = bits[1];
- if (!tagName) {
- tagName = '*';
- }
- // Get elements matching tag, filter them for class selector
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements;
- if (tagName == '*') {
- elements = getAllChildren(currentContext[h]);
- } else {
- elements = currentContext[h].getElementsByTagName(tagName);
- }
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- for (var k = 0; k < found.length; k++) {
- if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
- currentContext[currentContextIndex++] = found[k];
- }
- }
- continue; // Skip to next token
- }
- // Code to deal with attribute selectors
- if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
- var tagName = RegExp.$1;
- var attrName = RegExp.$2;
- var attrOperator = RegExp.$3;
- var attrValue = RegExp.$4;
- if (!tagName) {
- tagName = '*';
- }
- // Grab all of the tagName elements within current context
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements;
- if (tagName == '*') {
- elements = getAllChildren(currentContext[h]);
- } else {
- elements = currentContext[h].getElementsByTagName(tagName);
- }
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- var checkFunction; // This function will be used to filter the elements
- switch (attrOperator) {
- case '=': // Equality
- checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
- break;
- case '~': // Match one of space seperated words
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
- break;
- case '|': // Match start with value followed by optional hyphen
- checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
- break;
- case '^': // Match starts with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
- break;
- case '$': // Match ends with value - fails with "Warning" in Opera 7
- checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
- break;
- case '*': // Match ends with value
- checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
- break;
- default :
- // Just test for existence of attribute
- checkFunction = function(e) { return e.getAttribute(attrName); };
- }
- currentContext = new Array;
- var currentContextIndex = 0;
- for (var k = 0; k < found.length; k++) {
- if (checkFunction(found[k])) {
- currentContext[currentContextIndex++] = found[k];
- }
- }
- // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
- continue; // Skip to next token
- }
- // If we get here, token is JUST an element (not a class or ID selector)
- tagName = token;
- var found = new Array;
- var foundCount = 0;
- for (var h = 0; h < currentContext.length; h++) {
- var elements = currentContext[h].getElementsByTagName(tagName);
- for (var j = 0; j < elements.length; j++) {
- found[foundCount++] = elements[j];
- }
- }
- currentContext = found;
- }
- return currentContext;
-}
-
-/* That revolting regular expression explained
-/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
- \---/ \---/\-------------/ \-------/
- | | | |
- | | | The value
- | | ~,|,^,$,* or =
- | Attribute
- Tag
-*/
diff --git a/framework/Web/Javascripts/extra/json.js b/framework/Web/Javascripts/extra/json.js
deleted file mode 100644
index 0981169d..00000000
--- a/framework/Web/Javascripts/extra/json.js
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-Array.prototype.______array = '______array';
-
-Prado.AJAX.JSON = {
- org: 'http://www.JSON.org',
- copyright: '(c)2005 JSON.org',
- license: 'http://www.crockford.com/JSON/license.html',
-
- stringify: function (arg) {
- var c, i, l, s = '', v;
-
- switch (typeof arg) {
- case 'object':
- if (arg) {
- if (arg.______array == '______array') {
- for (i = 0; i < arg.length; ++i) {
- v = this.stringify(arg[i]);
- if (s) {
- s += ',';
- }
- s += v;
- }
- return '[' + s + ']';
- } else if (typeof arg.toString != 'undefined') {
- for (i in arg) {
- v = arg[i];
- if (typeof v != 'undefined' && typeof v != 'function') {
- v = this.stringify(v);
- if (s) {
- s += ',';
- }
- s += this.stringify(i) + ':' + v;
- }
- }
- return '{' + s + '}';
- }
- }
- return 'null';
- case 'number':
- return isFinite(arg) ? String(arg) : 'null';
- case 'string':
- l = arg.length;
- s = '"';
- for (i = 0; i < l; i += 1) {
- c = arg.charAt(i);
- if (c >= ' ') {
- if (c == '\\' || c == '"') {
- s += '\\';
- }
- s += c;
- } else {
- switch (c) {
- case '\b':
- s += '\\b';
- break;
- case '\f':
- s += '\\f';
- break;
- case '\n':
- s += '\\n';
- break;
- case '\r':
- s += '\\r';
- break;
- case '\t':
- s += '\\t';
- break;
- default:
- c = c.charCodeAt();
- s += '\\u00' + Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- }
- }
- }
- return s + '"';
- case 'boolean':
- return String(arg);
- default:
- return 'null';
- }
- },
- parse: function (text) {
- var at = 0;
- var ch = ' ';
-
- function error(m) {
- throw {
- name: 'JSONError',
- message: m,
- at: at - 1,
- text: text
- };
- }
-
- function next() {
- ch = text.charAt(at);
- at += 1;
- return ch;
- }
-
- function white() {
- while (ch) {
- if (ch <= ' ') {
- next();
- } else if (ch == '/') {
- switch (next()) {
- case '/':
- while (next() && ch != '\n' && ch != '\r') {}
- break;
- case '*':
- next();
- for (;;) {
- if (ch) {
- if (ch == '*') {
- if (next() == '/') {
- next();
- break;
- }
- } else {
- next();
- }
- } else {
- error("Unterminated comment");
- }
- }
- break;
- default:
- error("Syntax error");
- }
- } else {
- break;
- }
- }
- }
-
- function string() {
- var i, s = '', t, u;
-
- if (ch == '"') {
-outer: while (next()) {
- if (ch == '"') {
- next();
- return s;
- } else if (ch == '\\') {
- switch (next()) {
- case 'b':
- s += '\b';
- break;
- case 'f':
- s += '\f';
- break;
- case 'n':
- s += '\n';
- break;
- case 'r':
- s += '\r';
- break;
- case 't':
- s += '\t';
- break;
- case 'u':
- u = 0;
- for (i = 0; i < 4; i += 1) {
- t = parseInt(next(), 16);
- if (!isFinite(t)) {
- break outer;
- }
- u = u * 16 + t;
- }
- s += String.fromCharCode(u);
- break;
- default:
- s += ch;
- }
- } else {
- s += ch;
- }
- }
- }
- error("Bad string");
- }
-
- function array() {
- var a = [];
-
- if (ch == '[') {
- next();
- white();
- if (ch == ']') {
- next();
- return a;
- }
- while (ch) {
- a.push(value());
- white();
- if (ch == ']') {
- next();
- return a;
- } else if (ch != ',') {
- break;
- }
- next();
- white();
- }
- }
- error("Bad array");
- }
-
- function object() {
- var k, o = {};
-
- if (ch == '{') {
- next();
- white();
- if (ch == '}') {
- next();
- return o;
- }
- while (ch) {
- k = string();
- white();
- if (ch != ':') {
- break;
- }
- next();
- o[k] = value();
- white();
- if (ch == '}') {
- next();
- return o;
- } else if (ch != ',') {
- break;
- }
- next();
- white();
- }
- }
- error("Bad object");
- }
-
- function number() {
- var n = '', v;
- if (ch == '-') {
- n = '-';
- next();
- }
- while (ch >= '0' && ch <= '9') {
- n += ch;
- next();
- }
- if (ch == '.') {
- n += '.';
- while (next() && ch >= '0' && ch <= '9') {
- n += ch;
- }
- }
- if (ch == 'e' || ch == 'E') {
- n += 'e';
- next();
- if (ch == '-' || ch == '+') {
- n += ch;
- next();
- }
- while (ch >= '0' && ch <= '9') {
- n += ch;
- next();
- }
- }
- v = +n;
- if (!isFinite(v)) {
- ////error("Bad number");
- } else {
- return v;
- }
- }
-
- function word() {
- switch (ch) {
- case 't':
- if (next() == 'r' && next() == 'u' && next() == 'e') {
- next();
- return true;
- }
- break;
- case 'f':
- if (next() == 'a' && next() == 'l' && next() == 's' &&
- next() == 'e') {
- next();
- return false;
- }
- break;
- case 'n':
- if (next() == 'u' && next() == 'l' && next() == 'l') {
- next();
- return null;
- }
- break;
- }
- error("Syntax error");
- }
-
- function value() {
- white();
- switch (ch) {
- case '{':
- return object();
- case '[':
- return array();
- case '"':
- return string();
- case '-':
- return number();
- default:
- return ch >= '0' && ch <= '9' ? number() : word();
- }
- }
-
- return value();
- }
-}; \ No newline at end of file
diff --git a/framework/Web/Javascripts/extra/logger.js b/framework/Web/Javascripts/extra/logger.js
deleted file mode 100644
index b21df1ae..00000000
--- a/framework/Web/Javascripts/extra/logger.js
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
-
-Created By: Corey Johnson
-E-mail: probablyCorey@gmail.com
-
-Requires: Prototype Javascript library (http://prototype.conio.net/)
-
-Use it all you want. Just remember to give me some credit :)
-
-*/
-
-// ------------
-// Custom Event
-// ------------
-
-CustomEvent = Class.create()
-CustomEvent.prototype = {
- initialize : function() {
- this.listeners = []
- },
-
- addListener : function(method) {
- this.listeners.push(method)
- },
-
- removeListener : function(method) {
- var foundIndexes = this._findListenerIndexes(method)
-
- for(var i = 0; i < foundIndexes.length; i++) {
- this.listeners.splice(foundIndexes[i], 1)
- }
- },
-
- dispatch : function(handler) {
- for(var i = 0; i < this.listeners.length; i++) {
- try {
- this.listeners[i](handler)
- }
- catch (e) {
- alert("Could not run the listener " + this.listeners[i] + ". " + e)
- }
- }
- },
-
- // Private Methods
- // ---------------
- _findListenerIndexes : function(method) {
- var indexes = []
- for(var i = 0; i < this.listeners.length; i++) {
- if (this.listeners[i] == method) {
- indexes.push(i)
- }
- }
-
- return indexes
- }
-}
-
-// ------
-// Cookie
-// ------
-
-var Cookie = {
- set : function(name, value, expirationInDays, path) {
- var cookie = escape(name) + "=" + escape(value)
-
- if (expirationInDays) {
- var date = new Date()
- date.setDate(date.getDate() + expirationInDays)
- cookie += "; expires=" + date.toGMTString()
- }
-
- if (path) {
- cookie += ";path=" + path
- }
-
- document.cookie = cookie
-
- if (value && (expirationInDays == undefined || expirationInDays > 0) && !this.get(name)) {
- Logger.error("Cookie (" + name + ") was not set correctly... The value was " + value.toString().length + " charachters long (This may be over the cookie limit)");
- }
- },
-
- get : function(name) {
- var pattern = "(^|;)\\s*" + escape(name) + "=([^;]+)"
-
- var m = document.cookie.match(pattern)
- if (m && m[2]) {
- return unescape(m[2])
- }
- else return null
- },
-
- getAll : function() {
- var cookies = document.cookie.split(';')
- var cookieArray = []
-
- for (var i = 0; i < cookies.length; i++) {
- try {
- var name = unescape(cookies[i].match(/^\s*([^=]+)/m)[1])
- var value = unescape(cookies[i].match(/=(.*$)/m)[1])
- }
- catch (e) {
- continue
- }
-
- cookieArray.push({name : name, value : value})
-
- if (cookieArray[name] != undefined) {
- Logger.waring("Trying to retrieve cookie named(" + name + "). There appears to be another property with this name though.");
- }
-
- cookieArray[name] = value
- }
-
- return cookieArray
- },
-
- clear : function(name) {
- this.set(name, "", -1)
- },
-
- clearAll : function() {
- var cookies = this.getAll()
-
- for(var i = 0; i < cookies.length; i++) {
- this.clear(cookies[i].name)
- }
-
- }
-}
-
-// ------
-// Logger
-// -----
-
-Logger = {
- logEntries : [],
-
- onupdate : new CustomEvent(),
- onclear : new CustomEvent(),
-
-
- // Logger output
- log : function(message, tag) {
- var logEntry = new LogEntry(message, tag || "info")
- this.logEntries.push(logEntry)
- this.onupdate.dispatch(logEntry)
- },
-
- info : function(message) {
- this.log(message, 'info')
- if(typeof(console) != "undefined")
- console.info(message);
- },
-
- debug : function(message) {
- this.log(message, 'debug')
- if(typeof(console) != "undefined")
- console.debug(message);
- },
-
- warn : function(message) {
- this.log(message, 'warning')
- if(typeof(console) != "undefined")
- console.warn(message);
- },
-
- error : function(message, error) {
- this.log(message + ": \n" + error, 'error')
- if(typeof(console) != "undefined")
- console.error(message);
-
- },
-
- clear : function () {
- this.logEntries = []
- this.onclear.dispatch()
- }
-}
-
-LogEntry = Class.create()
-LogEntry.prototype = {
- initialize : function(message, tag) {
- this.message = message
- this.tag = tag
- }
-}
-
-LogConsole = Class.create()
-LogConsole.prototype = {
-
- // Properties
- // ----------
- commandHistory : [],
- commandIndex : 0,
-
- hidden : true,
-
- // Methods
- // -------
-
- initialize : function(toggleKey) {
- this.outputCount = 0
- this.tagPattern = Cookie.get('tagPattern') || ".*"
-
- // I hate writing javascript in HTML... but what's a better alternative
- this.logElement = document.createElement('div')
- document.body.appendChild(this.logElement)
- Element.hide(this.logElement)
-
- this.logElement.style.position = "absolute"
- this.logElement.style.left = '0px'
- this.logElement.style.width = '100%'
-
- this.logElement.style.textAlign = "left"
- this.logElement.style.fontFamily = "lucida console"
- this.logElement.style.fontSize = "100%"
- this.logElement.style.backgroundColor = 'darkgray'
- this.logElement.style.opacity = 0.9
- this.logElement.style.zIndex = 2000
-
- // Add toolbarElement
- this.toolbarElement = document.createElement('div')
- this.logElement.appendChild(this.toolbarElement)
- this.toolbarElement.style.padding = "0 0 0 2px"
-
- // Add buttons
- this.buttonsContainerElement = document.createElement('span')
- this.toolbarElement.appendChild(this.buttonsContainerElement)
-
- this.buttonsContainerElement.innerHTML += '<button onclick="logConsole.toggle()" style="float:right;color:black">close</button>'
- this.buttonsContainerElement.innerHTML += '<button onclick="Logger.clear()" style="float:right;color:black">clear</button>'
- if(!Prado.Inspector.disabled)
- this.buttonsContainerElement.innerHTML += '<button onclick="Prado.Inspector.inspect()" style="float:right;color:black; margin-right:15px;">Object Tree</button>'
-
-
- //Add Tag Filter
- this.tagFilterContainerElement = document.createElement('span')
- this.toolbarElement.appendChild(this.tagFilterContainerElement)
- this.tagFilterContainerElement.style.cssFloat = 'left'
- this.tagFilterContainerElement.appendChild(document.createTextNode("Log Filter"))
-
- this.tagFilterElement = document.createElement('input')
- this.tagFilterContainerElement.appendChild(this.tagFilterElement)
- this.tagFilterElement.style.width = '200px'
- this.tagFilterElement.value = this.tagPattern
- this.tagFilterElement.setAttribute('autocomplete', 'off') // So Firefox doesn't flip out
-
- Event.observe(this.tagFilterElement, 'keyup', this.updateTags.bind(this))
- Event.observe(this.tagFilterElement, 'click', function() {this.tagFilterElement.select()}.bind(this))
-
- // Add outputElement
- this.outputElement = document.createElement('div')
- this.logElement.appendChild(this.outputElement)
- this.outputElement.style.overflow = "auto"
- this.outputElement.style.clear = "both"
- this.outputElement.style.height = "200px"
- this.outputElement.style.backgroundColor = 'black'
-
- this.inputContainerElement = document.createElement('div')
- this.inputContainerElement.style.width = "100%"
- this.logElement.appendChild(this.inputContainerElement)
-
- this.inputElement = document.createElement('input')
- this.inputContainerElement.appendChild(this.inputElement)
- this.inputElement.style.width = '100%'
- this.inputElement.style.borderWidth = '0px' // Inputs with 100% width always seem to be too large (I HATE THEM) they only work if the border, margin and padding are 0
- this.inputElement.style.margin = '0px'
- this.inputElement.style.padding = '0px'
- this.inputElement.value = 'Type command here'
- this.inputElement.setAttribute('autocomplete', 'off') // So Firefox doesn't flip out
-
- Event.observe(this.inputElement, 'keyup', this.handleInput.bind(this))
- Event.observe(this.inputElement, 'click', function() {this.inputElement.select()}.bind(this))
-
- if(document.all && !window.opera)
- {
- window.setInterval(this.repositionWindow.bind(this), 500)
- }
- else
- {
- this.logElement.style.position="fixed";
- this.logElement.style.bottom="0px";
- }
- var self=this;
- Event.observe(document, 'keydown', function(e)
- {
- if((e.altKey==true) && Event.keyCode(e) == toggleKey ) //Alt+J | Ctrl+J
- self.toggle();
- });
-
- // Listen to the logger....
- Logger.onupdate.addListener(this.logUpdate.bind(this))
- Logger.onclear.addListener(this.clear.bind(this))
-
- // Preload log element with the log entries that have been entered
- for (var i = 0; i < Logger.logEntries.length; i++) {
- this.logUpdate(Logger.logEntries[i])
- }
-
- // Feed all errors into the logger (For some unknown reason I can only get this to work
- // with an inline event declaration)
- Event.observe(window, 'error', function(msg, url, lineNumber) {Logger.error("Error in (" + (url || location) + ") on line "+lineNumber+"", msg)})
-
- // Allow acess key link
- var accessElement = document.createElement('span')
- accessElement.innerHTML = '<button style="position:absolute;top:-100px" onclick="javascript:logConsole.toggle()" accesskey="d"></button>'
- document.body.appendChild(accessElement)
-
- if (Cookie.get('ConsoleVisible') == 'true') {
- this.toggle()
- }
- },
-
- toggle : function() {
- if (this.logElement.style.display == 'none') {
- this.show()
- }
- else {
- this.hide()
- }
- },
-
- show : function() {
- Element.show(this.logElement)
- this.outputElement.scrollTop = this.outputElement.scrollHeight // Scroll to bottom when toggled
- if(document.all && !window.opera)
- this.repositionWindow();
- Cookie.set('ConsoleVisible', 'true')
- this.inputElement.select()
- this.hidden = false;
- },
-
- hide : function() {
- this.hidden = true;
- Element.hide(this.logElement)
- Cookie.set('ConsoleVisible', 'false')
- },
-
- output : function(message, style) {
- // If we are at the bottom of the window, then keep scrolling with the output
- var shouldScroll = (this.outputElement.scrollTop + (2 * this.outputElement.clientHeight)) >= this.outputElement.scrollHeight
-
- this.outputCount++
- style = (style ? style += ';' : '')
- style += 'padding:1px;margin:0 0 5px 0'
-
- if (this.outputCount % 2 == 0) style += ";background-color:#101010"
-
- message = message || "undefined"
- message = message.toString().escapeHTML()
-
- this.outputElement.innerHTML += "<pre style='" + style + "'>" + message + "</pre>"
-
- if (shouldScroll) {
- this.outputElement.scrollTop = this.outputElement.scrollHeight
- }
- },
-
- updateTags : function() {
- var pattern = this.tagFilterElement.value
-
- if (this.tagPattern == pattern) return
-
- try {
- new RegExp(pattern)
- }
- catch (e) {
- return
- }
-
- this.tagPattern = pattern
- Cookie.set('tagPattern', this.tagPattern)
-
- this.outputElement.innerHTML = ""
-
- // Go through each log entry again
- this.outputCount = 0;
- for (var i = 0; i < Logger.logEntries.length; i++) {
- this.logUpdate(Logger.logEntries[i])
- }
- },
-
- repositionWindow : function() {
- var offset = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
- var pageHeight = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
- this.logElement.style.top = (offset + pageHeight - Element.getHeight(this.logElement)) + "px"
- },
-
- // Event Handlers
- // --------------
-
- logUpdate : function(logEntry) {
- if (logEntry.tag.search(new RegExp(this.tagPattern, 'igm')) == -1) return
- var style = ''
- if (logEntry.tag.search(/error/) != -1) style += 'color:red'
- else if (logEntry.tag.search(/warning/) != -1) style += 'color:orange'
- else if (logEntry.tag.search(/debug/) != -1) style += 'color:green'
- else if (logEntry.tag.search(/info/) != -1) style += 'color:white'
- else style += 'color:yellow'
-
- this.output(logEntry.message, style)
- },
-
- clear : function(e) {
- this.outputElement.innerHTML = ""
- },
-
- handleInput : function(e) {
- if (e.keyCode == Event.KEY_RETURN ) {
- var command = this.inputElement.value
-
- switch(command) {
- case "clear":
- Logger.clear()
- break
-
- default:
- var consoleOutput = ""
-
- try {
- consoleOutput = eval(this.inputElement.value)
- }
- catch (e) {
- Logger.error("Problem parsing input <" + command + ">", e)
- break
- }
-
- Logger.log(consoleOutput)
- break
- }
-
- if (this.inputElement.value != "" && this.inputElement.value != this.commandHistory[0]) {
- this.commandHistory.unshift(this.inputElement.value)
- }
-
- this.commandIndex = 0
- this.inputElement.value = ""
- }
- else if (e.keyCode == Event.KEY_UP && this.commandHistory.length > 0) {
- this.inputElement.value = this.commandHistory[this.commandIndex]
-
- if (this.commandIndex < this.commandHistory.length - 1) {
- this.commandIndex += 1
- }
- }
- else if (e.keyCode == Event.KEY_DOWN && this.commandHistory.length > 0) {
- if (this.commandIndex > 0) {
- this.commandIndex -= 1
- }
-
- this.inputElement.value = this.commandHistory[this.commandIndex]
- }
- else {
- this.commandIndex = 0
- }
- }
-}
-
-
-// -------------------------
-// Helper Functions And Junk
-// -------------------------
-function inspect(o)
-{
- var objtype = typeof(o);
- if (objtype == "undefined") {
- return "undefined";
- } else if (objtype == "number" || objtype == "boolean") {
- return o + "";
- } else if (o === null) {
- return "null";
- }
-
- try {
- var ostring = (o + "");
- } catch (e) {
- return "[" + typeof(o) + "]";
- }
-
- if (typeof(o) == "function")
- {
- o = ostring.replace(/^\s+/, "");
- var idx = o.indexOf("{");
- if (idx != -1) {
- o = o.substr(0, idx) + "{...}";
- }
- return o;
- }
-
- var reprString = function (o)
- {
- return ('"' + o.replace(/(["\\])/g, '\\$1') + '"'
- ).replace(/[\f]/g, "\\f"
- ).replace(/[\b]/g, "\\b"
- ).replace(/[\n]/g, "\\n"
- ).replace(/[\t]/g, "\\t"
- ).replace(/[\r]/g, "\\r");
- };
-
- if (objtype == "string") {
- return reprString(o);
- }
- // recurse
- var me = arguments.callee;
- // short-circuit for objects that support "json" serialization
- // if they return "self" then just pass-through...
- var newObj;
- if (typeof(o.__json__) == "function") {
- newObj = o.__json__();
- if (o !== newObj) {
- return me(newObj);
- }
- }
- if (typeof(o.json) == "function") {
- newObj = o.json();
- if (o !== newObj) {
- return me(newObj);
- }
- }
- // array
- if (objtype != "function" && typeof(o.length) == "number") {
- var res = [];
- for (var i = 0; i < o.length; i++) {
- var val = me(o[i]);
- if (typeof(val) != "string") {
- val = "undefined";
- }
- res.push(val);
- }
- return "[" + res.join(", ") + "]";
- }
-
- // generic object code path
- res = [];
- for (var k in o) {
- var useKey;
- if (typeof(k) == "number") {
- useKey = '"' + k + '"';
- } else if (typeof(k) == "string") {
- useKey = reprString(k);
- } else {
- // skip non-string or number keys
- continue;
- }
- val = me(o[k]);
- if (typeof(val) != "string") {
- // skip non-serializable values
- continue;
- }
- res.push(useKey + ":" + val);
- }
- return "{" + res.join(", ") + "}";
-}
-
-Array.prototype.contains = function(object) {
- for(var i = 0; i < this.length; i++) {
- if (object == this[i]) return true
- }
-
- return false
-}
-
-// Helper Alias for simple logging
-var puts = function() {return Logger.log(arguments[0], arguments[1])}
-
-/*************************************
-
- Javascript Object Tree
- version 1.0
- last revision:04.11.2004
- steve@slayeroffice.com
- http://slayeroffice.com
-
- (c)2004 S.G. Chipman
-
- Please notify me of any modifications
- you make to this code so that I can
- update the version hosted on slayeroffice.com
-
-
-************************************/
-if(typeof Prado == "undefined")
- var Prado = {};
-Prado.Inspector =
-{
- d : document,
- types : new Array(),
- objs : new Array(),
- hidden : new Array(),
- opera : window.opera,
- displaying : '',
- nameList : new Array(),
-
- format : function(str) {
- if(typeof(str) != "string") return str;
- str=str.replace(/</g,"&lt;");
- str=str.replace(/>/g,"&gt;");
- return str;
- },
-
- parseJS : function(obj) {
- var name;
- if(typeof obj == "string") { name = obj; obj = eval(obj); }
- win= typeof obj == 'undefined' ? window : obj;
- this.displaying = name ? name : win.toString();
- for(js in win) {
- try {
- if(win[js] && js.toString().indexOf("Inspector")==-1 && (win[js]+"").indexOf("[native code]")==-1) {
-
- t=typeof(win[js]);
- if(!this.objs[t.toString()]) {
- this.types[this.types.length]=t;
- this.objs[t]={};
- this.nameList[t] = new Array();
- }
- this.nameList[t].push(js);
- this.objs[t][js] = this.format(win[js]+"");
- }
- } catch(err) { }
- }
-
- for(i=0;i<this.types.length;i++)
- this.nameList[this.types[i]].sort();
- },
-
- show : function(objID) {
- this.d.getElementById(objID).style.display=this.hidden[objID]?"none":"block";
- this.hidden[objID]=this.hidden[objID]?0:1;
- },
-
- changeSpan : function(spanID) {
- if(this.d.getElementById(spanID).innerHTML.indexOf("+")>-1){
- this.d.getElementById(spanID).innerHTML="[-]";
- } else {
- this.d.getElementById(spanID).innerHTML="[+]";
- }
- },
-
- buildInspectionLevel : function()
- {
- var display = this.displaying;
- var list = display.split(".");
- var links = ["<a href=\"javascript:var_dump()\">[object Window]</a>"];
- var name = '';
- if(display.indexOf("[object ") >= 0) return links.join(".");
- for(var i = 0; i < list.length; i++)
- {
- name += (name.length ? "." : "") + list[i];
- links[i+1] = "<a href=\"javascript:var_dump('"+name+"')\">"+list[i]+"</a>";
- }
- return links.join(".");
- },
-
- buildTree : function() {
- mHTML = "<div>Inspecting "+this.buildInspectionLevel()+"</div>";
- mHTML +="<ul class=\"topLevel\">";
- this.types.sort();
- var so_objIndex=0;
- for(i=0;i<this.types.length;i++)
- {
- mHTML+="<li style=\"cursor:pointer;\" onclick=\"Prado.Inspector.show('ul"+i+"');Prado.Inspector.changeSpan('sp" + i + "')\"><span id=\"sp" + i + "\">[+]</span><b>" + this.types[i] + "</b> (" + this.nameList[this.types[i]].length + ")</li><ul style=\"display:none;\" id=\"ul"+i+"\">";
- this.hidden["ul"+i]=0;
- for(e=0;e<this.nameList[this.types[i]].length;e++)
- {
- var prop = this.nameList[this.types[i]][e];
- var value = this.objs[this.types[i]][prop]
- var more = "";
- if(value.indexOf("[object ") >= 0 && /^[a-zA-Z_]/.test(prop))
- {
- if(this.displaying.indexOf("[object ") < 0)
- more = " <a href=\"javascript:var_dump('"+this.displaying+"."+prop+"')\"><b>more</b></a>";
- else if(this.displaying.indexOf("[object Window]") >= 0)
- more = " <a href=\"javascript:var_dump('"+prop+"')\"><b>more</b></a>";
- }
- mHTML+="<li style=\"cursor:pointer;\" onclick=\"Prado.Inspector.show('mul" + so_objIndex + "');Prado.Inspector.changeSpan('sk" + so_objIndex + "')\"><span id=\"sk" + so_objIndex + "\">[+]</span>" + prop + "</li><ul id=\"mul" + so_objIndex + "\" style=\"display:none;\"><li style=\"list-style-type:none;\"><pre>" + value + more + "</pre></li></ul>";
- this.hidden["mul"+so_objIndex]=0;
- so_objIndex++;
- }
- mHTML+="</ul>";
- }
- mHTML+="</ul>";
- this.d.getElementById("so_mContainer").innerHTML =mHTML;
- },
-
- handleKeyEvent : function(e) {
- keyCode=document.all?window.event.keyCode:e.keyCode;
- if(keyCode==27) {
- this.cleanUp();
- }
- },
-
- cleanUp : function()
- {
- if(this.d.getElementById("so_mContainer"))
- {
- this.d.body.removeChild(this.d.getElementById("so_mContainer"));
- this.d.body.removeChild(this.d.getElementById("so_mStyle"));
- if(typeof Event != "undefined")
- Event.stopObserving(this.d, "keydown", this.dKeyDownEvent);
- this.types = new Array();
- this.objs = new Array();
- this.hidden = new Array();
- }
- },
-
- disabled : document.all && !this.opera,
-
- inspect : function(obj)
- {
- if(this.disabled)return alert("Sorry, this only works in Mozilla and Firefox currently.");
- this.cleanUp();
- mObj=this.d.body.appendChild(this.d.createElement("div"));
- mObj.id="so_mContainer";
- sObj=this.d.body.appendChild(this.d.createElement("style"));
- sObj.id="so_mStyle";
- sObj.type="text/css";
- sObj.innerHTML = this.style;
- this.dKeyDownEvent = this.handleKeyEvent.bind(this);
- if(typeof Event != "undefined")
- Event.observe(this.d, "keydown", this.dKeyDownEvent);
-
- this.parseJS(obj);
- this.buildTree();
-
- cObj=mObj.appendChild(this.d.createElement("div"));
- cObj.className="credits";
- cObj.innerHTML = "<b>[esc] to <a href=\"javascript:Prado.Inspector.cleanUp();\">close</a></b><br />Javascript Object Tree V2.0.";
-
- window.scrollTo(0,0);
- },
-
- style : "#so_mContainer { position:absolute; top:5px; left:5px; background-color:#E3EBED; text-align:left; font:9pt verdana; width:85%; border:2px solid #000; padding:5px; z-index:1000; color:#000; } " +
- "#so_mContainer ul { padding-left:20px; } " +
- "#so_mContainer ul li { display:block; list-style-type:none; list-style-image:url(); line-height:2em; -moz-border-radius:.75em; font:10px verdana; padding:0; margin:2px; color:#000; } " +
- "#so_mContainer li:hover { background-color:#E3EBED; } " +
- "#so_mContainer ul li span { position:relative; width:15px; height:15px; margin-right:4px; } " +
- "#so_mContainer pre { background-color:#F9FAFB; border:1px solid #638DA1; height:auto; padding:5px; font:9px verdana; color:#000; } " +
- "#so_mContainer .topLevel { margin:0; padding:0; } " +
- "#so_mContainer .credits { float:left; width:200px; font:6.5pt verdana; color:#000; padding:2px; margin-left:5px; text-align:left; border-top:1px solid #000; margin-top:15px; width:75%; } " +
- "#so_mContainer .credits a { font:9px verdana; font-weight:bold; color:#004465; text-decoration:none; background-color:transparent; }"
-}
-
-//similar function to var_dump in PHP, brings up the javascript object tree UI.
-function var_dump(obj)
-{
- Prado.Inspector.inspect(obj);
-}
-
-//similar function to print_r for PHP
-var print_r = inspect;
-