forked from tgandrews/tal-performance-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoinjector.html
51 lines (47 loc) · 1.57 KB
/
autoinjector.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
<html>
<head>
<title>TAL Performance monitor auto injector</title>
</head>
<body>
<h1>TAL auto injector</h1>
<form id="url" onsubmit="formSubmit(this); return false;">
<label for="talUrl">TAL Application URL:</label>
<input type="text" name="talUrl" value="http://pal.sandbox.dev.bbc.co.uk/iplayer/bigscreen/?brand=default&model=webkit&config=beta" />
<input type="submit" value="Submit" />
</form>
<iframe id="talApp"></iframe>
<script type="text/javascript">
var contentLoaded = function (iframe) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://10.10.14.27/~andret04/tv/talperformancemonitor.js'
var iframeDocument = iframe.contentDocument;
iframeDocument.getElementsByTagName('head')[0].appendChild(script);
}
var formSubmit = function (form) {
var iframe = document.getElementById('talApp');
iframe.src = 'about:blank';
var talAppUrl = form.talUrl.value;
console.log(talAppUrl);
iframe.height = 720;
iframe.width = 1280;
var inter = window.setInterval(function() {
var iframeDocument = iframe.contentDocument;
if (iframeDocument.URL === talAppUrl) {
var currentState = iframeDocument.readyState;
var previous = '';
if (currentState !== previous) {
console.log(currentState);
}
if (currentState === "interactive") {
window.clearInterval(inter);
contentLoaded(iframe);
}
}
}, 5);
iframe.src = talAppUrl;
return false;
};
</script>
</body>
</html>