diff --git a/gulp/tasks/copy.js b/gulp/tasks/copy.js
index 885522c..323c6b1 100644
--- a/gulp/tasks/copy.js
+++ b/gulp/tasks/copy.js
@@ -1,6 +1,6 @@
module.exports = function (gulp, plugins, config) {
return function copy() {
- gulp.src(['html/*.html', 'assets/favicon/*'])
+ gulp.src(['html/*.html', 'html/*.js', 'assets/favicon/*'])
.pipe(gulp.dest(config.build));
gulp.src(['assets/logo.svg', 'service-worker.js'])
.pipe(gulp.dest(config.build));
diff --git a/html/embed.html b/html/embed.html
new file mode 100644
index 0000000..a0113c3
--- /dev/null
+++ b/html/embed.html
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/html/embed.js b/html/embed.js
new file mode 100644
index 0000000..a922a14
--- /dev/null
+++ b/html/embed.js
@@ -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;
+ };
+}) ();
diff --git a/lib/main.js b/lib/main.js
index 5e03ec1..9421e5d 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -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();
window.router = new Router(language);