[OpenLayers-Commits] r10822 - in trunk/openlayers: build lib
lib/OpenLayers tests
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Oct 13 09:02:09 EDT 2010
Author: ahocevar
Date: 2010-10-13 06:02:08 -0700 (Wed, 13 Oct 2010)
New Revision: 10822
Added:
trunk/openlayers/tests/OpenLayers1.html
trunk/openlayers/tests/OpenLayers2.html
trunk/openlayers/tests/OpenLayers3.html
Removed:
trunk/openlayers/tests/OpenLayers.html
Modified:
trunk/openlayers/build/full.cfg
trunk/openlayers/build/library.cfg
trunk/openlayers/build/lite.cfg
trunk/openlayers/lib/OpenLayers.js
trunk/openlayers/lib/OpenLayers/SingleFile.js
trunk/openlayers/tests/list-tests.html
Log:
Made _getScriptLocation smarter, and added it to SingleFile.js also. This means that single file builds no longer need to contain OpenLayers.js. r=eleomine (closes #2873)
Modified: trunk/openlayers/build/full.cfg
===================================================================
--- trunk/openlayers/build/full.cfg 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/build/full.cfg 2010-10-13 13:02:08 UTC (rev 10822)
@@ -3,7 +3,6 @@
[first]
OpenLayers/SingleFile.js
-OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/BaseTypes/Class.js
OpenLayers/Util.js
@@ -15,4 +14,5 @@
[exclude]
Firebug
+OpenLayers.js
OpenLayers/Lang
Modified: trunk/openlayers/build/library.cfg
===================================================================
--- trunk/openlayers/build/library.cfg 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/build/library.cfg 2010-10-13 13:02:08 UTC (rev 10822)
@@ -4,7 +4,6 @@
[first]
OpenLayers/SingleFile.js
-OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/BaseTypes/Class.js
OpenLayers/Util.js
@@ -16,6 +15,7 @@
[exclude]
Firebug
+OpenLayers.js
OpenLayers/Format/GeoRSS.js
OpenLayers/Format/GML.js
OpenLayers/Format/WKT.js
Modified: trunk/openlayers/build/lite.cfg
===================================================================
--- trunk/openlayers/build/lite.cfg 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/build/lite.cfg 2010-10-13 13:02:08 UTC (rev 10822)
@@ -6,7 +6,6 @@
[first]
OpenLayers/SingleFile.js
-OpenLayers.js
OpenLayers/BaseTypes.js
OpenLayers/BaseTypes/Class.js
OpenLayers/Util.js
Modified: trunk/openlayers/lib/OpenLayers/SingleFile.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/SingleFile.js 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/lib/OpenLayers/SingleFile.js 2010-10-13 13:02:08 UTC (rev 10822)
@@ -4,7 +4,12 @@
* full text of the license. */
var OpenLayers = {
- singleFile: true
+ singleFile: true,
+ _getScriptLocation: (function() {
+ var s = document.getElementsByTagName('script');
+ var l = s[s.length-1].getAttribute("src").match(/(^|(.*?\/))(OpenLayers\.js)(\?|$)/)[1];
+ return (function() { return l; });
+ })()
};
Modified: trunk/openlayers/lib/OpenLayers.js
===================================================================
--- trunk/openlayers/lib/OpenLayers.js 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/lib/OpenLayers.js 2010-10-13 13:02:08 UTC (rev 10822)
@@ -14,55 +14,34 @@
* Before creating the OpenLayers namespace, check to see if
* OpenLayers.singleFile is true. This occurs if the
* OpenLayers/SingleFile.js script is included before this one - as is the
- * case with single file builds.
+ * case with old single file build profiles that included both
+ * OpenLayers.js and OpenLayers/SingleFile.js.
*/
var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile);
/**
- * Cache for the script location returned from
- * OpenLayers._getScriptLocation
+ * Relative path of this script.
*/
- var scriptLocation;
+ var scriptName = (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js";
/**
* Namespace: OpenLayers
* The OpenLayers object provides a namespace for all things OpenLayers
*/
window.OpenLayers = {
-
/**
- * Property: _scriptName
- * {String} Relative path of this script.
- */
- _scriptName: (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js",
-
- /**
* Function: _getScriptLocation
* Return the path to this script.
*
* Returns:
* {String} Path to this script
*/
- _getScriptLocation: function () {
- if (scriptLocation != undefined) {
- return scriptLocation;
- }
- scriptLocation = "";
- var isOL = new RegExp("(^|(.*?\\/))(" + OpenLayers._scriptName + ")(\\?|$)");
-
- var scripts = document.getElementsByTagName('script');
- for (var i=0, len=scripts.length; i<len; i++) {
- var src = scripts[i].getAttribute('src');
- if (src) {
- var match = src.match(isOL);
- if(match) {
- scriptLocation = match[1];
- break;
- }
- }
- }
- return scriptLocation;
- }
+ _getScriptLocation: (function() {
+ var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)");
+ var s = document.getElementsByTagName('script');
+ var l = s[s.length-1].getAttribute("src").match(r)[1];
+ return (function() { return l; });
+ })()
};
/**
* OpenLayers.singleFile is a flag indicating this file is being included
Deleted: trunk/openlayers/tests/OpenLayers.html
===================================================================
--- trunk/openlayers/tests/OpenLayers.html 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/tests/OpenLayers.html 2010-10-13 13:02:08 UTC (rev 10822)
@@ -1,31 +0,0 @@
-<html>
-<head>
- <script src="bogus/1/OpenLayers.js-foo"></script>
- <script src="bogus/2/foo-OpenLayers.js"></script>
- <script id="script" src="../lib/OpenLayers.js"></script>
- <script type="text/javascript">
- function test_OpenLayers(t) {
- t.plan(3);
-
- var script = document.getElementById("script");
-
- t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
-
- // create a clone of OpenLayers._getScriptLocation
- eval("var getScriptLocation = " + OpenLayers._getScriptLocation.toString());
- var scriptLocation;
-
- script.setAttribute("src", "../lib/OpenLayers.js?foo");
- t.eq(getScriptLocation(), "../", "Script location with search string correctly detected.");
- scriptLocation = null;
-
- // now pretend we're using a built script
- OpenLayers._scriptName = "OpenLayers.js";
- t.eq(getScriptLocation(), "../lib/", "not fooled by bogus paths");
-
- }
- </script>
-</head>
-<body>
-</body>
-</html>
Added: trunk/openlayers/tests/OpenLayers1.html
===================================================================
--- trunk/openlayers/tests/OpenLayers1.html (rev 0)
+++ trunk/openlayers/tests/OpenLayers1.html 2010-10-13 13:02:08 UTC (rev 10822)
@@ -0,0 +1,32 @@
+<html>
+<head>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
+<html>
+<head>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../", "Script location correctly detected.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
Added: trunk/openlayers/tests/OpenLayers2.html
===================================================================
--- trunk/openlayers/tests/OpenLayers2.html (rev 0)
+++ trunk/openlayers/tests/OpenLayers2.html 2010-10-13 13:02:08 UTC (rev 10822)
@@ -0,0 +1,38 @@
+<html>
+<head>
+ <script src="bogus/1/OpenLayers.js-foo"></script>
+ <script src="bogus/2/foo-OpenLayers.js"></script>
+ <script src="../lib/OpenLayers.js?foo"></script>
+ <script src="bogus/3/after-OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../", "Script location with search string correctly detected, and not fooled by other scripts.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
+<html>
+<head>
+ <script src="bogus/1/OpenLayers.js-foo"></script>
+ <script src="bogus/2/foo-OpenLayers.js"></script>
+ <script src="../lib/OpenLayers.js?foo"></script>
+ <script src="bogus/3/after-OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../", "Script location with search string correctly detected, and not fooled by other scripts.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
Added: trunk/openlayers/tests/OpenLayers3.html
===================================================================
--- trunk/openlayers/tests/OpenLayers3.html (rev 0)
+++ trunk/openlayers/tests/OpenLayers3.html 2010-10-13 13:02:08 UTC (rev 10822)
@@ -0,0 +1,38 @@
+<html>
+<head>
+ <script>
+ var OpenLayers = {singleFile: true};
+ </script>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../lib/", "Script location for single file build correctly detected.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
+<html>
+<head>
+ <script>
+ var OpenLayers = {singleFile: true};
+ </script>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_OpenLayers(t) {
+ t.plan(1);
+
+ var script = document.getElementById("script");
+
+ t.eq(OpenLayers._getScriptLocation(), "../lib/", "Script location for single file build correctly detected.");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
Modified: trunk/openlayers/tests/list-tests.html
===================================================================
--- trunk/openlayers/tests/list-tests.html 2010-10-11 23:34:02 UTC (rev 10821)
+++ trunk/openlayers/tests/list-tests.html 2010-10-13 13:02:08 UTC (rev 10822)
@@ -156,7 +156,9 @@
<li>Map.html</li>
<li>Marker.html</li>
<li>Marker/Box.html</li>
- <li>OpenLayers.html</li>
+ <li>OpenLayers1.html</li>
+ <li>OpenLayers2.html</li>
+ <li>OpenLayers3.html</li>
<li>Popup.html</li>
<li>Popup/Anchored.html</li>
<li>Popup/AnchoredBubble.html</li>
More information about the Commits
mailing list