-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplay.html
59 lines (50 loc) · 2 KB
/
replay.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html>
<head>
<title>Replay a Page</title>
<link rel="stylesheet" href="/static/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body>
<iframe id="target" class="target replay" src="{{ metadata.origin }}/pre"></iframe>
<div id="overlay">REPLAY
<div id="control" class="action">assume control</div>
<div id="keepstate" class="action">keep state & control</div>
</div>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
$(document).ready(function () {
var replay_key = '{{ replay_key }}';
var height = {{ metadata.height }};
var width = {{ metadata.width }};
var target = window.targetFrame = $('iframe.target')[0].contentWindow;
$('#target').height(height);
$('#target').width(width);
$('#control').click(function() {
$('#overlay').fadeOut();
target.postMessage('cleanup', '*');
});
$('#keepstate').click(function() {
$('#overlay').fadeOut();
target.postMessage('keep-state', '*');
target.postMessage('cleanup', '*');
});
$(window).on('message', function (e) {
console.log("reanimator finished");
$('.action').fadeIn();
$('#overlay').css('background-color', '#DEDEDE');
});
function data_received(data, status, jqxhr) {
setTimeout(function() {
console.log(data);
var replay_data = { log : JSON.stringify(data),
path : "{{ metadata.origin }}{{ metadata.pathname }}" };
console.log('Replaying.');
target.postMessage(replay_data, "*");
}, 1000);
}
$.get("/replay/get/" + replay_key, undefined, data_received, 'json');
$(".action").hide();
});
</script>
</body>
</html>