diff options
author | RaindropsSys <contact@minteck.org> | 2023-03-21 16:21:21 +0100 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-03-21 16:21:21 +0100 |
commit | 475c5731bf3362b6ac8d2dc5d5b43e4b4a6117bd (patch) | |
tree | 2cff46debf9c1e13892e7babff9deb6874ecb4b2 /pages/schedules.inc | |
parent | 7ccc2de87f9e25c715dc09b9aba4eb5c66f80424 (diff) | |
download | pluralconnect-475c5731bf3362b6ac8d2dc5d5b43e4b4a6117bd.tar.gz pluralconnect-475c5731bf3362b6ac8d2dc5d5b43e4b4a6117bd.tar.bz2 pluralconnect-475c5731bf3362b6ac8d2dc5d5b43e4b4a6117bd.zip |
Updated 26 files and added 1074 files (automated)
Diffstat (limited to 'pages/schedules.inc')
-rw-r--r-- | pages/schedules.inc | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/pages/schedules.inc b/pages/schedules.inc new file mode 100644 index 0000000..bfdaf6e --- /dev/null +++ b/pages/schedules.inc @@ -0,0 +1,213 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $app; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; + +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php'; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/composer/ical/ical.php"; + +?> + +<style> + .day-gradient { + background-image: linear-gradient(180deg, rgba(7,15,36,1) 0%, rgba(36,56,83,1) 14%, rgba(165,126,57,1) 28%, rgba(37,109,201,1) 42%, rgba(47,165,208,1) 57%, rgba(252,120,15,1) 71%, rgba(38,66,97,1) 85%, rgba(7,15,36,1) 100%); + background-size: 100% 1000%; + } + + .invert { + filter: invert(1) hue-rotate(180deg); + } + + @media (max-width: 800px) { + #schedules { + grid-template-columns: 1fr !important; + } + + .schedules-separator { + display: block !important; + } + } +</style> + +<br> +<div class="container"> + <h2>Schedules</h2> + + <div id="schedules" style="margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 20px;"> + <div> + <div id="live-time-other-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px; margin-bottom: 20px;"> + <b><?= $app["other"]["name"] ?></b><br> + <h3 id="live-time-other">--:--</h3> + </div> + + <?php + + $weekDay = (int)date('N'); + + if ($weekDay < 6 && !in_array(date('Y-m-d'), $app["other"]["work"]["off"])) { + $start = ($app["other"]["work"]["start"][0] * 3600) + ($app["other"]["work"]["start"][1] * 60); + $end = ($app["other"]["work"]["end"][0] * 3600) + ($app["other"]["work"]["end"][1] * 60); + $parts = explode("|", (new DateTime("now", new DateTimeZone("America/Chicago")))->format("H|i")); + $now = ((int)$parts[0] * 3600) + ((int)$parts[1] * 60); + + if ($start < $now && $now < $end) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🗄️</span> Currently at work</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); + } elseif ($now > $end) { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> Finally off work!</b></div>'); + } elseif ($now < $start) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🗄️</span> There\'s work today</b></p>Starting ' . timeIn($start - $now, true) . '<br>Working for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); + } + } else { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> No work today!</b></div>'); + } + + ?> + + <ul> + <li><b>Anchorage:</b> <span id="live-time-other1">--:--</span></li> + <li><b>Vancouver:</b> <span id="live-time-other2">--:--</span></li> + </ul> + + <hr style="display: none;" class="schedules-separator"> + </div> + + <div> + <div id="live-time-cloudburst-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px; margin-bottom: 20px;"> + <b>Cloudburst System</b><br> + <h3 id="live-time-cloudburst">--:--</h3> + </div> + + <?php + + $calendar = new \om\IcalParser(); + $calendar->parseFile($_SERVER['DOCUMENT_ROOT'] . "/includes/data/calendar.ics"); + + $college = array_values(array_filter((array)$calendar->getEvents()->sorted(), function ($i) { + return strtotime(((array)$i["DTEND"])["date"]) > time() && date('Y-m-d', strtotime(((array)$i["DTEND"])["date"])) === date('Y-m-d') && trim(strtolower($i["SUMMARY"])) === "(cloudburst) college"; + })); + + if (count($college) > 0) { + $start = strtotime(((array)$college[0]["DTSTART"])["date"]); + $end = strtotime(((array)$college[0]["DTEND"])["date"]); + $now = time(); + + if ($start < $now && $now < $end) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🏫️</span> Currently in college</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); + } elseif ($now > $end) { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> Finally out of college!</b></div>'); + } elseif ($now < $start) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🏫️</span> Getting ready for college</b></p>Starting ' . timeIn($start - $now, true) . '<br>In college for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); + } + } else { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> No college today!</b></div>'); + } + + ?> + + <hr style="display: none;" class="schedules-separator"> + </div> + + <div> + <div id="live-time-raindrops-outer" class="day-gradient" style="text-align: center; background-color: rgba(255, 255, 255, .1); padding: 20px 0; border-radius: 10px; margin-bottom: 20px;"> + <b>Raindrops System</b><br> + <h3 id="live-time-raindrops">--:--</h3> + </div> + + <?php + + $school = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/school.json"), true); + + if (isset($school[date('Y-m-d')])) { + $today = $school[date('Y-m-d')]; + + if (count($college) > 0) { + $start = $today["firstClass"]["timestamp"] / 1000; + $end = strtotime($today["end"]); + $now = time(); + + if ($start < $now && $now < $end) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🎓️</span> Currently in school</b></p>Started ' . timeAgo($now - $start, false, true, true) . '<br>Finishing ' . timeIn($end - $now, true) . '</div>'); + } elseif ($now > $end) { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> Finally out of school!</b></div>'); + } elseif ($now < $start) { + echo('<div class="alert alert-warning"><p><b><span class="invert">🎓️</span> Getting ready for school</b></p>Starting ' . timeIn($start - $now, true) . '<br>In school for ' . timeAgo($end - $start, false, true, true, false) . '</div>'); + } + } else { + echo('<div class="alert alert-success"><b><span class="invert">🎉</span> No school today!</b></div>'); + } + } + + ?> + + <hr style="display: none;" class="schedules-separator"> + </div> + </div> +</div> + +<script> + function getDayPercentage(time) { + let hours = parseInt(time.split(":")[0]); + let minutes = parseInt(time.split(":")[1].split(" ")[0]); + + if (time.split(":")[1].split(" ")[1] === "PM") hours += 12; + if (hours === 12 && time.split(":")[1].split(" ")[1] === "AM") hours = 0; + if (hours === 24 && time.split(":")[1].split(" ")[1] === "PM") hours = 12; + + let timestamp = new Date("1970-01-01 " + hours + ":" + minutes + " UTC").getTime() / 1000; + + return (timestamp / 86400) * 100; + } + + function updateTime() { + let time1 = (new Intl.DateTimeFormat('en-US', { + timeZone: 'Europe/Paris', + hour: 'numeric', + minute: 'numeric', + hour12: true + })).format(new Date()); + + document.getElementById("live-time-raindrops").innerText = time1; + document.getElementById("live-time-raindrops-outer").style.backgroundPositionY = getDayPercentage(time1) + "%"; + + let time2 = (new Intl.DateTimeFormat('en-US', { + timeZone: 'Europe/London', + hour: 'numeric', + minute: 'numeric', + hour12: true + })).format(new Date()); + + document.getElementById("live-time-cloudburst").innerText = time2; + document.getElementById("live-time-cloudburst-outer").style.backgroundPositionY = getDayPercentage(time2) + "%"; + + let time3 = (new Intl.DateTimeFormat('en-US', { + timeZone: 'America/Chicago', + hour: 'numeric', + minute: 'numeric', + hour12: true + })).format(new Date()); + + document.getElementById("live-time-other").innerText = time3; + document.getElementById("live-time-other-outer").style.backgroundPositionY = getDayPercentage(time3) + "%"; + + document.getElementById("live-time-other1").innerText = (new Intl.DateTimeFormat('en-US', { + timeZone: 'America/Anchorage', + hour: 'numeric', + minute: 'numeric', + hour12: true + })).format(new Date()); + document.getElementById("live-time-other2").innerText = (new Intl.DateTimeFormat('en-US', { + timeZone: 'America/Vancouver', + hour: 'numeric', + minute: 'numeric', + hour12: true + })).format(new Date()); + } + + updateTime(); + + setInterval(() => { + updateTime(); + }, 10000); +</script> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> |