| author | ymh <ymh.work@gmail.com> |
| Thu, 20 Sep 2018 15:10:28 +0200 | |
| changeset 1439 | df4c992749ea |
| child 1441 | a0968287653f |
| 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 |
?> |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
var startYoutubeCode = "<?php echo($youtube_code ? $youtube_code : '') ?>"; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
function getCurrentYoutubeCode() { |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
var resCode = null; |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
var youtubeCodeList = [ |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
<?php foreach ($youtube_code_list as $time_entry): ?> |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
[<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, "<?php echo($time_entry[2]);?>"] |
|
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(); |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
youtubeCodeList.some(function(timeEntry) { |
|
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() { |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
if(getCurrentYoutubeCode() !== startYoutubeCode) { |
|
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 |
} |
|
df4c992749ea
Add dynamic code for youtube code and a automatic reloader
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
}, 5000); |