var HIDDEN="hidden"; var LEVEL = "level"; var PLUS_SRC="dom-images/butplus.gif"; var MIN_SRC="dom-images/butmin.gif"; var newRoot; var maxColumns=1; function loadDomViewer() { // See if the rootDocument variable has been set on this window. var rootDocument = window.rootDocument; // If not look to the opener for an explicity rootDocument variable, otherwise, use the opener document if (!rootDocument && window.opener) { rootDocument = window.opener.rootDocument || window.opener.document; } if (rootDocument) { document.body.innerHTML = displayDOM(rootDocument); } else { document.body.innerHTML = "Must specify rootDocument for window. This can be done by setting the rootDocument variable on this window, or on the opener window for a popup window."; } } function displayDOM(root){ var str = ""; str+=""; str += treeTraversal(root,0); // to make table columns work well. str += ""; for (var i=0; i < maxColumns; i++) { str+= ""; } str += ""; str += "
    
"; return str; } function checkForChildren(element){ if(!element.hasChildNodes()) return false; var nodes = element.childNodes; var size = nodes.length; var count=0; for(var i=0; i< size; i++){ var node = nodes.item(i); //if(node.toString()=="[object Text]"){ //this is equalent to the above //but will work with more browsers if(node.nodeType!=1){ count++; } } if(count == size) return false; else return true; } function treeTraversal(root, level){ var str = ""; var nodes= null; var size = null; //it is supposed to show the last node, //but the last node is always nodeText type //and we don't show it if(!root.hasChildNodes()) return "";//displayNode(root,level,false); nodes = root.childNodes; size = nodes.length; for(var i=0; i< size; i++){ var element = nodes.item(i); //if the node is textNode, don't display if(element.nodeType==1){ str+= displayNode(element,level,checkForChildren(element)); str+=treeTraversal(element, level+1); } } return str; } function displayNode(element, level, isLink){ nodeContent = getNodeContent(element); columns = Math.round((nodeContent.length / 12) + 0.5); if (columns + level > maxColumns) { maxColumns = columns + level; } var str =""; for (var i=0; i < level; i++) str+= " "; str+=""; if(isLink){ str+=''; str+=''; } str += nodeContent; if(isLink) str+=""; return str; } function getNodeContent(element) { str = ""; id =""; if (element.id != null && element.id != "") { id = " ID(" + element.id +")"; } name =""; if (element.name != null && element.name != "") { name = " NAME(" + element.name + ")"; } value =""; if (element.value != null && element.value != "") { value = " VALUE(" + element.value + ")"; } href =""; if (element.href != null && element.href != "") { href = " HREF(" + element.href + ")"; } text =""; if (element.text != null && element.text != "" && element.text != "undefined") { text = " #TEXT(" + trim(element.text) +")"; } str+=" "+ element.nodeName + id + name + value + href + text + ""; return str; } function trim(val) { val2 = val.substring(0,20) + " "; var spaceChr = String.fromCharCode(32); var length = val2.length; var retVal = ""; var ix = length -1; while(ix > -1){ if(val2.charAt(ix) == spaceChr) { } else { retVal = val2.substring(0, ix +1); break; } ix = ix-1; } if (val.length > 20) { retVal += "..."; } return retVal; } function hide(hlink){ var isHidden = false; var image = hlink.firstChild; if(image.src.toString().indexOf(MIN_SRC)!=-1){ image.src=PLUS_SRC; isHidden=true; }else{ image.src=MIN_SRC; } var rowObj= hlink.parentNode.parentNode; var rowLevel = parseInt(rowObj.className.substring(LEVEL.length)); var sibling = rowObj.nextSibling; var siblingLevel = sibling.className.substring(LEVEL.length); if(siblingLevel.indexOf(HIDDEN)!=-1){ siblingLevel = siblingLevel.substring(0,siblingLevel.length - HIDDEN.length-1); } siblingLevel=parseInt(siblingLevel); while(sibling!=null && rowLevel