function showDomTree(topElement,topCode) {
var outStr = ''; topCode = topCode ? topCode : '0';
if( !topElement ) { outStr = 'Error, no top level element supplied.'; }
else if( typeof( topElement.nodeType) == 'undefined' ) { outStr = 'Error, browser is not DOM compliant.'; }
else {
if( topElement.attributes ) {
var elAttr = '';
if( topElement.className ) { elAttr += 'this.totalInfo[\'className\']=unescape(\''+escape(topElement.className)+'\');'; }
for( var x = 0; topElement.attributes[x]; x++ ) { if(topElement.attributes[x].nodeValue){
elAttr += 'this.totalInfo[unescape(\''+escape(topElement.attributes[x].nodeName)+'\')]=unescape(\''+escape(topElement.getAttribute(topElement.attributes[x].nodeName))+'\');';
} }
for( var x in topElement.style ) { if(topElement.style[x]&&topElement.style[x]!='false'){
elAttr += 'this.totalInfo[unescape(\'style.'+escape(x)+'\')]=unescape(\''+escape(topElement.style[x])+'\');';
} }
} else { var elAttr = 'this.totalInfo.nodeValue=unescape(\''+escape(topElement.nodeValue)+'\');'; }
if( topCode == '0' ) { outStr += '<ul>'; }
outStr += '<li>'+(topElement.firstChild?('<a href="#" onclick="disTog(\''+topCode+'\',this);return false;">[+]</a> '):'')+'<span onclick="if(window.MWJactEl){window.MWJactEl.className=\'\';}window.MWJactEl=this;this.className=\'highlighted\';this.totalInfo = new Object();'+elAttr+'if(window.handleAttributes){handleAttributes(this.totalInfo);}">'+((topElement.nodeName=='!')?'#comment':topElement.nodeName)+'</span>';
if( topElement.firstChild ) {
outStr += '<ul id="'+topCode+'" style="display:none;">';
for( var x = 0; topElement.childNodes[x]; x++ ) {
outStr += showDomTree( topElement.childNodes[x], topCode+'_'+x );
}
outStr += '</ul>';
}
outStr += '</li>';
if( topCode == '0' ) { outStr += '</ul>'; }
}
return outStr;
}
function disTog(id,el) { el.innerHTML = ( el.innerHTML.indexOf( '+' ) + 1 ) ? '[-]' : '[+]'; document.getElementById(id).style.display = document.getElementById(id).style.display ? '' : 'none'; }
function handleAttributes(ob) { var theStr = ''; for( var x in ob ) { theStr += ( theStr ? '\n' : '' ) + x + ' = ' + ob[x]; } alert(theStr); }