Files
openlayers/demo/loader.js
2012-06-23 20:00:28 +02:00

36 lines
1.3 KiB
JavaScript

// the following code includes the sourc-files of OpenLayers as they are
// defined in ol.js.
//
// You can control in which form the source will be loaded by passing
// URL-parameters:
//
// - host
// where the plovr compiler is running, if not passed this defaults to the
// current host on port 9810
//
// - mode
// which mode of compilation should be applied. Common values for this are
// RAW, SIMPLE or ADVANCED. If not provided, SIMPLE is used.
(function(doc, l){
var hostRegex = /[\\?&]host=([^&#]*)/,
modeRegex = /[\\?&]mode=([^&#]*)/,
idRegex = /[\\?&]id=([^&#]*)/,
hostResult = hostRegex.exec(l.href),
modeResult = modeRegex.exec(l.href),
idResult = idRegex.exec(l.href),
host = (hostResult && hostResult[1])
? hostResult[1]
: (l.host)
? l.host + ':9810'
: 'localhost:9810',
mode = (modeResult && modeResult[1])
? modeResult[1]
: 'SIMPLE',
id = (idResult && idResult[1])
? idResult[1]
: 'ol',
script = '<sc' + 'ript type="text/javascript" '
+ 'src="http://' + host + '/compile?id=' + id + '&amp;mode=' + mode + '">'
+ '</scr' + 'ipt>';
doc.write(script);
})(document, location);