diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 6ce29564b1..5cb60a8243 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -314,28 +314,15 @@ "OpenLayers/Lang/en.js" ); // etc. - var agent = navigator.userAgent; - var docWrite = (agent.match("MSIE") || agent.match("Safari")); - if(docWrite) { - var allScriptTags = new Array(jsfiles.length); - } + // use "parser-inserted scripts" for guaranteed execution order + // http://hsivonen.iki.fi/script-execution/ + var allScriptTags = new Array(jsfiles.length); var host = OpenLayers._getScriptLocation() + "lib/"; for (var i=0, len=jsfiles.length; i"; - } else { - var s = document.createElement("script"); - s.src = host + jsfiles[i]; - var h = document.getElementsByTagName("head").length ? - document.getElementsByTagName("head")[0] : - document.body; - h.appendChild(s); - } - } - if (docWrite) { - document.write(allScriptTags.join("")); } + document.write(allScriptTags.join("")); } })(); diff --git a/lib/OpenLayers.js.orig b/lib/OpenLayers.js.orig new file mode 100644 index 0000000000..6ce29564b1 --- /dev/null +++ b/lib/OpenLayers.js.orig @@ -0,0 +1,345 @@ +/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/* + * @requires OpenLayers/BaseTypes.js + * @requires OpenLayers/Lang/en.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() { + /** + * 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 old single file build profiles that included both + * OpenLayers.js and OpenLayers/SingleFile.js. + */ + var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile); + + /** + * Relative path of this script. + */ + var scriptName = (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js"; + + /** + * Namespace: OpenLayers + * The OpenLayers object provides a namespace for all things OpenLayers + */ + window.OpenLayers = { + /** + * Method: _getScriptLocation + * Return the path to this script. This is also implemented in + * OpenLayers/SingleFile.js + * + * Returns: + * {String} Path to this script + */ + _getScriptLocation: (function() { + var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)"), + s = document.getElementsByTagName('script'), + src, m, l = ""; + for(var i=0, len=s.length; i"; + } else { + var s = document.createElement("script"); + s.src = host + jsfiles[i]; + var h = document.getElementsByTagName("head").length ? + document.getElementsByTagName("head")[0] : + document.body; + h.appendChild(s); + } + } + if (docWrite) { + document.write(allScriptTags.join("")); + } + } +})(); + +/** + * Constant: VERSION_NUMBER + */ +OpenLayers.VERSION_NUMBER="$Revision$";