summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/OLLoader.js
blob: a2311c7e2ffa56077b76281c362d4902d2662f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Adding a mode parameter with "build" as value in the run-tests.html will 
// make usage of the build version of the library.
// get the OLLoader.js script location
(function() {
    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 results = regex.exec( href );
    l += (results && results[1] == 'build') ? 
        "../build/OpenLayers.js" : "../lib/OpenLayers.js"; 
    scriptTag = "<script src='" + l + "'></script>"; 
    document.write(scriptTag);
})();