-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjump.html
43 lines (36 loc) · 1.27 KB
/
jump.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Direkt Link to a Panorama inside a Theasys-Tour</title>
</head>
<body>
<script id="embed" async src="https://static.theasys.io/embed.js"></script>
<script>
const embed = document.querySelector("#embed");
embed.dataset.height = "400px";
embed.dataset.id = "my-id";
const urlParams = new URLSearchParams(window.location.search);
const defaultTour = "XlEhWs4G1i85cVdYtTVx8ANxJQmBAp";
const defaultPano = "Lfhry1a5NA";
const tour = urlParams.get("tour") || defaultTour;
const pano = urlParams.get("pano") || defaultPano;
embed.dataset.theasys = tour;
THEASYS = {};
apiListen("loaded", () => {
THEASYS.iframe = document.querySelector("#my-id").contentWindow;
apiSet("panorama", pano);
});
function apiListen(key, fn) {
const eventHandler = event => {
const data = event.data;
if(data[key]) fn(data[key]);
}
window.addEventListener("message", eventHandler, false);
}
function apiSet(key, value) {
THEASYS.iframe.postMessage({type: "api", key, action:"set", value }, "https://www.theasys.io");
}
</script>
</body>
</html>