module.require("dragdrop");module.style("console");function ConsoleResize(){this.init("ConsoleTracer","__tracer_group");this.setHandleElId("console-resize");this.addInvalidHandleId("console-title");this.dragOnly=true}v8.console=function(){var I="1.4.0",J="console-action",E=[],H=0,F=["<div>Type /help for command list.</div>"],A=0,B=false,O=false,M=null,N=null;function D(){if(B){Event.removeListener(this.control,"keydown",K)}this.screenObj=this.control=null}function G(){var Q="";for(var R=A,P=F.length;R<P;R++){Q+=F[R]}v8.console.screenObj.innerHTML+=Q;A=F.length;setTimeout(C.delegate(v8.console),0)}function C(){this.screenObj.scrollTop=this.screenObj.scrollHeight}function K(U){var W="";switch(Event.getCharCode(U)){case 9:Event.stopEvent(U);W=this.control.value.trim();if(W=="/"){this.control.value="/"+JS.members(this.commandHelp)[0];return true}if(W.match(/\/[a-z]+$/)){W=W.substring(1);var V=new RegExp("^"+W);var S=false;for(cmd in this.commandHelp){if(cmd==W){S=true;continue}if(S||cmd.match(V)){this.control.value="/"+cmd;return true}}}audio.play("fail");break;case 33:this.screenObj.scrollTop-=this.screenObj.clientHeight;break;case 34:this.screenObj.scrollTop+=this.screenObj.clientHeight;break;case 35:if(!U.ctrlKey){return true}this.screenObj.scrollTop=this.screenObj.scrollHeight;break;case 36:if(!U.altKey){return true}this.screenObj.scrollTop=0;break;case 38:if(U.shiftKey){return true}if(U.ctrlKey){this.screenObj.scrollTop-=12}else{if(H>0){this.control.value=E[--H]}}break;case 40:if(U.shiftKey){return true}if(U.ctrlKey){this.screenObj.scrollTop+=12}else{if(H<E.length-1){this.control.value=E[++H]}}break;case 13:if(U.ctrlKey){this.control.value+=String.fromCharCode(10);return true}W=this.control.value.trim();if(!W.length){return true}if(!E.length||E[E.length-1]!=W){E.push(W);var Q=E.length-10;if(Q<0){Q=0}if(storage.available){storage.put("v8.console.history",JSON.stringify(E.slice(Q,E.length)))}}H=E.length;if(W.substring(0,1)=="/"){var P="";var T=W.indexOf(String.fromCharCode(32));if(T!=-1){P=W.substr(T+1);W=W.substring(1,T)}else{W=W.substr(1)}W=W.toLowerCase();if(this.commands[W]){if(!this.commands[W].call(this,P)){return true}}else{F.push('<span class="error">Unsupported command</span>');audio.play("fail")}}else{this.trace("&gt; "+W);if(this.sql){this.commands.query.call(this,[W])}else{try{this.trace(runCode(W));this.control.value="";return true}catch(R){F.push('<span class="error">'+R.name+" &ndash; "+R.message+"</span>");audio.play("fail")}}}this.control.value="";if(A<F.length){G.call(this)}break;default:return true}Event.stopEvent(U);return false}function L(){var Q=$("ConsoleTracer"),P={width:Q.offsetWidth,height:v8.console.screenObj.offsetHeight,left:Q.offsetLeft,top:Q.offsetTop};storage.put("v8.console.pos",JSON.stringify(P))}return{log:false,sql:false,screenObj:null,control:null,commands:{},commandHelp:{},buffer:function(P){F.push(P)},bufferClear:function(){F=[];A=0},flush:function(){G()},getCommands:function(){return this.commandHelp},trace:function(P){switch(typeof (P)){case"string":if(P.length){F.push("<div>"+P+"</div>")}else{F.push("<div>[ empty string ]</div>")}break;case"number":F.push('<div style="font-weight:bold;color:#66F;">'+P+"</div>");break;case"boolean":if(P){F.push('<div style="font-weight:bold;color:green;">'+P.toString().toUpperCase()+"</div>")}else{F.push('<div style="font-weight:bold;color:red;">'+P.toString().toUpperCase()+"</div>")}break;case"function":F.push('<div style="font-weight:bold;color:lightblue">Function</div>');break;case"object":if(Array.prototype.isPrototypeOf(P)){F.push('<div style="font-weight:bold;color:orange">['+P+"]</div>")}else{if(Date.prototype.isPrototypeOf(P)){F.push('<div style="font-weight:bold;color:orange">'+P+"</div>")}else{if(P===null){F.push('<div style="font-weight:bold;color:gray">NULL</div>')}else{F.push('<div style="font-weight:bold;color:orange">Object</div>')}}}break;default:F.push('<div style="color:gray">'+typeof (P)+"</div>")}if(B){G.call(this)}},toggle:function(){if(!$("ConsoleTracer")){JS.extend(ConsoleResize,DragDrop);ConsoleResize.prototype.onMouseDown=function(X){this.startWidth=this.getEl().offsetWidth;this.startHeight=v8.console.screenObj.offsetHeight;this.startPos=[Event.getPageX(X),Event.getPageY(X)]};ConsoleResize.prototype.onDrag=function(a){var Y=[Event.getPageX(a),Event.getPageY(a)];var Z=this.startWidth+Y[0]-this.startPos[0];if(Z<280){Z=280}var X=this.startHeight+Y[1]-this.startPos[1];if(X<10){X=10}this.getEl().style.width=Z+"px";v8.console.screenObj.style.height=X+"px"};var U=document.createElement("div");U.id="ConsoleTracer";if(Env.legacy){U.style.position="absolute";dom.setXY(U,[10,10])}var T=document.createElement("div");T.id="console-title";T.setAttribute("UNSELECTABLE","on");T.innerHTML="v8.Console v"+I;var P=document.createElement("div");P.id="console-work";this.screenObj=document.createElement("div");this.screenObj.className="screen";var S=document.createElement("div");S.className="btm";this.control=document.createElement("textarea");this.control.name="debugInp";this.control.rows="3";this.control.cols="10";this.control.spellcheck=false;var R=document.createElement("img");R.id="console-resize";R.src="images/resize.png";R.alt="Drag to resize";if(Env.ie){R.setAttribute("UNSELECTABLE","on")}document.body.appendChild(U);U.appendChild(T);U.appendChild(P);U.appendChild(this.screenObj);S.appendChild(this.control);U.appendChild(S);U.appendChild(R);if(storage.available&&storage.hasKey("v8.console.history")){try{var V=storage.get("v8.console.history");if(V){V=JSON.parse(V);if(JS.isArray(V)){E=V;H=E.length}}}catch(W){F.push('<span class="error">An error occured while trying to restore Console history.</span>')}}if(storage.available&&storage.hasKey("v8.console.pos")){var Q=JSON.parse(storage.get("v8.console.pos"));U.style.width=Q.width+"px";U.style.top=Q.top+"px";U.style.left=Q.left+"px";this.screenObj.style.height=Q.height+"px"}else{U.style.width=(dom.getViewportWidth()-50)+"px"}N=new ConsoleResize();M=new DDProxy("ConsoleTracer","__tracer_group",{dragOnly:true});M.setHandleElId("console-title");M.addInvalidHandleId("console-resize");if(storage.available){N.endDrag=L;M.endDragAfter=L}Event.on(window,"unload",D,this,true)}else{dom[B?"hide":"show"]("ConsoleTracer")}B=!B;if(B){Event.on(this.control,"keydown",K,this,true)}else{A=0;H=E.length;this.screenObj.innerHTML="";Event.removeListener(this.control,"keydown",K);return }this.control.focus();G.call(this)},query:function(P){ajax.load("console.cfm?action=query&sql="+P.urlEncoded(),J,"Executing query.")},display:function(){if(!B){this.toggle()}}}}();function trace(C){var A=arguments.length;if(A>1){for(var B=0;B<A;B++){trace(arguments[B])}return }v8.console.trace.call(v8.console,C);if(window.console&&console.log){console.log(C)}}app.debug=true;v8.console.debugXML=function(A){if(!A.match(/[<]pre/)){A+='<br/><textarea style="background-color:light-yellow" rows="10" cols="150">'+A.replace(/>/g,">"+String.fromCharCode(13))+"</textarea>"}modal.open({id:"xml-error",allowClose:true,contents:modal.header+A+modal.footer})};v8.console.debugJSON=function(B,A){if(!A.match(/[<]pre/)){A+='<br/><textarea style="background-color:light-yellow" rows="10" cols="150">'+A+"</textarea>"}modal.open({id:"json-error",allowClose:true,contents:modal.header+'<h1 style="color:red">'+B.message+"</h1><br/>"+A+modal.footer})};v8.console.xmlQuery=function(A){ajax.queue(this.xmlQueryHnd,"xmlQuery-Act",this);ajax.post("sql="+encodeURIComponent(A));ajax.loadXML("console.cfm?action=xmpQuery","xmlQuery-Act");this.buffer('<span class="work">Executing query statement. Please wait&#8230;</span>');this.flush();dom.show("console-work")};v8.console.xmlQueryHnd=function(){var B=ajax.getXML("xmlQuery-Act");var C=B.selectSingleNode("result");var A="";A+='<div class="area"><em style="color:yellow">Execution time: ';A+=C.getAttribute("ExecutionTime");A+=" ms</em><br/>";A+='Query: <em style="color:#69f">';A+=dom.xmlText(B.selectSingleNode("query"));A+="</em>";A+=dom.xmlText(C);A+="</div>";this.buffer(A);this.flush();dom.hide("console-work")};v8.console.commandHelp.about=["/about","information about this widget"];v8.console.commands.about=function(){this.buffer('<div class="area">Designed and developed by Apostolos Tsakpinis<br/>zDimensions G.P.<br/>http://www.zdimensions.gr<br/><br/>Copyright &copy; 2006 zDimensions. All rights reserved</div>');return true};v8.console.commandHelp.benchmark=["/benchmark [CODE]","Benchmarks supplied code."];v8.console.commands.benchmark=function(A){if(!A.length){this.buffer('<em class="error">Missing code fragment to benchmark!</em>');this.flush();audio.play("fail");return false}dom.show("console-work");function B(){this.buffer('<span class="work">Benchmark begun. Please wait&#8230;</span>');this.flush();setTimeout(this.commands.benchmarkRun.delegate(this,[A]),0)}if(!module.loaded("benchmark")){this.buffer('<span class="work">Loading V8.Benchmark module. Please wait&#8230;</span>');this.flush();module.load("benchmark",B.delegate(this))}else{B.call(this)}return true};v8.console.commands.benchmarkObj=null;v8.console.commands.benchmarkRun=function(A){try{Bench.start("ConsoleBench");runCode(A);Bench.stop("ConsoleBench")}catch(B){this.buffer('<span class="error">'+B.message+"</span>");this.flush();audio.play("fail");dom.hide("console-work");return }if(Bench.getElapsed("ConsoleBench")>2000){audio.play("success")}dom.hide("console-work");Bench.show("ConsoleBench")};v8.console.commandHelp.bottom=["/bottom","scrolls to the bottom"];v8.console.commands.bottom=function(){this.screenObj.scrollTop=this.screenObj.scrollHeight;return true};v8.console.commandHelp.clear=["/clear","Clears the console buffer."];v8.console.commands.clear=function(){this.bufferClear();this.screenObj.innerHTML="";this.control.value="";return false};v8.console.commandHelp.cfadmin=["/cfadmin","Launches coldfusion administrator."];v8.console.commands.cfadmin=function(){try{var B=window.open("/CFIDE/administrator/")}catch(A){this.buffer('<span class="error">Please add '+document.location.host+" to you list of allowed sites.</span>");this.flush();audio.play("fail");return false}return true};v8.console.commandHelp.def=["/def [PROC|FUNC|TABLE|TRIGGER] [objectName]","Displays definition of given procedure, function, table, or table triggers."];v8.console.commands.def=function(A){if(!A.length){this.buffer('<span class="error">Missing or invalid argument [object type]</span>');this.flush();audio.play("fail");return false}var B=A.split(" ");if(B.length<2){this.buffer('<span class="error">Missing or invalid argument [object name]</span>');this.flush();audio.play("fail");return false}switch(B[0].toLowerCase()){case"func":case"proc":this.xmlQuery("EXEC dbo.sp_sproc_columns "+B[1]);break;case"table":this.xmlQuery("EXEC dbo.sp_columns "+B[1]);break;case"trigger":this.xmlQuery("EXEC dbo.sp_helptrigger "+B[1]);break;default:this.buffer('<span class="error">Unsupported argument '+B[0]+"</span>");this.flush();audio.play("fail");return false}return true};v8.console.commandHelp.dev=["/dev","Jumps to developer module page."];v8.console.commands.dev=function(){nav("dev.cfm");return false};v8.console.commandHelp.edit=["/edit [objName]","Downloads the source code of a procedure or function to the computer."];v8.console.commands.edit=function(B){if(!B.length){this.buffer('<em class="error">Missing object name argument!</em>');this.flush();audio.play("fail");return false}var A=["action=dbSource","mode=edit","name="+B];this.buffer('<span class="work">Retrieving source code for '+B+". Please wait&#8230;</span>");this.flush();document.location="console.cfm?"+A.join("&");return true};v8.console.commandHelp.eval=["/eval","Runs Coldfusion evaluate() function on passed string."];v8.console.commands.eval=function(A){if(A.length){dom.show("console-work");ajax.queue(this.commands.evalHnd,"cfeval",this);ajax.loadJSON("console.cfm?action=cfeval&str="+encodeURIComponent(A),"cfeval");this.buffer('<span class="work">Evaluating coldfusion statement. Please wait&#8230;</span>')}else{this.buffer('<span class="error">Missing evaluation string argument!</span>');this.flush();audio.play("fail");return false}return true};v8.console.commands.evalHnd=function(){dom.hide("console-work");this.trace(ajax.getJSON("cfeval").result)};v8.console.commandHelp.exit=["/exit","Closes console."];v8.console.commands.exit=function(){this.toggle();return false};v8.console.commands.quit=v8.console.commands.exit;v8.console.commandHelp.help=["/help","Displays this help message."];v8.console.commands.help=function(){var B='<div class="area"><strong style="color:orange">SUPPORTED COMMANDS</strong>',C=null,A=this.getCommands();for(C in A){B+='<br/><strong style="color:#69f">'+A[C][0]+"</strong> : "+A[C][1]}B+="</div>";this.buffer(B);return true};v8.console.commandHelp.info=["/info","Displays information about the browser."];v8.console.commands.info=function(){var A='<div class="area">';A+='<em style="color:#69f;">Navigator:</em> '+window.navigator.appName;A+='<br/><em style="color:#69f;">Navigator UserAgent:</em> '+window.navigator.userAgent;A+='<br/><em style="color:#69f;">Navigator Minor:</em> '+window.navigator.appMinorVersion;A+='<br/><em style="color:#69f;">Platform:</em> '+window.navigator.platform;A+='<br/><em style="color:#69f;">Cookies:</em> '+window.navigator.cookieEnabled;A+='<br/><em style="color:#69f;">compatMode:</em> '+document.compatMode;A+='<br/><em style="color:#69f;">hostName:</em> '+document.location.hostname;A+='<br/><em style="color:#69f;">URL:</em> '+document.URL;A+='<br/><em style="color:#69f;">protocol:</em> '+document.location.protocol;A+='<br/><em style="color:#69f;">domain:</em> '+document.domain;A+='<br/><em style="color:#69f;">pathName:</em> '+document.location.pathname;A+='<br/><em style="color:#69f;">search:</em> '+document.location.search;A+='<br/><em style="color:#69f;">referrer:</em> '+document.referrer;A+='<br/><em style="color:#69f;">lastModified:</em> '+document.lastModified;A+="</div>";this.buffer(A);return true};v8.console.commandHelp.lang=["/lang","Builds language files (cfm & js from xml)."];v8.console.commands.lang=function(){ajax.queue(this.commands.langHnd,"v8-lang",this);ajax.loadJSON("dev.cfm?action=rebuildLang","v8-lang");this.buffer('<em class="work">Building language files from xml configuration files. Please wait&#8230;</em>');dom.show("console-work");return true};v8.console.commands.langHnd=function(){var A=ajax.getJSON("v8-lang");if(A.flag>1){audio.play("error");this.buffer('<span class="error">'+A.msg+"</span>")}else{audio.play("success");this.buffer(A.msg)}this.flush();dom.hide("console-work")};v8.console.commandHelp.list=["/list [PROC|FUNC|TABLE] [objectName]","Displays a list of procedures or tables based on the preffix if given."];v8.console.commands.list=function(A){var B=A.split(" ");if(B.length<2){this.buffer('<span class="error">Missing object type or name argument!</span>');this.flush();audio.play("fail");return false}switch(B[0].toLowerCase()){case"func":this.commands.listDb("func",B[1]);break;case"proc":this.commands.listDb("proc",B[1]);break;case"table":this.commands.listDb("table",B[1]);break;default:this.buffer('<span class="error">Listing '+B[0]+" is not supported.</span>");this.flush();audio.play("fail");return false}return true};v8.console.commands.listDb=function(B,C){dom.show("console-work");var A=["action=dbList","type="+B,"name="+C];ajax.queue(v8.console.commands.listDbHnd,"list-db",v8.console);ajax.loadJSON("console.cfm?"+A.join("&"),"list-db");v8.console.buffer('<span class="work">Querying for '+C+". Please wait&#8230;</span>");v8.console.flush()};v8.console.commands.listDbHnd=function(){this.buffer('<div class="area">'+ajax.getJSON("list-db").result+"</div>");this.flush();dom.hide("console-work")};v8.console.commandHelp.members=["/members [JS Object]","Outputs a list of object members ( variables and functions )."];v8.console.commands.members=function(D){if(!D.length){this.buffer('<span class="error">Please provide object name</span>');this.flush();audio.play("fail");return false}var C=null;try{C=runCode(D.trim())}catch(G){}if(!C){this.buffer('<span class="error">'+D+" is not an object.</span>");this.flush();audio.play("fail");return false}if(window.console&&window.console.dir){console.group(D);console.dir(C);console.groupEnd()}var F=JS.members(C);if(!F.length){this.buffer('<span class="work">'+D+" has no members.</span>");this.flush();audio.play("info");return false}F.sort();var B=F.length,A;this.buffer('<pre style="font-size:10px">');for(var E=0;E<B;A=F[E++]){switch(typeof (C[A])){case"string":this.buffer('<em style="color:#9f9">&lt;String&gt;</em>');break;case"number":this.buffer('<em style="color:#f99">&lt;Number&gt;</em>');break;case"boolean":this.buffer('<em style="color:#f9f">&lt;Boolean&gt;</em>');break;case"function":this.buffer('<em style="color:#99f;font-weight:bold">&lt;Function&gt;</em>');break;case"object":if(JS.isArray(C[A])){this.buffer('<em style="color:yellow;font-weight:bold">&lt;Array&gt;</em>'+String.fromCharCode(9))}else{if(C[A]===null){this.buffer('<em style="color:red">null</em>'+String.fromCharCode(9))}else{this.buffer('<em style="color:yellow;font-weight:bold">&lt;Object&gt;</em>')}}break;default:continue}this.buffer(String.fromCharCode(9)+A+String.fromCharCode(10))}this.buffer("</pre>");return true};v8.console.commandHelp.push=["/push [PROC|FUNC] [name]","Pushes proc/func changes to master server ( opposite of /upgrade )."];v8.console.commands.push=function(A){var B=A.split(" ");if(B.length<2){this.buffer('<span class="error">Missing object name argument! Must be one of proc,func</span>');this.flush();audio.play("fail");return false}switch(B[0].toLowerCase()){case"proc":this.commands.pushDb("proc",B[1]);break;case"func":this.commands.pushDb("func",B[1]);break;default:this.buffer('<span class="error">Pushing '+B[0]+" updates is not supported.</span>");this.flush();audio.play("fail");return false}return true};v8.console.commands.pushDb=function(B,C){dom.show("console-work");var A=["action=dbPush","type="+B,"name="+C];ajax.queue(v8.console.commands.pushDbHnd,"db-push",v8.console);ajax.loadJSON("console.cfm?"+A.join("&"),"db-push");v8.console.buffer('<span class="work">Uploading new version of '+C+". Please wait&#8230;</span>");v8.console.flush()};v8.console.commands.pushDbHnd=function(){var A=ajax.getJSON("db-push");audio.play(A.flag);this.buffer('<span class="'+A.flag+'">'+A.message+"</span>");this.flush();dom.hide("console-work")};v8.console.commandHelp.query=["/query [queryStr]","Runs and outputs 'queryStr' result set."];v8.console.commands.query=function(A){if(A.length){this.xmlQuery(A);return true}else{this.buffer('<span class="error">Missing query string argument!</span>');this.flush();audio.play("fail");return false}};v8.console.commandHelp.source=["/source [objName]","Displays stored procedure's or function's source code."];v8.console.commands.source=function(B){if(!B.length){this.buffer('<em class="error">Missing object name argument!</em>');this.flush();audio.play("fail");return false}dom.show("console-work");var A=["action=dbSource","name="+B];ajax.queue(this.commands.sourceHnd,"db-Source",this);ajax.loadJSON("console.cfm?"+A.join("&"),"db-Source");this.buffer('<span class="work">Retrieving source code for '+B+". Please wait&#8230;</span>");this.flush();return true};v8.console.commands.sourceHnd=function(){var A=ajax.getJSON("db-Source");if(A.success){this.buffer('<div class="area"><pre>'+A.source+"</pre></div>")}else{audio.play("error");this.buffer('<span class="error">'+A.message+"</span>")}this.flush();dom.hide("console-work")};v8.console.commandHelp.sql=["/sql","Toggles SQL mode on or off. Commands are interpreted as sql statements."];v8.console.commands.sql=function(){this.sql=!this.sql;this.buffer('<div><img src="images/bullet_'+(this.sql?"green":"red")+'.png" style="vertical-align:middle" /> SQL mode has been turned '+(this.sql?"on":"off")+"</div>");return true};v8.console.commandHelp.top=["/top","Scrolls to the top."];v8.console.commands.top=function(){this.screenObj.scrollTop=0;return true};v8.console.commandHelp.upgrade=["/upgrade [PROC|FUNC] [name]","Upgrades stored procedure or function from master server."];v8.console.commands.upgrade=function(A){var B=A.split(" ");if(B.length<2){this.buffer('<span class="error">Missing object name argument! Must be one of proc,func</span>');this.flush();audio.play("fail");return false}switch(B[0].toLowerCase()){case"proc":this.commands.upgradeDb("proc",B[1]);break;case"func":this.commands.upgradeDb("func",B[1]);break;default:this.buffer('<span class="error">Upgrading '+B[0]+" is not supported.</span>");this.flush();audio.play("fail");return false}return true};v8.console.commands.upgradeDb=function(B,C){dom.show("console-work");var A=["action=dbUpgrade","type="+B,"name="+C];ajax.queue(v8.console.commands.upgradeDbHnd,"db-Upgrade",v8.console);ajax.loadJSON("console.cfm?"+A.join("&"),"db-Upgrade");v8.console.buffer('<span class="work">Upgrading '+C+". Please wait&#8230;</span>");v8.console.flush()};v8.console.commands.upgradeDbHnd=function(){var A=ajax.getJSON("db-Upgrade");audio.play(A.flag);this.buffer('<span class="'+A.flag+'">'+A.message+"</span>");this.flush();dom.hide("console-work")};