SIMPLE and WHITESPACE builds

This commit is contained in:
Éric Lemoine
2013-02-22 23:14:47 +01:00
parent b14912567b
commit 6b9e79171b
4 changed files with 99 additions and 10 deletions
+37 -8
View File
@@ -6,9 +6,9 @@
* This loader is used for the hosted examples. It is used in place of the
* development loader (examples/loader.js).
*
* ol.css and ol.js are built with Plovr/Closure, based on build/ol.json.
* (`build.py build` builds them). They are located in the ../build/
* directory, relatively to this script.
* 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.
*
* The script should be named loader.js. So it needs to be renamed to
* loader.js from loader_hosted_examples.js.
@@ -19,9 +19,27 @@
*/
(function() {
var scripts = document.getElementsByTagName('script');
var i, src, index, search, chunks, pair, params = {};
var i, pair;
var href = window.location.href, start, end, paramsString, pairs,
pageParams = {};
if (href.indexOf('?') > 0) {
start = href.indexOf('?') + 1;
end = href.indexOf('#') > 0 ? href.indexOf('#') : href.length;
paramsString = href.substring(start, end);
pairs = paramsString.split(/[&;]/);
for (i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
if (pair[0]) {
pageParams[decodeURIComponent(pair[0])] =
decodeURIComponent(pair[1]);
}
}
}
var scripts = document.getElementsByTagName('script');
var src, index, search, chunks, scriptParams = {};
for (i = scripts.length - 1; i >= 0; --i) {
src = scripts[i].getAttribute('src');
if (~(index = src.indexOf('loader.js?'))) {
@@ -29,18 +47,29 @@
chunks = search ? search.split('&') : [];
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
if (pair[0]) {
scriptParams[decodeURIComponent(pair[0])] =
decodeURIComponent(pair[1]);
}
}
break;
}
}
var oljs = 'ol.js', mode;
if ('mode' in pageParams) {
mode = pageParams.mode.toLowerCase();
if (mode != 'advanced') {
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/ol.js">' +
'src="../build/' + oljs + '">' +
'</scr' + 'ipt>');
document.write('<scr' + 'ipt type="text/javascript" ' +
'src="' + encodeURIComponent(params.id) + '.js">' +
'src="' + encodeURIComponent(scriptParams.id) + '.js">' +
'</scr' + 'ipt>');
}());
+24
View File
@@ -0,0 +1,24 @@
{
"id": "ol-simple",
"externs": [
"externs/bingmaps.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
"inherits": "ol.json",
"inputs": [
"build/src/internal/src/requireall.js",
"build/src/internal/src/types.js"
],
"mode": "SIMPLE",
// Note: we can't have a (function(){%output%})() output wrapper with
// WHITESPACE and SIMPLE modes. See this link for explanations:
// https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
"output-wrapper": "%output%"
}
+24
View File
@@ -0,0 +1,24 @@
{
"id": "ol-whitespace",
"externs": [
"externs/bingmaps.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
"inherits": "ol.json",
"inputs": [
"build/src/internal/src/requireall.js",
"build/src/internal/src/types.js"
],
"mode": "WHITESPACE",
// Note: we can't have a (function(){%output%})() output wrapper with
// WHITESPACE and SIMPLE modes. See this link for explanations:
// https://groups.google.com/forum/#!topic/plovr/gQyZEa2NpsU
"output-wrapper": "%output%"
}