Also handle the case where the regex does not match in OpenLayers.js::_getScriptLocation, and use a shorter variable name for the match. In addition to the reviewed patch, also added some comments about simplification in 3.0, and to make jorix happy. Finally, moved VERSION_NUMBER to the top to make it easy to see it in a minified build. r=elemoine (closes #2873)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10831 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+13
-5
@@ -7,7 +7,13 @@
|
|||||||
* @requires OpenLayers/BaseTypes.js
|
* @requires OpenLayers/BaseTypes.js
|
||||||
* @requires OpenLayers/Lang/en.js
|
* @requires OpenLayers/Lang/en.js
|
||||||
* @requires OpenLayers/Console.js
|
* @requires OpenLayers/Console.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: In 3.0, we will stop supporting build profiles that include
|
||||||
|
* OpenLayers.js. This means we will not need the singleFile and scriptFile
|
||||||
|
* variables, because we don't have to handle the singleFile case any more.
|
||||||
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
/**
|
/**
|
||||||
@@ -30,8 +36,9 @@
|
|||||||
*/
|
*/
|
||||||
window.OpenLayers = {
|
window.OpenLayers = {
|
||||||
/**
|
/**
|
||||||
* Function: _getScriptLocation
|
* Method: _getScriptLocation
|
||||||
* Return the path to this script.
|
* Return the path to this script. This is also implemented in
|
||||||
|
* OpenLayers/SingleFile.js
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} Path to this script
|
* {String} Path to this script
|
||||||
@@ -39,7 +46,8 @@
|
|||||||
_getScriptLocation: (function() {
|
_getScriptLocation: (function() {
|
||||||
var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)");
|
var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)");
|
||||||
var s = document.getElementsByTagName('script');
|
var s = document.getElementsByTagName('script');
|
||||||
var l = s[s.length-1].getAttribute("src").match(r)[1];
|
var m = s[s.length-1].getAttribute("src").match(r);
|
||||||
|
var l = m ? m[1] : "";
|
||||||
return (function() { return l; });
|
return (function() { return l; });
|
||||||
})()
|
})()
|
||||||
};
|
};
|
||||||
@@ -52,7 +60,7 @@
|
|||||||
*
|
*
|
||||||
* When we *are* part of a SFL build we do not dynamically include the
|
* When we *are* part of a SFL build we do not dynamically include the
|
||||||
* OpenLayers library code as it will be appended at the end of this file.
|
* OpenLayers library code as it will be appended at the end of this file.
|
||||||
*/
|
*/
|
||||||
if(!singleFile) {
|
if(!singleFile) {
|
||||||
var jsfiles = new Array(
|
var jsfiles = new Array(
|
||||||
"OpenLayers/Util.js",
|
"OpenLayers/Util.js",
|
||||||
|
|||||||
@@ -4,16 +4,30 @@
|
|||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
var OpenLayers = {
|
var OpenLayers = {
|
||||||
|
/**
|
||||||
|
* Constant: VERSION_NUMBER
|
||||||
|
*/
|
||||||
|
VERSION_NUMBER: "$Revision$",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant: singleFile
|
||||||
|
* TODO: remove this in 3.0 when we stop supporting build profiles that
|
||||||
|
* include OpenLayers.js
|
||||||
|
*/
|
||||||
singleFile: true,
|
singleFile: true,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: _getScriptLocation
|
||||||
|
* Return the path to this script. This is also implemented in
|
||||||
|
* OpenLayers.js
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {String} Path to this script
|
||||||
|
*/
|
||||||
_getScriptLocation: (function() {
|
_getScriptLocation: (function() {
|
||||||
var s = document.getElementsByTagName('script');
|
var s = document.getElementsByTagName('script');
|
||||||
var match = s[s.length-1].getAttribute("src").match(/(^|(.*?\/))(OpenLayers\.js)(\?|$)/);
|
var m = s[s.length-1].getAttribute("src").match(/(^|(.*?\/))(OpenLayers\.js)(\?|$)/);
|
||||||
var l = match ? match[1] : "";
|
var l = m ? m[1] : "";
|
||||||
return (function() { return l; });
|
return (function() { return l; });
|
||||||
})()
|
})()
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Constant: VERSION_NUMBER
|
|
||||||
*/
|
|
||||||
OpenLayers.VERSION_NUMBER="$Revision$";
|
|
||||||
|
|||||||
Reference in New Issue
Block a user