| author | ymh <ymh.work@gmail.com> |
| Sun, 23 Sep 2018 17:14:07 +0200 | |
| changeset 1479 | 2b510a3a0f7d |
| parent 1474 | 53f0f4ed20c8 |
| permissions | -rw-r--r-- |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
include_once('./config.php'); |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
header("Content-type: application/x-javascript"); |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
?> |
| 1474 | 5 |
var startEmbedCode = '<?php echo(addslashes($islive_embed ? $islive_embed : '')) ?>'; |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
| 1450 | 7 |
function getCurrentEmbedCode() { |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
var resCode = null; |
| 1450 | 9 |
var embedCodeList = [ |
10 |
<?php foreach ($embed_code_list as $time_entry): ?> |
|
| 1474 | 11 |
[<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, '<?php echo(addslashes($time_entry[2]));?>'], |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
<?php endforeach; ?> |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
]; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
var currentTime = Date.now(); |
| 1450 | 15 |
embedCodeList.some(function(timeEntry) { |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
if(currentTime >= timeEntry[0] && currentTime <= timeEntry[1]) { |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
resCode = timeEntry[2]; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
return true; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
} |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
}); |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
return resCode ? resCode : ''; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
} |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
|
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
setInterval(function() { |
| 1450 | 25 |
if(getCurrentEmbedCode() !== startEmbedCode) { |
|
1439
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
window.location.reload(true); |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
} |
| 1450 | 28 |
}, 60000); |