Extent hosted loader to support debug mode

This commit is contained in:
Éric Lemoine
2013-03-06 19:19:11 +01:00
parent 74b8fea679
commit 757401313b

View File

@@ -1,17 +1,15 @@
/**
*
* Loader to add ol.css, ol.js and the example-specific js file to the
* documents.
*
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
* ol.css, ol.js, ol-simple.js, and ol-whitespace.js are built with
* Plovr/Closure. `build.py build` builds them. They are located in the
* ../build/ directory, relatively to this script.
* ol.css, ol.js, ol-simple.js, ol-whitespace.js, and ol-deps.js are built
* by OL3's build.py script. They are located in the ../build/ directory,
* relatively to this script.
*
* The script should be named loader.js. So it needs to be renamed to
* loader.js from loader_hosted_examples.js.
* The script must be named loader.js.
*
* Usage:
*
@@ -59,17 +57,23 @@
var oljs = 'ol.js', mode;
if ('mode' in pageParams) {
mode = pageParams.mode.toLowerCase();
if (mode != 'advanced') {
if (mode == 'debug') {
mode = 'raw';
}
if (mode != 'advanced' && mode != 'raw') {
oljs = 'ol-' + mode + '.js';
}
}
document.write('<link rel="stylesheet" href="../build/ol.css" '+
'type="text/css">');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="../build/' + oljs + '">' +
'</scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="' + encodeURIComponent(scriptParams.id) + '.js">' +
'</scr' + 'ipt>');
var scriptId = encodeURIComponent(scriptParams.id);
document.write('<link rel="stylesheet" href="../build/ol.css" type="text/css">');
if (mode != 'raw') {
document.write('<scr' + 'ipt type="text/javascript" src="../build/' + oljs + '"></scr' + 'ipt>');
} else {
window.CLOSURE_NO_DEPS = true; // we've got our own deps file
document.write('<scr' + 'ipt type="text/javascript" src="../closure-library/closure/goog/base.js"></scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" src="../build/ol-deps.js"></scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" src="' + scriptId + '-require.js"></scr' + 'ipt>');
}
document.write('<scr' + 'ipt type="text/javascript" src="' + scriptId + '.js"></scr' + 'ipt>');
}());