Add fallback when examples are opened w/ file://.

When opening an example through the `file:`-protocol, e.g.
`file:///ol3/examples/full-screen.html` our `loader.js` would inject
a `<script>` tag with a `src` pointing to an illegal URL
`http://:9810/compile?mode=ADVANCED&id=full-screen`.

This changes the respective logic, so that in the case that we are accessed
through the `file:`-protocol, we fallback to using `localhost` as hostname
for the plovr-compiler.

The examples that do not use XHR (like e.g. `wms-capabilities.html`) now
work as expected when accessed through `file:`-protocol.
This commit is contained in:
Marc Jansen
2013-03-15 10:29:01 +01:00
parent 8692c42318
commit 2641a1135f

View File

@@ -23,6 +23,9 @@
mode: 'ADVANCED',
id: 'ol'
};
if (window.location.protocol === 'file:' && !params.hostname) {
params.hostname = 'localhost';
}
var chunks, search, pair;
var src, index, id, i;