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 2006/11/06 23:51:36 UTC

svn commit: r471933 - /incubator/xap/trunk/src/xap/util/Debug.js

Author: mturyn
Date: Mon Nov  6 15:51:36 2006
New Revision: 471933

URL: http://svn.apache.org/viewvc?view=rev&rev=471933
Log:
Added actual tag-writing code here to decouple it completely from Utils, and also so that we can change the definition of the sourceRootDir 
---no longer assuming that there's a directory called 'src' under it, must add that explicitly if needed.  Default _sourceRootDir changed to 
"../../src" in order to reflect that.

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=471933&r1=471932&r2=471933
==============================================================================
--- incubator/xap/trunk/src/xap/util/Debug.js (original)
+++ incubator/xap/trunk/src/xap/util/Debug.js Mon Nov  6 15:51:36 2006
@@ -24,10 +24,11 @@
  */
 
 Xap.provide("xap.util.Debug");
-Xap.require("xap.util.Utils");
 
 
-xap.util.Debug._sourceRootDir = "../../" ;
+xap.util.Debug._sourceRootDir = "../../src" ;
+
+
 
 /**
  *  Keep track of the source root directory for the debuggable files.
@@ -55,13 +56,19 @@
 //If there are args, the first should be a list of
 // classes to load; if there are no arguments, use 
 // the default list of files:
-	if(arguments.length ==0  && xap.util.Debug._debuggables){
-		xap.util.Debug.loadDebuggables(xap.util.Debug._debuggables) ;
+	if(arguments.length == 0){
+		if( xap.util.Debug._debuggables ){
+			xap.util.Debug.loadDebuggables(xap.util.Debug._debuggables) ;
+		}
 		return;
 	}else{ 
-		for (var nom in arguments[0]){
-			xap.util.Debug._loadDebuggable(nom) ;
-		}
+		// Just in case we got a string:
+		if (arguments[0] instanceof Array ){
+			for (var nom in arguments[0]){
+				alert(nom) ;
+				xap.util.Debug._loadDebuggable(nom) ;
+			}
+		}	
 	}
 }
 
@@ -79,9 +86,9 @@
 	if ( !xap.util.Debug._sourceRootDir.match(xap.util.Debug.trailingSlashRegexp)){
 		xap.util.Debug._sourceRootDir +="/" ;
 	}
-	path = xap.util.Debug._sourceRootDir +"src/"+path +".js" ;
+	path = xap.util.Debug._sourceRootDir +path +".js" ;
 	Xap.logString += ";"+ path;
-	xap.util.Utils.importFile(path) ;
+	xap.util.Debug.importFile(path) ;
 }
 
 
@@ -93,6 +100,21 @@
 } 
 
 
+xap.util.Debug.importFile = function( path ) {
+	if( xap.util.Debug.s_pathCache == null ) {
+		xap.util.Debug.s_pathCache = new Object();
+	}
+	if ( xap.util.Debug.s_pathCache[path] ){
+		return;
+	}
+	xap.util.Debug.s_pathCache[path] = true;
+	var scriptElement = "<script language=\"JavaScript\" " +
+		"type=\"text/javascript\" src=\"" + path + "\"></script>";
+	document.write( scriptElement );
+}
+
+xap.util.Debug.s_pathCache = null;
+
 
 /**
  * For debugging all files loaded through Xap.require():
@@ -101,7 +123,6 @@
 	xap.util.Debug._debugAll = true ;
 } 
 
-
 if( window.debug_config ){
 	for(var key in window.debug_config ){
 		xap.util.Debug[key] = window.debug_config[key] ;
@@ -113,3 +134,5 @@
 		xap.util.Debug.addDebuggables(xap.util.Debug._debugList) ;
 	}
 }
+
+