CustomEvent=Class.create();
CustomEvent.prototype={initialize:function(){
this.listeners=[];
},addListener:function(_1){
this.listeners.push(_1);
},removeListener:function(_2){
var _3=this._findListenerIndexes(_2);
for(var i=0;i<_3.length;i++){
this.listeners.splice(_3[i],1);
}
},dispatch:function(_5){
for(var i=0;i<this.listeners.length;i++){
try{
this.listeners[i](_5);
}
catch(e){
alert("Could not run the listener "+this.listeners[i]+". "+e);
}
}
},_findListenerIndexes:function(_7){
var _8=[];
for(var i=0;i<this.listeners.length;i++){
if(this.listeners[i]==_7){
_8.push(i);
}
}
return _8;
}};
var Cookie={set:function(_a,_b,_c,_d){
var _e=escape(_a)+"="+escape(_b);
if(_c){
var _f=new Date();
_f.setDate(_f.getDate()+_c);
_e+="; expires="+_f.toGMTString();
}
if(_d){
_e+=";path="+_d;
}
document.cookie=_e;
if(_b&&(_c==undefined||_c>0)&&!this.get(_a)){
Logger.error("Cookie ("+_a+") was not set correctly... The value was "+_b.toString().length+" charachters long (This may be over the cookie limit)");
}
},get:function(_10){
var _11="(^|;)\\s*"+escape(_10)+"=([^;]+)";
var m=document.cookie.match(_11);
if(m&&m[2]){
return unescape(m[2]);
}else{
return null;
}
},getAll:function(){
var _13=document.cookie.split(";");
var _14=[];
for(var i=0;i<_13.length;i++){
try{
var _16=unescape(_13[i].match(/^\s*([^=]+)/m)[1]);
var _17=unescape(_13[i].match(/=(.*$)/m)[1]);
}
catch(e){
continue;
}
_14.push({name:_16,value:_17});
if(_14[_16]!=undefined){
Logger.waring("Trying to retrieve cookie named("+_16+"). There appears to be another property with this name though.");
}
_14[_16]=_17;
}
return _14;
},clear:function(_18){
this.set(_18,"",-1);
},clearAll:function(){
var _19=this.getAll();
for(var i=0;i<_19.length;i++){
this.clear(_19[i].name);
}
}};
Logger={logEntries:[],onupdate:new CustomEvent(),onclear:new CustomEvent(),log:function(_1b,tag){
try{
if(logConsole.logElement.style.display!="none"){
var _1d=new LogEntry(new Date().print("%d/%m/%Y %H:%M:%S ")+_1b,tag||"info");
this.logEntries.push(_1d);
this.onupdate.dispatch(_1d);
}
}
catch(e){
var _1d=new LogEntry(new Date().print("%d/%m/%Y %H:%M:%S ")+_1b,tag||"info");
this.logEntries.push(_1d);
this.onupdate.dispatch(_1d);
}
},info:function(_1e){
this.log(_1e,"info");
},debug:function(_1f){
this.log(_1f,"debug");
},warn:function(_20){
this.log(_20,"warning");
},error:function(_21,_22){
this.log(_21+": \n"+_22,"error");
},clear:function(){
this.logEntries=[];
this.onclear.dispatch();
}};
LogEntry=Class.create();
LogEntry.prototype={initialize:function(_23,tag){
this.message=_23;
this.tag=tag;
}};
LogConsole=Class.create();
LogConsole.prototype={commandHistory:[],commandIndex:0,initialize:function(){
this.outputCount=0;
this.tagPattern=Cookie.get("tagPattern")||".*";
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;
this.toolbarElement=document.createElement("div");
this.logElement.appendChild(this.toolbarElement);
this.toolbarElement.style.padding="0 0 0 2px";
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>";
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");
Event.observe(this.tagFilterElement,"keyup",this.updateTags.bind(this));
Event.observe(this.tagFilterElement,"click",function(){
this.tagFilterElement.select();
}.bind(this));
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";
this.inputElement.style.margin="0px";
this.inputElement.style.padding="0px";
this.inputElement.value="Type command here";
this.inputElement.setAttribute("autocomplete","off");
Event.observe(this.inputElement,"keyup",this.handleInput.bind(this));
Event.observe(this.inputElement,"click",function(){
this.inputElement.select();
}.bind(this));
window.setInterval(this.repositionWindow.bind(this),500);
this.repositionWindow();
Logger.onupdate.addListener(this.logUpdate.bind(this));
Logger.onclear.addListener(this.clear.bind(this));
for(var i=0;i<Logger.logEntries.length;i++){
this.logUpdate(Logger.logEntries[i]);
}
Event.observe(window,"error",function(msg,url,_28){
Logger.error("Error in ("+(url||location)+") on line "+_28+"",msg);
});
var _29=document.createElement("span");
_29.innerHTML="<button style=\"position:absolute;top:-100px\" onclick=\"javascript:logConsole.toggle()\" accesskey=\"l\"></button>";
document.body.appendChild(_29);
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;
Cookie.set("ConsoleVisible","true");
this.inputElement.select();
},hide:function(){
Element.hide(this.logElement);
Cookie.set("ConsoleVisible","false");
},output:function(_2a,_2b){
var _2c=(this.outputElement.scrollTop+(2*this.outputElement.clientHeight))>=this.outputElement.scrollHeight;
this.outputCount++;
_2b=(_2b?_2b+=";":"");
_2b+="padding:1px;margin:0 0 5px 0";
if(this.outputCount%2==0){
_2b+=";background-color:#101010";
}
_2a=_2a||"undefined";
_2a=_2a.toString().escapeHTML();
this.outputElement.innerHTML+="<pre style='"+_2b+"'>"+_2a+"</pre>";
if(_2c){
this.outputElement.scrollTop=this.outputElement.scrollHeight;
}
},updateTags:function(){
var _2d=this.tagFilterElement.value;
if(this.tagPattern==_2d){
return;
}
try{
new RegExp(_2d);
}
catch(e){
return;
}
this.tagPattern=_2d;
Cookie.set("tagPattern",this.tagPattern);
this.outputElement.innerHTML="";
this.outputCount=0;
for(var i=0;i<Logger.logEntries.length;i++){
this.logUpdate(Logger.logEntries[i]);
}
},repositionWindow:function(){
var _2f=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop;
var _30=self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
this.logElement.style.top=(_2f+_30-Element.getHeight(this.logElement))+"px";
},logUpdate:function(_31){
if(_31.tag.search(new RegExp(this.tagPattern,"igm"))==-1){
return;
}
var _32="";
if(_31.tag.search(/error/)!=-1){
_32+="color:red";
}else{
if(_31.tag.search(/warning/)!=-1){
_32+="color:orange";
}else{
if(_31.tag.search(/debug/)!=-1){
_32+="color:green";
}else{
if(_31.tag.search(/info/)!=-1){
_32+="color:white";
}else{
_32+="color:yellow";
}
}
}
}
this.output(_31.message,_32);
},clear:function(e){
this.outputElement.innerHTML="";
},handleInput:function(e){
if(e.keyCode==Event.KEY_RETURN){
var _35=this.inputElement.value;
switch(_35){
case "clear":
Logger.clear();
break;
default:
var _36="";
try{
_36=eval(this.inputElement.value);
}
catch(e){
Logger.error("Problem parsing input <"+_35+">",e);
break;
}
Logger.log(_36);
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;
}
}
}
}};
var EviewBlanket=Class.create();
EviewBlanket.prototype={initialize:function(){
this.blanket=document.createElement("div");
document.body.appendChild(this.blanket);
Element.hide(this.blanket);
this.blanket.style.position="absolute";
this.blanket.style.left="0px";
this.blanket.style.top="0px";
this.blanket.style.width="100%";
this.blanket.style.height="100%";
this.blanket.style.backgroundColor="Transparent";
this.blanket.style.opacity=0.2;
this.blanket.style.zIndex=3000;
},toggle:function(){
if(this.blanket.style.display=="none"){
Element.show(this.blanket);
}else{
Element.hide(this.blanket);
}
},show:function(){
if(this.blanket.style.display=="none"){
Element.show(this.blanket);
}
},hide:function(){
if(this.blanket.style.display!="none"){
Element.hide(this.blanket);
}
}};
Event.observe(window,"load",function(){
logConsole=new LogConsole();
eviewBlanket=new EviewBlanket();
});
function inspect(_37,_38,_39){
var _3a=[];
var _3b=[];
_37=$(_37);
for(var _3c in _37){
try{
if(_37[_3c] instanceof Function){
if(!_39){
_3b.push(_3c+":\t"+_37[_3c]);
}
}else{
if(!_38){
_3a.push(_3c+":\t"+_37[_3c]);
}
}
}
catch(e){
Logger.error("Excetion thrown while inspecting object.",e);
}
}
_3a.sort();
_3b.sort();
var _3d=_3a.concat(_3b);
var _3e="";
for(var i=0;i<_3d.length;i++){
_3e+=(_3d[i]+"\n");
}
return _3e;
}
Array.prototype.contains=function(_40){
for(var i=0;i<this.length;i++){
if(_40==this[i]){
return true;
}
}
return false;
};
var puts=function(){
return Logger.log(arguments[0],arguments[1]);
};


