You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2007/03/12 21:34:03 UTC
svn commit: r517409 - /incubator/xap/trunk/codebase/src/xap/util/Debug.js
Author: mturyn
Date: Mon Mar 12 14:34:02 2007
New Revision: 517409
URL: http://svn.apache.org/viewvc?view=rev&rev=517409
Log:
Backtracked debugging: it works a lot better by accumulating a list of files to load and then laoding them just before the <HEAD/> element closes, rather than loading them as they come.
Added xap.util.Debug.preloadDebuggables, which loads debuggables and sets xap.util.Debug.preloaded==true, so we can tell if we've already loaded the ones we'll initially expect.
Modified:
incubator/xap/trunk/codebase/src/xap/util/Debug.js
Modified: incubator/xap/trunk/codebase/src/xap/util/Debug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/Debug.js?view=diff&rev=517409&r1=517408&r2=517409
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/Debug.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/Debug.js Mon Mar 12 14:34:02 2007
@@ -54,6 +54,12 @@
}
}
+xap.util.Debug.preloadDebuggables = function(){
+ xap.util.Debug.loadDebuggables.apply(arguments) ;
+ xap.util.Debug.preloaded = true ;
+}
+
+
/**
* Load the list of debuggable files from the server.
*/
@@ -123,7 +129,7 @@
arr.shift() ;
path = prePath +"/"+ arr.join("/") +".js" ;
-// Xap.logString += ";"+ path;
+ //Xap.logString += ";"+ path;
xap.util.Debug.importFile(path) ;
}
@@ -135,7 +141,7 @@
xap.util.Debug._debugLoad = tf ;
}
-xap.util.Debug.SCRIPT_PARENT=null ;
+xap.util.Debug.HEAD=null ;
xap.util.Debug.importFile = function( path ) {
@@ -147,31 +153,23 @@
}
xap.util.Debug.s_pathCache[path] = true;
-
- if( !xap.util.Debug.SCRIPT_PARENT ){
- var allScripts = document.getElementsByTagName("SCRIPT") ;
- if(allScripts && allScripts.length>1){
- // should only have one....
- xap.util.Debug.SCRIPT_PARENT = allScripts[0].parentNode ;
+ if( !document.body ){
+ // Works best---but often won't work once the body elements's
+ // in place:
+ var scriptString = "<script language=\"JavaScript\" " +
+ "type=\"text/javascript\" src=\"" + path + "\"></script>";
+ document.write( scriptString );
+
+ } else {
+ var element = document.createElement("SCRIPT") ;
+ element.type="text/javascript" ;
+ element.language="JavaScript" ;
+ element.src = path ;
+ if(!xap.util.Debug.HEAD){
+ xap.util.Debug.HEAD = document.getElementsByTagName("head")[0] ;
}
+ xap.util.Debug.HEAD.appendChild( element) ;
}
- var element = document.createElement("SCRIPT") ;
- element.type="text/javascript" ;
- element.language="JavaScript" ;
- element.src = path ;
-
- var theParent = xap.util.Debug.SCRIPT_PARENT ;
-
- if( !xap.util.Debug.SCRIPT_PARENT ){
- // Faute de mieux---but often won't work once the body elements's
- // in place:
- var allHTMLs = document.getElementsByTagName("HTML") ;
- // TODO: Find out why sometimes there is more than
- // one---why? In any event, the last one is the one we
- // want:
- theParent = allHTMLs.pop() ;
- }
- theParent.appendChild(element) ;
}
xap.util.Debug.s_pathCache = null;