--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/marathon-serpentine-2018/reloader.php Thu Sep 20 15:10:28 2018 +0200
@@ -0,0 +1,28 @@
+<?php
+include_once('./config.php');
+header("Content-type: application/x-javascript");
+?>
+var startYoutubeCode = "<?php echo($youtube_code ? $youtube_code : '') ?>";
+
+function getCurrentYoutubeCode() {
+ var resCode = null;
+ var youtubeCodeList = [
+ <?php foreach ($youtube_code_list as $time_entry): ?>
+ [<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, "<?php echo($time_entry[2]);?>"]
+ <?php endforeach; ?>
+ ];
+ var currentTime = Date.now();
+ youtubeCodeList.some(function(timeEntry) {
+ if(currentTime >= timeEntry[0] && currentTime <= timeEntry[1]) {
+ resCode = timeEntry[2];
+ return true;
+ }
+ });
+ return resCode ? resCode : '';
+}
+
+setInterval(function() {
+ if(getCurrentYoutubeCode() !== startYoutubeCode) {
+ window.location.reload(true);
+ }
+}, 5000);