2function debug(text, reverse) {
3 if (debugWindow == null)
6 time = "-"; //new Date();
8 $('debug').innerHTML = time + " " + text + "<br>"+ $('debug').innerHTML;
9 debugWindow.getContent().scrollTop=0;
12 $('debug').innerHTML += time + " " + text + "<br>";
13 debugWindow.getContent().scrollTop=10000; // Far away
19 debugWindow.destroy();
24function showDebug(bShow) {
25 if (debugWindow == null) {
26 debugWindow = new Window('debug_window', {className: 'dialog',width:250, height:100, right:4, bottom:42, zIndex:1000, opacity:1, showEffect: Element.show, resizable: true, title: "Debug"})
27 debugWindow.getContent().innerHTML = "<style>#debug_window .dialog_content {background:#000;}</style> <div id='debug'></div>";
29 date.setMonth(date.getMonth()+3);
31 //debugWindow.setCookie(null, date);
33 if( typeof bShow == 'undefined' || bShow)debugWindow.show()
37function clearDebug() {
38 if (debugWindow == null)
40 $('debug').innerHTML = "";
44 * document.createElement convenience wrapper
46 * The data parameter is an object that must have the "tag" key, containing
47 * a string with the tagname of the element to create. It can optionally have
48 * a "children" key which can be: a string, "data" object, or an array of "data"
49 * objects to append to this element as children. Any other key is taken as an
50 * attribute to be applied to this tag.
52 * Available under an MIT license:
53 * http://www.opensource.org/licenses/mit-license.php
55 * @param {Object} data The data representing the element to create
56 * @return {Element} The element created.
60 if ('string'==typeof data) {
61 el=document.createTextNode(data);
64 el=document.createElement(data.tag);
68 if ('undefined'!=typeof data.children) {
69 if ('string'==typeof data.children ||'undefined'==typeof data.children.length) {
70 //strings and single elements
71 el.appendChild($E(data.children));
74 for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) {
75 el.appendChild($E(child));
78 delete(data.children);
81 //any other data is attributes
92 inspectOutput: function (container, within) {
93 within = within || debugWindow.getContent()
95 if (debugWindow == null)
98 within.appendChild(container)
101 inspect: function(object) {
102 var cont = $E({tag: "div", className: "inspector"})
103 Debug.inspectObj(object, cont)
104 debugWindow.getContent().appendChild(cont)
107 inspectObj: function (object, container) {
108 for (prop in object) {
109 Debug.inspectOutput(Debug.inspectable(object, prop), container)
113 inspectable: function(object, prop) {
114 cont = $E({tag: 'div', className: 'inspectable', children: [prop + " value: " + object[prop] ]})
115 cont.toInspect = object[prop]
116 Event.observe(cont, 'click', Debug.inspectClicked, false)
120 inspectClicked: function(e) {
121 Debug.inspectContained(Event.element(e))
125 inspectContained: function(container) {
126 if (container.opened) {
127 container.parentNode.removeChild(container.opened)
128 delete(container.opened)
130 sibling = container.parentNode.insertBefore($E({tag: "div", className: "child"}), container.nextSibling)
131 if (container.toInspect)
132 Debug.inspectObj(container.toInspect, sibling)
133 container.opened = sibling
137var inspect = Debug.inspect;