summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-12-22 21:45:24 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-12-22 21:45:24 +0100
commit5f18267c7ebbbb55288d793e84402f5ee86fcafd (patch)
treeb05f621b94c3f4413e0f091da50c4575c65b66e3
parent31fed783e82dd065c71b234ba08ece596a081f05 (diff)
downloadpluralconnect-5f18267c7ebbbb55288d793e84402f5ee86fcafd.tar.gz
pluralconnect-5f18267c7ebbbb55288d793e84402f5ee86fcafd.tar.bz2
pluralconnect-5f18267c7ebbbb55288d793e84402f5ee86fcafd.zip
Updated pages/byfront.inc (automated)
-rw-r--r--pages/byfront.inc121
1 files changed, 103 insertions, 18 deletions
diff --git a/pages/byfront.inc b/pages/byfront.inc
index d3b8bf0..beb9275 100644
--- a/pages/byfront.inc
+++ b/pages/byfront.inc
@@ -2,7 +2,7 @@
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
-$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);
+global $app; global $_PROFILE;
?>
@@ -10,6 +10,13 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ
<div class="container">
<div id="page-content">
<h2>Members by last fronted</h2>
+ <select id="selected-system" class="form-select" style="margin-bottom: 20px;" onchange="refreshList()">
+ <option value="gdapd" <?= $_PROFILE["login"] === "raindrops" ? "select" : "" ?>>Raindrops System</option>
+ <option value="hrbom" <?= $_PROFILE["login"] === "Moonwind" ? "select" : "" ?>>Moonglow</option>
+ <option value="<?= $app["other"]["id"] ?>" <?= $_PROFILE["login"] !== "raindrops" && $_PROFILE["login"] !== "cloudburst" && $_PROFILE["login"] !== "Moonwind" ? "select" : "" ?>><?= $app["other"]["name"] ?></option>
+ <option value="ynmuc" <?= $_PROFILE["login"] === "cloudburst" ? "select" : "" ?>>Cloudburst System</option>
+ <option value="">(all systems)</option>
+ </select>
<?php $members = [
...array_map(function ($i) {
@@ -87,13 +94,91 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ
return $i;
}, array_values(array_filter(scoreOrderGlobal(), function ($i) {
return $i["_system"] === "gdapd";
+ }))),
+ ...array_map(function ($i) {
+ $system = "hrbom";
+ $i["_lastFronted"] = -1;
+ $id = $i["id"];
+ $memberData = $i;
+
+ $fronters = array_map(function ($item) {
+ return $item["id"];
+ }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
+
+ if (in_array($id, $fronters)) {
+ $i["_lastFronted"] = time();
+ } else {
+ $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
+
+ $thisMember = array_filter($switches, function ($item) use ($memberData) {
+ return in_array($memberData["id"], $item["members"]);
+ });
+
+ $thisMember = array_values($thisMember);
+ $frontingEnd = null;
+
+ if (count($thisMember) > 0) {
+ $thisIndex = array_search($thisMember[0], $switches);
+
+ $frontingStart = $thisMember[0];
+ $frontingEnd = $switches[$thisIndex - 1];
+ }
+
+ if ($frontingEnd !== null && isset($frontingStart)) {
+ $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
+ }
+ }
+
+ return $i;
+ }, array_values(array_filter(scoreOrderGlobal(), function ($i) {
+ return $i["_system"] === "hrbom";
+ }))),
+ ...array_map(function ($i) {
+ global $app;
+ $system = $app["other"]["id"];
+ $i["_lastFronted"] = -1;
+ $id = $i["id"];
+ $memberData = $i;
+
+ $fronters = array_map(function ($item) {
+ return $item["id"];
+ }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
+
+ if (in_array($id, $fronters)) {
+ $i["_lastFronted"] = time();
+ } else {
+ $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
+
+ $thisMember = array_filter($switches, function ($item) use ($memberData) {
+ return in_array($memberData["id"], $item["members"]);
+ });
+
+ $thisMember = array_values($thisMember);
+ $frontingEnd = null;
+
+ if (count($thisMember) > 0) {
+ $thisIndex = array_search($thisMember[0], $switches);
+
+ $frontingStart = $thisMember[0];
+ $frontingEnd = $switches[$thisIndex - 1];
+ }
+
+ if ($frontingEnd !== null && isset($frontingStart)) {
+ $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
+ }
+ }
+
+ return $i;
+ }, array_values(array_filter(scoreOrderGlobal(), function ($i) {
+ global $app;
+ return $i["_system"] === $app["other"]["id"];
})))
]; uasort($members, function ($a, $b) {
return $b["_lastFronted"] - $a["_lastFronted"];
- }); $members = array_reverse($members); foreach ($members as $member): if ($member["_lastFronted"] <= time() - 86400 * 21):
+ }); $members = array_reverse($members); foreach ($members as $member):
$metadata = $member["_metadata"];?>
- <div class="relation" style="margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;">
+ <div data-relation-system="<?= $member["_system"] ?>" class="relation" style="display: none; margin-bottom:10px;padding:10px;border-radius:10px;grid-template-columns: 1fr 2fr max-content;">
<a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>">
<img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;">&nbsp;<?= $member["display_name"] ?? $member["name"] ?>
</a>
@@ -106,23 +191,23 @@ $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includ
<?php endif; ?>
</div>
</div>
- <?php endif; endforeach; ?><hr><?php foreach ($members as $member): if ($member["_lastFronted"] > time() - 86400 * 21):
+ <?php endforeach; ?>
- $metadata = $member["_metadata"];?>
- <div class="relation" style="margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;">
- <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>">
- <img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;">&nbsp;<?= $member["display_name"] ?? $member["name"] ?>
- </a>
+ <script>
+ function refreshList() {
+ let system = document.getElementById("selected-system").value;
- <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;">
- <?php if ($member["_lastFronted"] === -1): ?>
- Never fronted
- <?php else: ?>
- Last fronted <?= timeAgo($member["_lastFronted"]) ?><?php if ($member["_lastFronted"] !== time()): ?> (<?= date('l j F Y', $member["_lastFronted"]) ?>)<?php endif; ?>
- <?php endif; ?>
- </div>
- </div>
- <?php endif; endforeach; ?>
+ for (let relation of document.getElementsByClassName("relation")) {
+ if (relation.getAttribute("data-relation-system") === system || system === "") {
+ relation.style.display = "grid";
+ } else {
+ relation.style.display = "none";
+ }
+ }
+ }
+
+ refreshList();
+ </script>
<style>
@media (max-width: 991px) {