v8.console=function(){var i="1.4.2",j="console-action",e=[],h=0,f=["<div>Type /help for command list.</div>"],a=0,b=false,m=false;function d(){if(b){Event.removeListener(this.control,"keydown",k)}this.screenObj=this.control=null}function g(){var o="";for(var p=a,n=f.length;p<n;p++){o+=f[p]}v8.console.screenObj.innerHTML+=o;a=f.length;setTimeout(c.delegate(v8.console),0)}function c(){this.screenObj.scrollTop=this.screenObj.scrollHeight}function k(s){var u="";switch(Event.getCharCode(s)){case 9:Event.stopEvent(s);u=this.control.value.trim();if(u=="/"){this.control.value="/"+JS.members(this.commandHelp)[0];return true}if(u.match(/\/[a-z]+$/)){u=u.substring(1);var t=new RegExp("^"+u);var q=false;for(cmd in this.commandHelp){if(cmd==u){q=true;continue}if(q||cmd.match(t)){this.control.value="/"+cmd;return true}}}break;case 33:this.screenObj.scrollTop-=this.screenObj.clientHeight;break;case 34:this.screenObj.scrollTop+=this.screenObj.clientHeight;break;case 35:if(!s.ctrlKey||!s.metaKey){return true}this.screenObj.scrollTop=this.screenObj.scrollHeight;break;case 36:if(!s.altKey){return true}this.screenObj.scrollTop=0;break;case 38:if(s.shiftKey){return true}if(s.ctrlKey||s.metaKey){this.screenObj.scrollTop-=12}else{if(h>0){this.control.value=e[--h]}}break;case 40:if(s.shiftKey){return true}if(s.ctrlKey||s.metaKey){this.screenObj.scrollTop+=12}else{if(h<e.length-1){this.control.value=e[++h]}}break;case 13:if(s.ctrlKey||s.metaKey){this.control.value+=String.fromCharCode(10);return true}u=this.control.value.trim();if(!u.length){Event.stopEvent(s);return false}if(!e.length||e[e.length-1]!=u){e.push(u);var o=e.length-10;if(o<0){o=0}storage.put("v8.console.history",JSON.stringify(e.slice(o,e.length)))}h=e.length;if(u.substring(0,1)=="/"){var n="",r=u.indexOf(String.fromCharCode(32));if(r!=-1){n=u.substr(r+1);u=u.substring(1,r)}else{u=u.substr(1)}u=u.toLowerCase();if(this.commands[u]){if(!this.commands[u].call(this,n)){Event.stopEvent(s);return false}}else{f.push('<span class="error">Unsupported command</span>')}}else{Event.stopEvent(s);this.trace("&gt; "+u);if(this.sql){this.commands.query.call(this,[u])}else{try{this.trace(JS.eval(u))}catch(p){f.push('<span class="error">'+p.name+" &ndash; "+p.message+"</span>")}}}this.control.value="";if(a<f.length){g.call(this)}break;default:return true}Event.stopEvent(s);return false}function l(){var o=$("ConsoleTracer"),n={width:o.offsetWidth,height:v8.console.screenObj.offsetHeight,left:o.offsetLeft,top:o.offsetTop};storage.put("v8.console.pos",JSON.stringify(n))}return{log:false,sql:false,screenObj:null,control:null,commands:{},commandHelp:{},buffer:function(n){f.push(n)},bufferClear:function(){f=[];a=0},flush:function(){if(b){g()}},getCommands:function(){return this.commandHelp},trace:function(n){switch(typeof(n)){case"string":if(n.length){f.push("<div>"+n+"</div>")}else{f.push("<div>[ empty string ]</div>")}break;case"number":f.push('<div style="font-weight:bold;color:#66F;">'+n+"</div>");break;case"boolean":if(n){f.push('<div style="font-weight:bold;color:green;">'+n.toString().toUpperCase()+"</div>")}else{f.push('<div style="font-weight:bold;color:red;">'+n.toString().toUpperCase()+"</div>")}break;case"function":f.push('<div style="font-weight:bold;color:lightblue">Function</div>');break;case"object":if(Array.prototype.isPrototypeOf(n)){f.push('<div style="font-weight:bold;color:orange">['+n+"]</div>")}else{if(Date.prototype.isPrototypeOf(n)){f.push('<div style="font-weight:bold;color:orange">'+n+"</div>")}else{if(n===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(n)+"</div>")}if(b){g.call(this)}},toggle:function(){if(!$("ConsoleTracer")){module.style("console");if(!module.loaded("dragdrop")){module.load("dragdrop",arguments.callee.delegate(this));return}var q=document.createElement("div");q.id="ConsoleTracer";if(Env.legacy){q.style.position="absolute";dom.setXY(q,[10,10])}var p=document.createElement("div");p.id="console-title";p.setAttribute("UNSELECTABLE","on");p.innerHTML="v8.Console v"+i;var n=document.createElement("div");n.id="console-work";this.screenObj=document.createElement("div");this.screenObj.className="screen";var o=document.createElement("div");o.className="btm";this.control=document.createElement("textarea");this.control.name="debugInp";this.control.rows="3";this.control.cols="10";this.control.spellcheck=false;document.body.appendChild(q);q.appendChild(p);q.appendChild(n);q.appendChild(this.screenObj);o.appendChild(this.control);q.appendChild(o);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(n){ajax.load("console.cfm?action=query&sql="+n.urlEncoded(),j,"Executing query.")},display:function(){if(!b){this.toggle()}},hide: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(){var a=["Designed and developed by Apostolos Tsakpinis.","Licensed under the MIT license.","http://www.zdimensions.gr/","","Copyright &copy; 2009 zDimensions. All rights reserved."];this.buffer('<div class="area">'+a.join("<br>")+"</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();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(args){try{Bench.start("ConsoleBench");JS.eval(args);Bench.stop("ConsoleBench")}catch(e){this.buffer('<span class="error">'+e.message+"</span>");this.flush();dom.hide("console-work");return}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();return false}return true};v8.console.commandHelp.css=["/css","Reloads external CSS files. Use this to test CSS changes without reloading the page."];v8.console.commands.css=function(){this.buffer('<span class="info">Resetting Cascading Style Sheets</span>');for(var d=0,c=document.getElementsByTagName("link"),a=c.length;d<a;d++){var e=c[d];if(~e.rel.toLowerCase().indexOf("stylesheet")&&e.href){var b=e.href.replace(/(&|%5C?)forceReload=\d+/,"");e.href=b+(b.indexOf("?")>=0?"&":"?")+"forceReload="+(new Date().valueOf())}}this.hide();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();return false}var b=a.split(" ");if(b.length<2){this.buffer('<span class="error">Missing or invalid argument [object name]</span>');this.flush();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();return false}return true};v8.console.commandHelp.dev=["/dev","Jumps to developer module page."];v8.console.commands.dev=function(){v8.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();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.callback(a),"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();return false}return true};v8.console.commands.evalHnd=function(b){dom.hide("console-work");var a=ajax.getJSON("cfeval").result;if(typeof a!="string"&&window.console&&window.console.dir){this.trace(a.toString());console.group(b);console.dir(a);console.groupEnd()}else{this.trace(a)}};v8.console.commandHelp.exit=["/exit","Closes console."];v8.console.commands.exit=function(){this.hide();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>',d=null,a=this.getCommands();for(d in a){b+='<br/><strong style="color:#69f">'+a[d][0]+"</strong> : "+a[d][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;">window.navigator.appName:</em> '+window.navigator.appName;a+='<br/><em style="color:#69f;">window.navigator.userAgent:</em> '+window.navigator.userAgent;a+='<br/><em style="color:#69f;">window.navigator.appMinorVersion:</em> '+window.navigator.appMinorVersion;a+='<br/><em style="color:#69f;">window.navigator.platform:</em> '+window.navigator.platform;a+='<br/><em style="color:#69f;">window.navigator.cookieEnabled:</em> '+window.navigator.cookieEnabled;a+='<br/><em style="color:#69f;">document.location.hostname:</em> '+document.location.hostname;a+='<br/><em style="color:#69f;">document.location.protocol:</em> '+document.location.protocol;a+='<br/><em style="color:#69f;">document.location.pathname:</em> '+document.location.pathname;a+='<br/><em style="color:#69f;">document.location.search:</em> '+document.location.search;a+='<br/><em style="color:#69f;">document.compatMode:</em> '+document.compatMode;a+='<br/><em style="color:#69f;">document.domain:</em> '+document.domain;a+='<br/><em style="color:#69f;">document.referrer:</em> '+document.referrer;a+='<br/><em style="color:#69f;">document.URL:</em> '+document.URL;a+='<br/><em style="color:#69f;">document.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){this.buffer('<span class="error">'+a.msg+"</span>")}else{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();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();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(args){if(!args.length){this.buffer('<span class="error">Please provide object name</span>');this.flush();return false}var trgObj=null;try{trgObj=JS.eval(args.trim())}catch(e){}if(!trgObj){this.buffer('<span class="error">'+args+" is not an object.</span>");this.flush();return false}if(window.console&&window.console.dir){console.group(args);console.dir(trgObj);console.groupEnd()}var mNames=JS.members(trgObj);if(!mNames.length){this.buffer('<span class="work">'+args+" has no members.</span>");this.flush();return false}mNames.sort();var len=mNames.length,m;this.buffer('<pre style="font-size:10px">');for(var i=0;i<len;m=mNames[i++]){switch(typeof(trgObj[m])){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(trgObj[m])){this.buffer('<em style="color:yellow;font-weight:bold">&lt;Array&gt;</em>'+String.fromCharCode(9))}else{if(trgObj[m]===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)+m+String.fromCharCode(10))}this.buffer("</pre>");return true};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();return false}};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};;