diff options
Diffstat (limited to 'includes/functions.php')
-rw-r--r-- | includes/functions.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/includes/functions.php b/includes/functions.php index db4a8df..1a2bf4c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -7,7 +7,7 @@ if (!function_exists("getMiniName")) { function getMiniName(string $name) { $parts = explode(" ", $name); - if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly") { + if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy") { if (str_contains($parts[0], "/")) { return explode("/", $parts[0])[0]; } else { @@ -19,6 +19,23 @@ if (!function_exists("getMiniName")) { } } +if (!function_exists("withCaretakersDown")) { + function withCaretakersDown(array $ordered): array { + $caretakersNo = []; + $caretakersYes = []; + + foreach ($ordered as $item) { + if ($item["_metadata"]["little"] === 2) { + $caretakersYes[] = $item; + } else { + $caretakersNo[] = $item; + } + } + + return [...$caretakersNo, ...$caretakersYes]; + } +} + if (!function_exists("getSystemMember")) { function getSystemMember(string $system, string $id) { $systemID = $system; @@ -61,7 +78,7 @@ if (!function_exists("showMembersFromList")) { <a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;"><div> <img alt="" src="' . $member['avatar_url'] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> <div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['display_name'] ?? $member['name']) . '</div> -<div style="text-decoration:none !important;color:black !important;"><code style="text-decoration:none !important;color:white !important;">' . ($member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '</code></div> +<div style="text-decoration:none !important;color:black !important;"><code style="text-decoration:none !important;color:white !important;">' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '</code></div> </div></div></a>'); }} } @@ -114,13 +131,13 @@ if (!function_exists("showSystem")) { $i["system"] = $id; return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id-members.json"), true), function ($i) use ($travelling) { - return !$travelling[$i['id']]['travelling']; + return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']); })), ...array_map(function ($i) use ($id) { $i["travelling"] = true; $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "gdapd" ? "ynmuc" : "gdapd") . "-members.json"), true), function ($i) use ($travelling) { - return $travelling[$i['id']]['travelling']; + return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; }))], $id)); echo('</div> @@ -162,7 +179,7 @@ if (!function_exists("timeAgo")) { $time = strtotime($time); } - $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; + $periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); $now = time(); @@ -182,7 +199,7 @@ if (!function_exists("timeAgo")) { $difference = round($difference); - $period = $periods[$j] . ($difference >1 ? "s" :''); + $period = $periods[$j]; return "{$difference} {$period} {$tense}"; } } |