| author | veltr |
| Fri, 21 Sep 2012 11:18:57 +0900 | |
| changeset 964 | d7d56ea2d0a6 |
| parent 910 | b9f1bd52df9a |
| child 1072 | ac1eacb3aa33 |
| 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 |
||
| 906 | 6 |
if (typeof IriSP === "undefined") { |
7 |
IriSP = {}; |
|
8 |
} |
|
9 |
||
10 |
IriSP.iFrameUpdater = function(_frameId) { |
|
| 882 | 11 |
|
| 906 | 12 |
var _frame = document.getElementById(_frameId), |
13 |
_blocked = false, |
|
14 |
_updater = function() { |
|
15 |
_blocked = true; |
|
16 |
window.setTimeout(function() { |
|
17 |
_blocked = false; |
|
18 |
}, 1000); |
|
19 |
_frame.contentWindow.postMessage(document.location.hash, "*"); |
|
20 |
}; |
|
21 |
|
|
22 |
window.onhashchange = _updater; |
|
23 |
|
|
| 882 | 24 |
window.addEventListener('message', function(_e) { |
| 906 | 25 |
if (/^#/.test(_e.data) && !_blocked) { |
| 910 | 26 |
if (typeof window.history !== "undefined" && typeof window.history.replaceState !== "undefined") { |
27 |
window.history.replaceState({}, "", _e.data); |
|
28 |
} else { |
|
29 |
document.location.hash = _e.data; |
|
30 |
} |
|
|
809
1997dae651c6
added some code to handle embedding in an iframe and mediafragment.
hamidouk
parents:
589
diff
changeset
|
31 |
} |
| 882 | 32 |
}); |
33 |
|
|
| 906 | 34 |
window.setTimeout(_updater, 2000); |
35 |
|
|
36 |
}; |