blob: 34d0b3dedbbf1626b8aa99231d35a760b63baf1e [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--************************************************************************-->
<!--* FireFox JavaScript Browser Object Dump *-->
<!--* *-->
<!--* Copyright 2007 IBM *-->
<!--* Bradley Childs (childsb@us.ibm.com) *-->
<!--************************************************************************-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>FireFox JavaScript Object Browser Dump</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
// Netscape 6 (or Mozilla)?
var isNS6 = (navigator.userAgent.indexOf("Gecko") > 0) ? 1 : 0;
// Arrays for tracking objects/methods.
var objectList = new Array();
var objTypeArrays = new Array();
var rootElements = new Array();
var nameArray = new Array();
function addRootDisplayElement(theObject,objName){
var valueString;
if(objName=="") objName="this";
valueString = objName + ".prototype = new " + getObjectName(theObject) + "();";
rootElements[rootElements.length] = valueString;
}
function shouldExclude(nameOfElement){
/* allows filtered values and exclude elements that are coming from this script */
var excluded = ["shouldExclude",
"addRootDisplayElement",
"buildClasses",
"getObjectName",
"objectList",
"objTypeArrays",
"rootElements",
"nameArray",
"isNS6",
"getObjectSuperType",
"isKnownObject",
"generateHTMLObjectTable",
"addElementToObject",
"addToObjects",
"getAllProperties",
"isArray",
"isObject",
"findProperties",
"DOMViewerObj",
"DOMViewerName"];
var k;
for(k=0;k<excluded.length;k++){
if(nameOfElement==excluded[k]) return true;
}
return false;
}
function buildClasses(){
var ea = new Array();
var k,j,t;
for(k=0;k<objectList.length;k++){
var elementArray;
var classObjectName;
try{
classObjectName = objectList[k];
}catch(exception){}
if(shouldExclude(classObjectName)) continue;
var superName = (isArray(classObjectName))?"new Array();":"new Object();";
ea[ea.length] = classObjectName + ".prototype= " + superName;
ea[ea.length] = "function " + classObjectName + "(){};"
elementArray = objTypeArrays[k];
if(!isArray(elementArray)) continue;
for(j=0;j<elementArray.length;j++){
try{
value = elementArray[j];
}catch(exception){
value = name;
}
name = nameArray[k][j];
if(shouldExclude(name)) continue;
if(value==null) continue;
if(isObject(value)){
try{
var superType = getObjectSuperType(value);
ea[ea.length] = classObjectName + ".prototype." + name + "= new " + superType + "();";
}catch(exception){
continue;
//ea[ea.length] = classObjectName + "." + name + ".prototype=new " + name + "();";
}
}else if(value instanceof Function){
var argString = "";
for(t=0;t<value.length;t++){
argString += "arg" + (t+1) + ((t+1)<value.length?",":"");
}
ea[ea.length] = classObjectName + ".prototype." + name + "=function("+argString+"){};";
}else if(typeof value=="string"){
ea[ea.length] = classObjectName + ".prototype." + name + "=\"\";";
}else if(typeof value =="boolean"){
ea[ea.length] = classObjectName + ".prototype." + name + "=false;";
}else if(typeof value =="number"){
ea[ea.length] = classObjectName + ".prototype." + name + "=0;";
}
}
}
return ea;
}
function getObjectName(sibObject){
var start,end,parentString;
var objString = String(sibObject);
if(objString!=null){
start = (objString.indexOf("object") + 6);
end = objString.indexOf("]");
if(start<end){
parentString = objString.substring(start,end);
}else{
start = objString.indexOf("[");
end = objString.indexOf("]");
if(start<end){
parentString = objString.subString(start,end);
}else{
parentString = objString;
}
}
}
return parentString;
}
function getObjectSuperType(sibObject){
var parentString;
parentString = getObjectName(sibObject);
if(isArray(sibObject)){
var array=true;
}
var constr;
if(!(parentString=="Object") && isKnownObject(parentString)){
return parentString;
} else if(isArray(sibObject)){
return "Array";
}
return parentString;
}
function isKnownObject(objValue){
if(objValue==null) return false;
var k;
for(k=0;k<objectList.length;k++){
try{
if(String(objectList[k])==objValue){
return true;
}
}catch(Exception){}
}
return false;
}
function generateHTMLObjectTable(DOMViewerObj, DOMViewerName){
findProperties(DOMViewerObj, null, DOMViewerName);
var s = '<table>';
var i;
for(i = 0; i < rootElements.length; i++){
s+= "<tr><td>" + new String(rootElements[i]) + "</td></tr>";
}
s+="<tr><td><br><br></tr></td>"
newElms = buildClasses();
for(i = 0; i < newElms.length; i++){
s+= "<tr><td>" + new String(newElms[i]) + "</td></tr>";
}
return s + "</table>"
}
function addElementToObject(classObject,functionObject,name){
var value,k;
var index=-1;
if(isObject(classObject)){
value = getObjectName(classObject);
}else{
value=classObject;
}
for(k=0;k<objectList.length;k++){
if(objectList[k]==value){
index=k;
break;
}
}
if(index==-1) return false;
if(objTypeArrays[index]==null){
objTypeArrays[index] = new Array();
}
if(nameArray[index]==null) nameArray[index] = new Array();
for(k=0;k<nameArray[index].length;k++){
try{
if(nameArray[index][k]==name) return; // nothing to do
}catch(exception){
// not found
}
}
objTypeArrays[index][objTypeArrays[index].length] = (functionObject==null?(new String()):functionObject);
nameArray[index][objTypeArrays[index].length-1] = name;
}
function addToObjects(newObject){
var value,k;
if(newObject==null) return false;
value = getObjectName(newObject);
for(k=0;k<objectList.length;k++){
if(objectList[k]==value){
return false;
}
}
objectList[objectList.length] = value;
return true;
}
function getAllProperties(object){
var propertyList = new Array();
try{
for (property in object)
propertyList[propertyList.length] = property;
}catch(exception){}
return propertyList;
}
function isArray(valueObject){
var isArray = false;
try{
isArray = (valueObject!=null && valueObject.length>0);
}catch(exception){ isArray = false; }
return isArray;
}
function isObject(elem){
return ((elem!=null) && (elem instanceof Object) && !(elem instanceof Function));
}
function findProperties(obj, parent, name) {
var allProperties,i;
if ( isObject(obj) && ! isArray(obj) ){
if(parent==null){
addToObjects(obj);
addRootDisplayElement(obj,name);
}
allProperties = getAllProperties(obj);
}else{
return;
}
for (i = 0; i < allProperties.length ; i++) {
if(allProperties[i]=="constructor") continue;
if(i==72){
// do something
var k = 10;
}
var objValue;
try{
objValue = obj[allProperties[i]];
}catch(exception){
objValue = null;
addElementToObject(obj,allProperties[i],String(allProperties[i]));
continue;
}
try{
if( isObject(objValue) && (! isArray(objValue)) && addToObjects(objValue)){
addElementToObject(obj,obj[allProperties[i]],String(allProperties[i]));
findProperties(obj[allProperties[i]], (parent==null?"":parent+ ".") + name, String(allProperties[i]));
}else if( objValue instanceof Object ){
addElementToObject(obj,objValue,String(allProperties[i]));
}else{
var isUndefPrim = (objValue==null || objValue=="" );
addElementToObject(obj,(isUndefPrim?allProperties[i]:objValue),String(allProperties[i]));
}
}catch(exception){
var k =10;
}
}
}
</script>
</head>
<body>
<h3>Browsers JavaScript Elements:</h3>
<script type="text/javascript">
// Show properties for the specified object in the opening window. Default to
// the document if no object is specified.
var DOMViewerObj = this;
var DOMViewerName = "";
if (!DOMViewerObj) {
DOMViewerObj = window.opener.document;
DOMViewerName = "document";
}
document.writeln(generateHTMLObjectTable(DOMViewerObj, DOMViewerName));
</script>
</body>
</html>