[OpenLayers-Commits] r11167 - trunk/openlayers/tests

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Feb 21 06:32:38 EST 2011


Author: pgiraud
Date: 2011-02-21 03:32:37 -0800 (Mon, 21 Feb 2011)
New Revision: 11167

Modified:
   trunk/openlayers/tests/OLLoader.js
Log:
Now we rely on relative paths + minor changes

Modified: trunk/openlayers/tests/OLLoader.js
===================================================================
--- trunk/openlayers/tests/OLLoader.js	2011-02-21 10:44:35 UTC (rev 11166)
+++ trunk/openlayers/tests/OLLoader.js	2011-02-21 11:32:37 UTC (rev 11167)
@@ -1,11 +1,25 @@
 // Adding a mode parameter with "build" as value in the run-tests.html will 
 // make usage of the build version of the library.
-var regexS = "[\\?&]mode=([^&#]*)";
-var regex = new RegExp( regexS );
+// get the OLLoader.js script location
+
+var r = new RegExp("(^|(.*?\\/))(" + "OLLoader.js" + ")(\\?|$)"),
+    s = document.getElementsByTagName('script'),
+    src, m, l = "";
+for(var i=0, len=s.length; i<len; i++) {
+    src = s[i].getAttribute('src');
+    if(src) {
+        var m = src.match(r);
+        if(m) {
+            l = m[1];
+            break;
+        }
+    }
+}
+
+var regex = new RegExp( "[\\?&]mode=([^&#]*)" );
 var href = window.parent.location.href;
-var url = href.substring(0, href.lastIndexOf('/') + 1);
 var results = regex.exec( href );
-url += (results && results[1] == 'build') ? 
+l += (results && results[1] == 'build') ? 
     "../build/OpenLayers.js" : "../lib/OpenLayers.js"; 
-scriptTag = "<script src='" + url + "'></script>"; 
+scriptTag = "<script src='" + l + "'></script>"; 
 document.write(scriptTag);



More information about the Commits mailing list