[OpenLayers-Commits] r10927 - addins/timedpointtrack/trunk/lib
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Nov 29 06:24:19 EST 2010
Author: ahocevar
Date: 2010-11-29 03:24:19 -0800 (Mon, 29 Nov 2010)
New Revision: 10927
Modified:
addins/timedpointtrack/trunk/lib/TimedPointTrack.js
Log:
fixed single file loading
Modified: addins/timedpointtrack/trunk/lib/TimedPointTrack.js
===================================================================
--- addins/timedpointtrack/trunk/lib/TimedPointTrack.js 2010-11-29 10:53:54 UTC (rev 10926)
+++ addins/timedpointtrack/trunk/lib/TimedPointTrack.js 2010-11-29 11:24:19 UTC (rev 10927)
@@ -8,17 +8,28 @@
* Addin: TimedPointTrack
*/
(function() {
- var singleFile = (OpenLayers._scriptName == "OpenLayers.js");
- var addinPath = OpenLayers._getScriptLocation() +
- (singleFile ? "" : "addins/timedpointtrack/trunk/");
+ var singleFile = OpenLayers.singleFile;
if (!singleFile) {
+ var r = new RegExp("(^|(.*?\\/))(TimedPointTrack\.js)(\\?|$)"),
+ s = document.getElementsByTagName('script'),
+ src, m, addinPath = "";
+ for (var i=0, len=s.length; i<len; i++) {
+ src = s[i].getAttribute('src');
+ if (src) {
+ var m = src.match(r);
+ if (m) {
+ addinPath = m[1];
+ break;
+ }
+ }
+ }
+
var jsfiles = new Array(
"OpenLayers/Control/TimeDisplay.js",
"OpenLayers/Control/TimeSlider.js",
"OpenLayers/Control/TimeSliderBar.js",
- "OpenLayers/Layer/TimedPointTrack.js",
- "OpenLayers/Layer/TimedWMSTrack.js"
+ "OpenLayers/Layer/TimedPointTrack.js"
);
var agent = navigator.userAgent;
@@ -26,14 +37,14 @@
if(docWrite) {
var allScriptTags = new Array(jsfiles.length);
}
- var host = addinPath + "lib/";
+
for (var i=0, len=jsfiles.length; i<len; i++) {
if (docWrite) {
- allScriptTags[i] = "<script src='" + host + jsfiles[i] +
+ allScriptTags[i] = "<script src='" + addinPath + jsfiles[i] +
"'></script>";
} else {
var s = document.createElement("script");
- s.src = host + jsfiles[i];
+ s.src = addinPath + jsfiles[i];
var h = document.getElementsByTagName("head").length ?
document.getElementsByTagName("head")[0] :
document.body;
@@ -48,7 +59,8 @@
/**
* APIProperty: OpenLayers.TimedPointTrackImgPath
*/
- OpenLayers.TimedPointTrackImgPath = addinPath + "img/";
+ OpenLayers.TimedPointTrackImgPath = singleFile ? OpenLayers.ImgPath :
+ addinPath.replace("/lib/", "/img/");
/**
* Function: add
More information about the Commits
mailing list