incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r490571 - /incubator/xap/trunk/src/xap/util/Debug.js
Date Wed, 27 Dec 2006 21:30:05 GMT
Author: mturyn
Date: Wed Dec 27 13:30:05 2006
New Revision: 490571

URL: http://svn.apache.org/viewvc?view=rev&rev=490571
Log:
Now we write to the HEAD element of the page if it's there; has the advantage of working even
after the HEAD's been closed, e.g. for mCO debugging or JIT-loaded components.

Modified:
    incubator/xap/trunk/src/xap/util/Debug.js

Modified: incubator/xap/trunk/src/xap/util/Debug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/Debug.js?view=diff&rev=490571&r1=490570&r2=490571
==============================================================================
--- incubator/xap/trunk/src/xap/util/Debug.js (original)
+++ incubator/xap/trunk/src/xap/util/Debug.js Wed Dec 27 13:30:05 2006
@@ -70,25 +70,58 @@
 			for (var nom in arguments[0]){
 				xap.util.Debug._loadDebuggable(nom) ;
 			}
+		} else {
+			xap.util.Debug._loadDebuggable( arg[0] ) ;
 		}	
 	}
 }
 
 /**
- *  PRIVATE METHODS AND VARAIABLES
+ *  PRIVATE METHODS AND VARIABLES
  */
  
 // We use these repeatedly, why re-create them each time?
 xap.util.Debug.trailingSlashRegexp = /^.*\/$/ ;
 xap.util.Debug.allFullstopsRegexp = /\./g ;
 xap.util.Debug.anyAsteriskRegexp = /\*/g ;
+xap.util.Debug.initialDoubleDots = new RegExp("^\.\./") ;
+xap.util.Debug.ourModuleMap={} ;
+{
+	for(var prefx in dojo.hostenv.modulePrefixes_){
+		var path = dojo.hostenv.modulePrefixes_[prefx].value ;
+		// Slight change in location?
+		path=path.replace(/^\.\./,"") ;
+		path = xap.util.Debug._sourceRootDir+path ;
+		xap.util.Debug.ourModuleMap[prefx] = path ;
+	}
+
+}
+
 
 xap.util.Debug._loadDebuggable = function(str){
+
+//@JSD_EVAL str.indexOf("Mco") > -1 // !
 	var path = str.replace(xap.util.Debug.allFullstopsRegexp,"/") ;
-	if ( !xap.util.Debug._sourceRootDir.match(xap.util.Debug.trailingSlashRegexp)){
-		xap.util.Debug._sourceRootDir +="/" ;
+	var arr = str.split(".") ;
+	
+	// Not very general, but this has proved to be a minefield
+	//---maybe best to learn how to use dojo's own debugging for dojo
+	//but then, if that had been trivial, we would have done it.:
+	if( arr[0] == "dojo" ){
+		if (typeof eval(str) != "undefined"){
+			return ;
+		}
 	}
-	path = xap.util.Debug._sourceRootDir +path +".js" ;
+
+
+
+	var prePath = xap.util.Debug.ourModuleMap[ arr[0]  ] ;
+	if( ! prePath ){
+		return ;
+	}
+	arr.shift() ;
+	path = prePath +"/"+ arr.join("/") +".js" ;
+
 	Xap.logString += ";"+ path;
 	xap.util.Debug.importFile(path) ;
 }
@@ -101,8 +134,10 @@
 	xap.util.Debug._debugLoad = tf ;
 } 
 
-
+xap.util.Debug.HEAD=null ;
 xap.util.Debug.importFile = function( path ) {
+
+
 	if( xap.util.Debug.s_pathCache == null ) {
 		xap.util.Debug.s_pathCache = new Object();
 	}
@@ -110,9 +145,31 @@
 		return;
 	}
 	xap.util.Debug.s_pathCache[path] = true;
-	var scriptElement = "<script language=\"JavaScript\" " +
-		"type=\"text/javascript\" src=\"" + path + "\"></script>";
-	document.write( scriptElement );
+//	var scriptString = "<script language=\"JavaScript\" " +
+//		"type=\"text/javascript\" src=\"" + path + "\"></script>";
+//	document.write( scriptString );
+	if( !xap.util.Debug.HEAD ){
+		var allHeads = document.getElementsByTagName("HEAD") ;
+		if(allHeads && allHeads.length>1){
+		// should only have one....
+			xap.util.Debug.HEAD	= allHeads[0] ;
+		}
+	}
+	if( !xap.util.Debug.HEAD ){
+		// Faute de mieux---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 ;
+		alert(path) ;
+		xap.util.Debug.HEAD.appendChild( element) ;
+	}
 }
 
 xap.util.Debug.s_pathCache = null;



Mime
View raw message