From f4b20175cc9a9de7dfbebedb5476749f603060c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 16 Oct 2012 21:51:48 +0200 Subject: [PATCH 1/4] Add a specific loader for hosted examples This loader is responsible for adding ol.js, ol.css and the example-specific js script to the document. This is the loader used in examples when hosted. --- build/loader_hosted_examples.js | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 build/loader_hosted_examples.js diff --git a/build/loader_hosted_examples.js b/build/loader_hosted_examples.js new file mode 100644 index 0000000000..3ec22aa5e2 --- /dev/null +++ b/build/loader_hosted_examples.js @@ -0,0 +1,46 @@ +/** + * + * 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 and ol.js are built with Plovr/Closure, based build/ol.json. + * (`make build` should build 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. + * + * Usage: + * + * + */ + +(function() { + var scripts = document.getElementsByTagName('script'); + + var i, src, index, search, chunks, pair, params = {}; + for (i = scripts.length - 1; i >= 0; --i) { + src = scripts[i].getAttribute('src'); + if (~(index = src.indexOf('loader.js?'))) { + search = src.substr(index + 10); + chunks = search ? search.split('&') : []; + for (i = chunks.length - 1; i >= 0; --i) { + pair = chunks[i].split('='); + params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); + } + break; + } + } + + document.write(''); + document.write('' + + ''); + document.write('' + + ''); +}()); From 190e21f79631dfc732152fc90563ad6eeb50810a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 16 Oct 2012 21:55:12 +0200 Subject: [PATCH 2/4] The loader adds link tag for ol.css --- examples/full-screen.html | 1 - examples/loader.js | 2 ++ examples/overlay-and-popup.html | 1 - examples/side-by-side.html | 1 - examples/two-layers.html | 1 - 5 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/full-screen.html b/examples/full-screen.html index f61977613c..a8ab852868 100644 --- a/examples/full-screen.html +++ b/examples/full-screen.html @@ -12,7 +12,6 @@ height: 100%; } - ol3 full-screen demo diff --git a/examples/loader.js b/examples/loader.js index 3ea91f7536..52feee5a4e 100644 --- a/examples/loader.js +++ b/examples/loader.js @@ -54,6 +54,8 @@ pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key])); } + document.write(''); var url = 'http://' + host + '/compile?' + pairs.join('&'); document.write(''); }()); diff --git a/examples/overlay-and-popup.html b/examples/overlay-and-popup.html index 67bba0aa9b..fd0d44eaee 100644 --- a/examples/overlay-and-popup.html +++ b/examples/overlay-and-popup.html @@ -66,7 +66,6 @@ margin-left: -13px; } - ol3 overlay-and-popup demo diff --git a/examples/side-by-side.html b/examples/side-by-side.html index c1c16f3220..da4a0472e3 100644 --- a/examples/side-by-side.html +++ b/examples/side-by-side.html @@ -2,7 +2,6 @@ -