1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
/*
File: xajax_verbose.js
The xajax verbose debugging module. This is an optional module, include in
your project with care. :)
Title: xajax verbose debugging module
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
/*
@package xajax
@version $Id: xajax_verbose_uncompressed 327 2007-02-28 16:55:26Z calltoconstruct $
@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
@copyright Copyright (c) 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White & J. Max Wilson
@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/
try {
if ('undefined' == typeof xajax)
throw { name: 'SequenceError', message: 'Error: xajax core was not detected, verbose module disabled.' }
if ('undefined' == typeof xajax.debug)
throw { name: 'SequenceError', message: 'Error: xajax debugger was not detected, verbose module disabled.' }
/*
Class: xajax.debug.verbose
Provide a high level of detail which can be used to debug hard to find
problems.
*/
xajax.debug.verbose = {}
/*
Function: xajax.debug.verbose.expandObject
Generate a debug message expanding all the first level
members found therein.
Parameters:
obj - (object): The object to be enumerated.
Returns:
string - The textual representation of all the first
level members.
*/
xajax.debug.verbose.expandObject = function(obj) {
var rec = true;
if (1 < arguments.length)
rec = arguments[1];
if ('function' == typeof (obj)) {
return '[Function]';
} else if ('object' == typeof (obj)) {
if (true == rec) {
var t = ' { ';
var separator = '';
for (var m in obj) {
t += separator;
t += m;
t += ': ';
try {
t += xajax.debug.verbose.expandObject(obj[m], false);
} catch (e) {
t += '[n/a]';
}
separator = ', ';
}
t += ' } ';
return t;
} else return '[Object]';
} else return '"' + obj + '"';
}
/*
Function: xajax.debug.verbose.makeFunction
Generate a wrapper function around the specified function.
Parameters:
obj - (object): The object that contains the function to be
wrapped.
name - (string): The name of the function to be wrapped.
Returns:
function - The wrapper function.
*/
xajax.debug.verbose.makeFunction = function(obj, name) {
return function() {
var fun = name;
fun += '(';
var separator = '';
var pLen = arguments.length;
for (var p = 0; p < pLen; ++p) {
fun += separator;
fun += xajax.debug.verbose.expandObject(arguments[p]);
separator = ',';
}
fun += ');';
var msg = '--> ';
msg += fun;
xajax.debug.writeMessage(msg);
var returnValue = true;
var code = 'returnValue = obj(';
separator = '';
for (var p = 0; p < pLen; ++p) {
code += separator;
code += 'arguments[' + p + ']';
separator = ',';
}
code += ');';
eval(code);
msg = '<-- ';
msg += fun;
msg += ' returns ';
msg += xajax.debug.verbose.expandObject(returnValue);
xajax.debug.writeMessage(msg);
return returnValue;
}
}
/*
Function: xajax.debug.verbose.hook
Generate a wrapper function around each of the functions
contained within the specified object.
Parameters:
x - (object): The object to be scanned.
base - (string): The base reference to be prepended to the
generated wrapper functions.
*/
xajax.debug.verbose.hook = function(x, base) {
for (var m in x) {
if ('function' == typeof (x[m])) {
x[m] = xajax.debug.verbose.makeFunction(x[m], base + m);
}
}
}
xajax.debug.verbose.hook(xajax, 'xajax.');
xajax.debug.verbose.hook(xajax.callback, 'xajax.callback.');
xajax.debug.verbose.hook(xajax.css, 'xajax.css.');
xajax.debug.verbose.hook(xajax.dom, 'xajax.dom.');
xajax.debug.verbose.hook(xajax.events, 'xajax.events.');
xajax.debug.verbose.hook(xajax.forms, 'xajax.forms.');
xajax.debug.verbose.hook(xajax.js, 'xajax.js.');
xajax.debug.verbose.hook(xajax.tools, 'xajax.tools.');
xajax.debug.verbose.hook(xajax.tools.queue, 'xajax.tools.queue.');
xajax.debug.verbose.hook(xajax.command, 'xajax.command.');
xajax.debug.verbose.hook(xajax.command.handler, 'xajax.command.handler.');
/*
Boolean: isLoaded
true - indicates that the verbose debugging module is loaded.
*/
xajax.debug.verbose.isLoaded = true;
} catch (e) {
alert(e.name + ': ' + e.message);
}
|