mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
framed replay fixes: don't use 'window.frames[0]' but get framed by 'replay_iframe' id to allow
for custom placement, multiple frames, etc... ensure outer frame url is updated to canonical (no mod) form for inverse setup as well.
This commit is contained in:
parent
578323da8a
commit
8bd8485b5a
@ -23,6 +23,7 @@ var TS_REGEX = /\/([\d]{1,14})\//;
|
|||||||
|
|
||||||
var curr_state = {};
|
var curr_state = {};
|
||||||
|
|
||||||
|
var IFRAME_ID = "replay_iframe";
|
||||||
|
|
||||||
function make_url(url, ts, mod)
|
function make_url(url, ts, mod)
|
||||||
{
|
{
|
||||||
@ -38,8 +39,9 @@ function make_url(url, ts, mod)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function push_state(url, timestamp, request_ts, capture_str, is_live) {
|
function push_state(url, timestamp, request_ts, capture_str, is_live) {
|
||||||
if (window.frames[0].WB_wombat_location) {
|
var frame = document.getElementById(IFRAME_ID).contentWindow;
|
||||||
var curr_href = window.frames[0].WB_wombat_location.href;
|
if (frame.WB_wombat_location) {
|
||||||
|
var curr_href = frame.WB_wombat_location.href;
|
||||||
|
|
||||||
// If not current url, don't update
|
// If not current url, don't update
|
||||||
if (url != curr_href) {
|
if (url != curr_href) {
|
||||||
@ -56,8 +58,9 @@ function push_state(url, timestamp, request_ts, capture_str, is_live) {
|
|||||||
state.capture_str = capture_str;
|
state.capture_str = capture_str;
|
||||||
state.is_live = is_live;
|
state.is_live = is_live;
|
||||||
|
|
||||||
if (wbinfo.replay_mod == "") {
|
var canon_url = make_url(url, state.request_ts, "");
|
||||||
window.history.replaceState(state, "", state.inner_url);
|
if (window.location.href != canon_url) {
|
||||||
|
window.history.replaceState(state, "", canon_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_state(state);
|
set_state(state);
|
||||||
@ -66,7 +69,8 @@ function push_state(url, timestamp, request_ts, capture_str, is_live) {
|
|||||||
function pop_state(state) {
|
function pop_state(state) {
|
||||||
set_state(state);
|
set_state(state);
|
||||||
|
|
||||||
window.frames[0].src = state.inner_url;
|
var frame = document.getElementById(IFRAME_ID).contentWindow;
|
||||||
|
frame.src = state.inner_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extract_ts(url)
|
function extract_ts(url)
|
||||||
@ -131,7 +135,7 @@ function iframe_loaded(event) {
|
|||||||
var request_ts;
|
var request_ts;
|
||||||
var capture_str;
|
var capture_str;
|
||||||
var is_live = false;
|
var is_live = false;
|
||||||
var iframe = window.frames[0];
|
var iframe = document.getElementById(IFRAME_ID).contentWindow;
|
||||||
|
|
||||||
if (iframe.WB_wombat_location) {
|
if (iframe.WB_wombat_location) {
|
||||||
url = iframe.WB_wombat_location.href;
|
url = iframe.WB_wombat_location.href;
|
||||||
|
@ -30,7 +30,7 @@ html, body
|
|||||||
</head>
|
</head>
|
||||||
<body style="margin: 0px; padding: 0px;">
|
<body style="margin: 0px; padding: 0px;">
|
||||||
<div class="wb_iframe_div">
|
<div class="wb_iframe_div">
|
||||||
<iframe src="{{ wbrequest.wb_prefix + embed_url }}" onload="iframe_loaded(event);" seamless="seamless" frameborder="0" scrolling="yes" class="wb_iframe"/>
|
<iframe id="replay_iframe" src="{{ wbrequest.wb_prefix + embed_url }}" onload="iframe_loaded(event);" seamless="seamless" frameborder="0" scrolling="yes" class="wb_iframe"/>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user