Apache-Voodoo
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Debug/html/debug.js view on Meta::CPAN
//////////////////////////////////////////////////////////////////////////////////
// Feather Ajax
//////////////////////////////////////////////////////////////////////////////////
// reference to the calling object
this.caller = null;
// ..and the associated set method
this.setResponseHandler = function(obj) {
this.caller = obj;
};
this.createRequestObject = function() {
var ro;
try {
ro=new XMLHttpRequest();
}
catch(e) {
ro=new ActiveXObject("Microsoft.XMLHTTP");
}
return ro;
};
this.http = this.createRequestObject();
var me = this;
this.sndReq = function(action,url,data) {
if (action.toUpperCase()=="POST") {
this.http.open(action,url,true);
this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
this.http.onreadystatechange=this.handleResponse;
this.http.send(data);
}
else {
this.http.open(action,url+'?'+data,true);
this.http.onreadystatechange=this.handleResponse;
this.http.send(null);
}
};
this.handleResponse = function() {
// Stripped down to only call the response handler passing it the response content
if (me.http.readyState==4) {
me.caller.handleResponse(me.http.responseText);
}
};
}
function voodooDebug(opts) {
this.debug_root = opts.debug_root;
this.app_id = opts.app_id;
this.session_id = opts.session_id;
this.request_id = opts.request_id;
this.origin_id = this.request_id;
this.imgSpinner = new Image(16,16);
this.imgMinus = new Image(9,9);
this.imgPlus = new Image(9,9);
this.imgSpinner.src = this.debug_root+"/spinner.gif";
this.imgMinus.src = this.debug_root+"/minus.png";
this.imgPlus.src = this.debug_root+"/plus.png";
this.elementid = 1; //counter so we can generate unique element ids.
this.levels = {
"debug": 1,
"info": 1,
"warn": 1,
"error": 1,
"exception": 1,
"table": 1,
"trace": 1
};
this.openSections = {
"profile": false,
"debug": false,
"return_data": false,
"session": false,
"template_conf": false,
"parameters": false
};
this.parser = new voodooJson();
this.imgLevels = {};
for (var key in this.levels) {
this.imgLevels[key] = new Image(12,12);
this.imgLevels[key].src = this.debug_root+"/"+key+".png";
}
this.yourBrowserIsBroken = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
////////////////////////////////////////////////////////////////////////////////
//
// PUBLIC METHODS
//
////////////////////////////////////////////////////////////////////////////////
// pulls down the list of ajax requests made by the page we're looking at
this.listRequests = function() {
var params = 'app_id=' +this.app_id+
'&session_id='+this.session_id+
'&request_id='+this.origin_id;
this.sendRequest('request',params);
};
// Changes the which request we're looking at; refreshes all the open sections
this.changeRequest = function(obj) {
this.request_id = obj.value;
for (var section in this.openSections) {
if (this.openSections[section]) {
this.loadSection(section);
}
}
};
// Changes the debug block filtering options
this.filterDebug = function(obj,level) {
document.getElementById("vd_debug").innerHTML = '<img src="'+this.imgSpinner.src+'">';
this.levels[level] = (this.levels[level])?0:1;
var params = 'app_id=' +this.app_id+
'&session_id='+this.session_id+
'&request_id='+this.request_id;
for (var i in this.levels) {
params += '&' + i + '=' + this.levels[i];
}
this.sendRequest('debug',params);
};
// Handles the opening or closing of the various debug panels
this.handleSection = function(obj, section) {
if (obj.parentNode.className == "vdOpen") {
obj.parentNode.className = 'vdClosed';
obj.firstChild.src=this.imgPlus.src;
if (section != "top") {
this.openSections[section] = false;
}
}
else {
obj.parentNode.className = 'vdOpen';
obj.firstChild.src=this.imgMinus.src;
if (section != "top") {
this.openSections[section] = true;
( run in 0.469 second using v1.01-cache-2.11-cpan-df04353d9ac )