ddt.js
Summary
No overview generated for 'ddt.js'
DDT.agt = navigator.userAgent.toLowerCase();
DDT.is_ie = ((DDT.agt.indexOf("msie") != -1) && (DDT.agt.indexOf("opera") == -1));
DDT.is_opera = (DDT.agt.indexOf("opera") != -1);
DDT.is_mac = (DDT.agt.indexOf("mac") != -1);
DDT.is_mac_ie = (DDT.is_ie && DDT.is_mac);
DDT.is_win_ie = (DDT.is_ie && !DDT.is_mac);
DDT.is_gecko = (navigator.product == "Gecko");
function DDT( name )
{
if (name != undefined )
{
this.name = name;
}
else
{
this.name = "DDT";
}
this.state = "off";
this.popup = null;
}
DDT.prototype._ddtOn = function()
{
if ( this.popup == null )
{
var window_name = "ddt_popup_" + location.hostname.replace( /[.]/g, "_" );
if (DDT.is_gecko)
{
this.popup = window.open( "", "ddt_popup_" + location.host,
"toolbar=no,menubar=no,personalbar=no,width=800,height=450," +
"scrollbars=no,resizable=yes,modal=yes,dependable=yes");
}
else
{
this.popup = window.open("", window_name,
"toolbar=no,location=no,directories=no,status=no,menubar=no," +
"scrollbars=no,resizable=yes,width=800,height=450");
}
if (( typeof this.popup == 'undefined' ) || ( this.popup == null ))
{
alert( "FAILED TO OPEN DEBUGGING TRACE WINDOW" );
return false;
}
if (( this.popup != null ) && ( typeof this.popup.DDT_STATUS == 'undefined' ))
{
var content = "<html><head><title>Trace Messages for '" + location.host + "'</title></head><body><p>DDT</p><p><a href=\"javascript:document.write( '<hr>');\">ADD SEPARATOR</a></p></body></html>";
this.popup.document.write( content );
var header = this.popup.document.createElement( "h3" );
var message = this.popup.document.createTextNode( "_ddt Trace Messages" );
header.appendChild( message );
this.popup.document.body.appendChild( header );
this.popup.DDT_STATUS = "ok";
} // end of if the popup document hadn't been created.
} // end of if the popup had not been opened.
this.state = "on";
}; // end of _ddtOn()
// --------------------------------
/**
* turn off debugging messages.
*/
DDT.prototype._ddtOff = function()
{
this.state = "off";
}
// ----------------------------------
/**
* toggle debug message on/off state
*/
DDT.prototype._ddtToggle = function()
{
if ( this.state == "on" )
this._ddtOff();
else
this._ddtOn();
}
// --------------------------------
/**
* log a message
*
* writes a debugging trace message to debug popup if trace messages for this
* object have been turned on.
*/
DDT.prototype._ddt = function( file, line, msg )
{
if ( this.state == "on" )
{
// fireFox will generate an exception if the window is closed.
try
{
this.popup.document.write( "(" + this.name + ") " + file + ":" + line + " - " + msg + "<br>\n" );
}
catch( e )
{
// chances are the window was closed. For the moment we'll ignore this.
}
}
} // end of _ddt()
DDT.prototype._ddtDumpNode = function( file, line, msg, node )
{
if ( typeof node == 'undefined' )
{
this._ddt(
file, line, msg + " -- Node is undefined!" );
return;
}
if ( node == null )
{
this._ddt(
file, line, msg + " -- Node is null!" );
}
this._ddt(
file, line, msg + "<br>" + this.FragmentToString( node, 0 ) );
} // end of _ddtDumpNode()
DDT.prototype._ddtDumpObject = function( file, line, msg, obj )
{
this._ddt(
file, line, msg );
if ( typeof obj == 'undefined' )
{
this._ddt(
file, line, "Object is undefined!" );
}
for (var x in obj)
{
if ( typeof obj[x] == 'string' )
{
this._ddt(
file, line, "member - '" + x + "' = '" + obj[x].substr(0,40) + "'"
);
}
else
{
this._ddt(
file, line, "member - '" + x + "'"
);
}
}
} // end of _ddtDumpObject()
DDT.prototype.FragmentToString = function(root, level)
{
var retval = "";
if ( typeof root == 'undefined' )
return " root undefined ";
if ( root == null )
return " root is null ";
if ( typeof root.cloneRange != 'undefined' )
{
retval = "RANGE OBJECT - start offset '" + root.startOffset + "' end offset '" + root.endOffset + "'<br>";
retval += "RANGE START:<br>" + this.FragmentToString( root.startContainer, level );
retval += "RANGE END:<br>" + this.FragmentToString( root.endContainer, level );
return retval;
}
if ( typeof root.childNodes == 'undefined' )
return " root is not a node";
var childretval = "";
var i = 0;
for (i = 0; i < root.childNodes.length; i++)
{
childretval += this.FragmentToString( root.childNodes[i], level + 2);
}
retval = this.indent( level ) + this._ddtGetNodeType( root ) + " - " + root.childNodes.length + " children <br>" + childretval;
return retval;
};
DDT.prototype.indent = function( level )
{
var retval = "";
for (i = 0; i<level; i++ )
{
retval += " ";
}
return retval;
}
DDT.prototype._ddtGetNodeType = function( node )
{
var retval = "";
if ( typeof node == 'undefined' )
{
return "TYPE_IS_UNDEFINED";
}
if ( node == null )
{
return "TYPE_IS_NULL!";
}
if ( typeof node.nodeType == 'undefined' )
{
return "NOT_A_NODE_OBJECT - type is '" + typeof node + "'";
}
switch ( node.nodeType )
{
case 1:
retval = "ELEMENT_NODE - tag '" + node.nodeName + "'";
return retval;
break;
case 2:
return "ATTRIBUTE_NODE";
break;
case 3:
retval = "TEXT_NODE";
retval = retval + " contents '" + node.nodeValue + "'";
return retval;
break;
case 4:
return "CDATA_SECTION_NODE";
break;
case 5:
return "ENTITY_REFERENCE_NODE";
break;
case 6:
return "ENTITY_NODE";
break;
case 7:
return "PROCESSING_INSTRUCTION_NODE";
break;
case 8:
return "COMMENT_NODE";
break;
case 9:
return "DOCUMENT_NODE";
break;
case 10:
return "DOCUMENT_TYPE_NODE";
break;
case 11:
retval = "DOCUMENT_FRAGMENT_NODE";
return retval;
break;
case 12:
return "NOTATION_NODE";
break;
default:
return "UNKNOWN_NODE!";
break;
} // end of switch
}; // end of _ddtDumpNode()
DDT.prototype.getHTMLSource = function( html )
{
html = html.replace( /</ig, "<" );
html = html.replace( />/ig, ">" );
html = html.replace( /&/ig, "&" );
html = html.replace(/\xA0/g, " ");
html = html.replace(/\x22/g, """);
return html;
} // end of showHTML()
Documentation generated by
JSDoc on Mon Jun 13 20:27:40 2005