Better embeding support + example
This commit is contained in:
parent
e76c9910d0
commit
4be1964c56
|
@ -1,6 +1,6 @@
|
||||||
module.exports = function (gulp, plugins, config) {
|
module.exports = function (gulp, plugins, config) {
|
||||||
return function copy() {
|
return function copy() {
|
||||||
gulp.src(['html/*.html', 'assets/favicon/*'])
|
gulp.src(['html/*.html', 'html/*.js', 'assets/favicon/*'])
|
||||||
.pipe(gulp.dest(config.build));
|
.pipe(gulp.dest(config.build));
|
||||||
gulp.src(['assets/logo.svg', 'service-worker.js'])
|
gulp.src(['assets/logo.svg', 'service-worker.js'])
|
||||||
.pipe(gulp.dest(config.build));
|
.pipe(gulp.dest(config.build));
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<iframe src="./index.html" style="border: 1px solid red; width: 95%; height: 95%" id="meshviewer-embedded"></iframe>
|
||||||
|
<script type="text/javascript" src="./embed.js" />
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,24 @@
|
||||||
|
(function() {
|
||||||
|
var iframe=document.getElementById("meshviewer-embedded")
|
||||||
|
if (!iframe) {
|
||||||
|
console.log("IFrame 'meshviewer-embedded' not found")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!iframe.contentWindow) {
|
||||||
|
console.log("Element 'meshviewer-embedded' seems not to be a valid iframe")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (document.location.hash) {
|
||||||
|
window.setTimeout(function() {
|
||||||
|
iframe.contentWindow.location.hash = document.location.hash;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
iframe.contentWindow.addEventListener("message", (event) => {
|
||||||
|
if (event && event.data && event.data.hash) {
|
||||||
|
window.location.hash = event.data.hash;
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
window.onhashchange = function () {
|
||||||
|
iframe.contentWindow.location.hash = document.location.hash;
|
||||||
|
};
|
||||||
|
}) ();
|
|
@ -71,6 +71,10 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.onhashchange = function () {
|
||||||
|
window.postMessage({hash: window.location.hash}, '*');
|
||||||
|
};
|
||||||
|
|
||||||
var language = new Language();
|
var language = new Language();
|
||||||
window.router = new Router(language);
|
window.router = new Router(language);
|
||||||
|
|
||||||
|
|
Reference in New Issue