diff options
author | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
commit | a2df9a69dcc14cb70118cda2ded499055e7ee358 (patch) | |
tree | 6dd283e4e9452d38bce81ddaaae49b5335755842 /includes/system | |
parent | 84dd0735820b16b60f600284d35183d76547a71f (diff) | |
download | pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2 pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip |
m. update
Diffstat (limited to 'includes/system')
-rw-r--r-- | includes/system/compare.php | 18 | ||||
-rw-r--r-- | includes/system/history.php | 43 | ||||
-rw-r--r-- | includes/system/subsystem.php | 6 |
3 files changed, 46 insertions, 21 deletions
diff --git a/includes/system/compare.php b/includes/system/compare.php index 96eb5d9..6d69cd0 100644 --- a/includes/system/compare.php +++ b/includes/system/compare.php @@ -105,29 +105,33 @@ function getMember(string $id) { <?php foreach ($metadata["species"] ?? [] as $species): ?> <img data-bs-toggle="tooltip" title="<?php switch ($species) { case "earth": - echo "Earth pony"; + if ($metadata["robot"]) echo "Robot earth pony"; else echo "Earth pony"; break; case "alicorn": - echo "Alicorn"; + if ($metadata["robot"]) echo "Robot alicorn"; else echo "Alicorn"; + break; + + case "crystal": + if ($metadata["robot"]) echo "Robot crystal pony"; else echo "Crystal pony"; break; case "pegasus": - echo "Pegasus"; + if ($metadata["robot"]) echo "Robot pegasus"; else echo "Pegasus"; break; case "batpony": - echo "Bat pony"; + if ($metadata["robot"]) echo "Robot bat pony"; else echo "Bat pony"; break; case "unicorn": - echo "Unicorn"; + if ($metadata["robot"]) echo "Robot unicorn"; else echo "Unicorn"; break; default: - echo $species; + echo $species . "_" . $metadata["robot"]; break; - } ?>" style="width:24px;vertical-align: middle;position:relative;top:-5px;" src="/assets/species/<?= $species ?>.png" alt="<?= $species ?>"> + } ?>" style="width:24px;vertical-align: middle;position:relative;top:-5px;" src="/assets/species/<?= $species ?><?= $metadata["robot"] ? "-robot" : "" ?>.png" alt="<?= $species ?>"> <?php endforeach; ?> </span> <span class="comparison-item"> diff --git a/includes/system/history.php b/includes/system/history.php index ad4e30e..8483e3a 100644 --- a/includes/system/history.php +++ b/includes/system/history.php @@ -21,7 +21,11 @@ function getMember(string $id) { $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-switches.json"), true); uksort($switches, function ($a, $b) { - return strtotime($b["timestamp"]) - strtotime($a["timestamp"]); + if (isset($b["timestamp"]) && isset($a["timestamp"])) { + return strtotime($b["timestamp"]) - strtotime($a["timestamp"]); + } else { + return null; + } }); function getSwitchesForDay(int $day) { @@ -33,7 +37,11 @@ function getMember(string $id) { })); uksort($filtered, function ($a, $b) { - return strtotime($b["timestamp"]) - strtotime($a["timestamp"]); + if (isset($b["timestamp"]) && isset($a["timestamp"])) { + return strtotime($b["timestamp"]) - strtotime($a["timestamp"]); + } else { + return null; + } }); return $filtered; @@ -80,6 +88,13 @@ function getMember(string $id) { ?> <h2>Front history in the <?= $systemCommonName ?></h2> + <div class="alert alert-warning" id="timezone" style="display: none;"> + Times on this page are now shown using your local timezone (<span id="timezone-name">-</span>). Days start at <span id="day-start">-</span> (00:00 on UTC). + <script> + document.getElementById("day-start").innerText = new Date(<?= strtotime(date('Y-m-d')) ?> * 1000).toTimeString().substring(0, 5); + document.getElementById("timezone-name").innerText = new Date().toTimeString().split("(")[1].split(")")[0]; + </script> + </div> <h4>Today</h4> <?php @@ -100,7 +115,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 0) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 0) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -130,7 +145,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 1) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 1) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -160,7 +175,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 2) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 2) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -190,7 +205,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 3) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 3) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -220,7 +235,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 4) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 4) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -250,7 +265,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 5) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 5) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -280,7 +295,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 6) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 6) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -310,7 +325,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 7) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 7) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -340,7 +355,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 8) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 8) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -365,7 +380,7 @@ function getMember(string $id) { foreach ($fronters as $fronter): $member = getMember($fronter["member"]); ?> <div class="fronter"> - <span class="fronter-date" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> + <span class="fronter-date" data-date-time="<?= isNotToday($fronter["date"], 9) ? strtotime(date('Y-m-d', $fronter["date"])) : $fronter["date"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> <?= isNotToday($fronter["date"], 9) ? "00:00" : date('H:i', $fronter["date"]) ?> </span> <span class="fronter-profile" style="vertical-align: middle;"> @@ -376,5 +391,9 @@ function getMember(string $id) { </div> <?php endforeach; ?> </div> + <script> + Array.from(document.getElementsByClassName("fronter-date")).forEach((i) => { i.innerText = new Date(parseInt(i.getAttribute("data-date-time").trim()) * 1000).toTimeString().split(" ")[0].substring(0, 5) + " " }); + document.getElementById("timezone").style.display = ""; + </script> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file diff --git a/includes/system/subsystem.php b/includes/system/subsystem.php index 5d28cba..14d1b2a 100644 --- a/includes/system/subsystem.php +++ b/includes/system/subsystem.php @@ -1,5 +1,7 @@ <?php global $system; global $systemCommonName; global $parts; global $systemID; +if (str_ends_with($_GET['_'], "/subsystem")) header("Location: /?error=Invalid subsystem ID") and die(); + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); $subsystemID = $parts[3]; @@ -97,7 +99,7 @@ function timeAgo($time): string { $difference = round($difference); $period = $periods[$j] . ($difference >1 ? "s" :''); - return "{$difference} {$period} {$tense} "; + return "{$difference} {$period} {$tense}"; } if (getSubsystemByID($subsystemID) === null) header("Location: /?error=Invalid subsystem ID") and die(); @@ -114,7 +116,7 @@ $title = $subsystemData["name"] . " ยท " . $systemCommonName; require_once $_SER <div id="page-content"> <?php global $isLoggedIn; if ($isLoggedIn): ?> - <small style="opacity:.5;display:block;">(<a href="/edit/<?= $system ?>/<?= $subsystemID ?>">edit</a>)</small> + <small style="opacity:.5;display:block;">(<a href="/-/edit/<?= $system ?>/<?= $subsystemID ?>">edit</a>)</small> <?php endif; ?> <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystemID.html") ?> </div> |