| author | ymh <ymh.work@gmail.com> |
| Wed, 04 Sep 2024 17:32:50 +0200 | |
| changeset 1072 | ac1eacb3aa33 |
| parent 910 | b9f1bd52df9a |
| permissions | -rw-r--r-- |
| 589 | 1 |
/* This piece of code is directly requested by the page the player is embedded |
2 |
on. It creates the iframe the player is embedded in and it reflects changes |
|
3 |
to the iframe url in the page url. |
|
4 |
*/ |
|
5 |
||
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
910
diff
changeset
|
6 |
const iFrameUpdater = function(_frameId) { |
| 882 | 7 |
|
| 906 | 8 |
var _frame = document.getElementById(_frameId), |
9 |
_blocked = false, |
|
10 |
_updater = function() { |
|
11 |
_blocked = true; |
|
12 |
window.setTimeout(function() { |
|
13 |
_blocked = false; |
|
14 |
}, 1000); |
|
15 |
_frame.contentWindow.postMessage(document.location.hash, "*"); |
|
16 |
}; |
|
17 |
|
|
18 |
window.onhashchange = _updater; |
|
19 |
|
|
| 882 | 20 |
window.addEventListener('message', function(_e) { |
| 906 | 21 |
if (/^#/.test(_e.data) && !_blocked) { |
| 910 | 22 |
if (typeof window.history !== "undefined" && typeof window.history.replaceState !== "undefined") { |
23 |
window.history.replaceState({}, "", _e.data); |
|
24 |
} else { |
|
25 |
document.location.hash = _e.data; |
|
26 |
} |
|
|
809
1997dae651c6
added some code to handle embedding in an iframe and mediafragment.
hamidouk
parents:
589
diff
changeset
|
27 |
} |
| 882 | 28 |
}); |
29 |
|
|
| 906 | 30 |
window.setTimeout(_updater, 2000); |
31 |
|
|
32 |
}; |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
910
diff
changeset
|
33 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
910
diff
changeset
|
34 |
export default iFrameUpdater; |