-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreldiv.js
100 lines (84 loc) · 2.54 KB
/
reldiv.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var timedout;
var milliseconds;
var mytimer;
var url;
//$("#loadstuff").click(
function setup() {
milliseconds = (new Date).getTime();
var expires = Math.round(milliseconds/1000)+200;
//debugger;
var path = 'players/kvnuuipe-4FuizHuQ.js';
var secret='KsQ5gv8wydgEf6PtVuV0xqTi';
var thevalue=path+':'+expires+':'+secret;
var hash = md5(thevalue);
url = 'https://content.jwplatform.com/'+path+'?exp='+expires+'&sig='+hash;
//url='https://cdn.jwplayer.com/players/kvnuuipe-4FuizHuQ.js';
console.log(url);
console.log(expires);
mytimer = setInterval(checkurlExists, 10000);
addthescript(document);
var iframe = document.getElementById('hack_iframe');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
addthescript(innerDoc);
}
//);
function addthescript(thedocument)
{
//debugger;
var viddiv = thedocument.getElementById('vid'),
script = thedocument.createElement('script'); // Create the script
// Set the script source
script.src = url;
viddiv.appendChild(script); // Append it
}
function checkurlExists()
{
//alert('checking');
urlExists(url, function(exists){
//debugger;
var durationsec = Math.round(((new Date).getTime()-milliseconds)/1000);
if(exists){
document.getElementById('lbltipAddedComment').innerHTML = 'URL still available after ' + durationsec + ' sec';
document.getElementById("lbltipAddedComment").style.color = "green";
console.log('still there after ' + durationsec + ' ' + url);
}
else
{
if(!timedout)
{
timedout=durationsec;
console.log('not available anymore, stopped after ' + timedout);
}
document.getElementById('lbltipAddedComment').innerHTML = 'URL not available anymore after ' + timedout + ' sec';
document.getElementById("lbltipAddedComment").style.color = "red";
//clearTimeout(mytimer);
}
});
var iframe = document.getElementById('hack_iframe');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
addthescript(innerDoc);
}
function urlExists(url, callback){
$.ajax({
type: 'HEAD',
url: url,
success: function(textStatus, jqXHR){
//debugger;
console.log('ajax success ' + jqXHR.status);
//console.log(message);
//console.log(text);
//console.log(jqXHR.getResponseHeader('Content-Length'));
callback(true);
},
complete: function(xhr, textStatus) {
console.log('COMPLETE: ' + xhr.status);
} ,
error: function(jqXHR) {
console.log('ajax error ' + jqXHR.status);
//console.log(message);
//console.log(text);
//console.log(jqXHR.getResponseHeader('Content-Length'));
callback(false);
}
});
}