diff options
author | Minteck <contact@minteck.org> | 2022-09-21 22:42:33 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-09-21 22:42:33 +0200 |
commit | e95b208af90cc386a7d8d1bcab426727cf4f0121 (patch) | |
tree | b293e0c644513fbeb6e9ad29be97fa6347a55e9f /includes/planner.php | |
parent | b5f589c323f415bb42ea7069cb4d1a8a2233dd69 (diff) | |
download | pluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.tar.gz pluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.tar.bz2 pluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.zip |
Update time
Diffstat (limited to 'includes/planner.php')
-rw-r--r-- | includes/planner.php | 614 |
1 files changed, 158 insertions, 456 deletions
diff --git a/includes/planner.php b/includes/planner.php index 64d87e4..8644b25 100644 --- a/includes/planner.php +++ b/includes/planner.php @@ -12,90 +12,18 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; $cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json"), true); $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-planner.json"), true); -?> - -<h2>Front planner</h2> -<table id="planner"> - <tbody> - <tr class="planner-day"> - <td colspan="4" id="planner-header-0">Today</td> - <?php - - if (!$cloudburst[date('Y-m-d')]) $cloudburst[date('Y-m-d')] = []; - $dayCloudburst = $cloudburst[date('Y-m-d')]; - if (!$raindrops[date('Y-m-d')]) $raindrops[date('Y-m-d')] = []; - $dayRaindrops = $raindrops[date('Y-m-d')]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d') ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 0);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d') ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 0);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> - +function day($display, $diff): void { global $cloudburst; global $raindrops; ?> + <?php if (!isset($display)) { + $display = date('l', time() + (86400 * $diff)); + }?> <tr class="planner-day" id="planner-header-1"> - <td colspan="4">Tomorrow</td> + <td colspan="4"><?= $display ?></td> <?php - if (!$cloudburst[date('Y-m-d', time() + 86400)]) $cloudburst[date('Y-m-d', time() + 86400)] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + 86400)]; - if (!$raindrops[date('Y-m-d', time() + 86400)]) $raindrops[date('Y-m-d', time() + 86400)] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + 86400)]; + if (!isset($cloudburst[date('Y-m-d', time() + (86400 * $diff))])) $cloudburst[date('Y-m-d', time() + (86400 * $diff))] = []; + $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * $diff))]; + if (!isset($raindrops[date('Y-m-d', time() + (86400 * $diff))])) $raindrops[date('Y-m-d', time() + (86400 * $diff))] = []; + $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * $diff))]; $index = 0; $lengthCloudburst = count($dayCloudburst); @@ -115,12 +43,16 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include <?= $index + 1 ?> </td> <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + 86400) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <?php $member = getMemberWithoutSystem($dayCloudburst[$index]); ?> + <?php if ($member["name"] === "fusion"): ?> + <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <?php else: ?> + <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <?php endif; ?> </td> <?php elseif ($index === count($dayCloudburst)): ?> <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 1);" class="planner-add-link"> + <a href="#" onclick="addFronter('cloudburst', <?= $diff ?>);" class="planner-add-link"> <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> <span class="planner-add-text">Add new fronter</span> </a> @@ -132,13 +64,17 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include <td class="planner-member-id"> <?= $index + 1 ?> </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> + <?php $member = getMemberWithoutSystem($dayRaindrops[$index]); ?> <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + 86400) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <?php if ($member["name"] === "fusion"): ?> + <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></a> + <?php else: ?> + <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> + <?php endif; ?> </td> <?php elseif ($index === count($dayRaindrops)): ?> <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 1);" class="planner-add-link"> + <a href="#" onclick="addFronter('raindrops', <?= $diff ?>);" class="planner-add-link"> <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> <span class="planner-add-text">Add new fronter</span> </a> @@ -151,368 +87,27 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include <tr class="planner-day planner-end-of-day"> <td colspan="4"> <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> + <?= getMiniName(getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> <?php else: ?> Unable to calculate who will sleep with who <?php endif; ?> </td> </tr> <tr class="planner-separator"></tr> +<?php +} +?> - <tr class="planner-day" id="planner-header-2"> - <td colspan="4"><?= date('l', time() + (86400 * 2)) ?></td> - <?php - - if (!$cloudburst[date('Y-m-d', time() + (86400 * 2))]) $cloudburst[date('Y-m-d', time() + (86400 * 2))] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * 2))]; - if (!$raindrops[date('Y-m-d', time() + (86400 * 2))]) $raindrops[date('Y-m-d', time() + (86400 * 2))] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * 2))]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 2)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 2);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 2)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 2);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> - - <tr class="planner-day"> - <td colspan="4" id="planner-header-3"><?= date('l', time() + (86400 * 3)) ?></td> - <?php - - if (!$cloudburst[date('Y-m-d', time() + (86400 * 3))]) $cloudburst[date('Y-m-d', time() + (86400 * 3))] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * 3))]; - if (!$raindrops[date('Y-m-d', time() + (86400 * 3))]) $raindrops[date('Y-m-d', time() + (86400 * 3))] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * 3))]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 3)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 3);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 3)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 3);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> - - <tr class="planner-day"> - <td colspan="4" id="planner-header-4"><?= date('l', time() + (86400 * 4)) ?></td> - <?php - - if (!$cloudburst[date('Y-m-d', time() + (86400 * 4))]) $cloudburst[date('Y-m-d', time() + (86400 * 4))] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * 4))]; - if (!$raindrops[date('Y-m-d', time() + (86400 * 4))]) $raindrops[date('Y-m-d', time() + (86400 * 4))] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * 4))]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 4)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 4);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 4)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 4);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> - - <tr class="planner-day"> - <td colspan="4" id="planner-header-5"><?= date('l', time() + (86400 * 5)) ?></td> - <?php - - if (!$cloudburst[date('Y-m-d', time() + (86400 * 5))]) $cloudburst[date('Y-m-d', time() + (86400 * 5))] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * 5))]; - if (!$raindrops[date('Y-m-d', time() + (86400 * 5))]) $raindrops[date('Y-m-d', time() + (86400 * 5))] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * 5))]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 5)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 5);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 5)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 5);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> - - <tr class="planner-day"> - <td colspan="4" id="planner-header-6"><?= date('l', time() + (86400 * 6)) ?></td> - <?php - - if (!$cloudburst[date('Y-m-d', time() + (86400 * 6))]) $cloudburst[date('Y-m-d', time() + (86400 * 6))] = []; - $dayCloudburst = $cloudburst[date('Y-m-d', time() + (86400 * 6))]; - if (!$raindrops[date('Y-m-d', time() + (86400 * 6))]) $raindrops[date('Y-m-d', time() + (86400 * 6))] = []; - $dayRaindrops = $raindrops[date('Y-m-d', time() + (86400 * 6))]; - - $index = 0; - $lengthCloudburst = count($dayCloudburst); - $lengthRaindrops = count($dayRaindrops); - $biggest = max($lengthCloudburst, $lengthRaindrops); - - ?> - </tr> - <tr class="planner-header"> - <td colspan="2">Cloudburst System</td> - <td colspan="2">Raindrops System</td> - </tr> - <?php for ($i = 0; $i <= $biggest; $i++): ?> - <tr class="planner-member"> - <?php if (isset($dayCloudburst[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <td class="planner-link"> - <?php $member = getSystemMember("ynmuc", $dayCloudburst[$index]); ?> - <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 6)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayCloudburst)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('cloudburst', 6);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - <?php if (isset($dayRaindrops[$index])): ?> - <td class="planner-member-id"> - <?= $index + 1 ?> - </td> - <?php $member = getSystemMember("gdapd", $dayRaindrops[$index]); ?> - <td class="planner-link"> - <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * 6)) ?>')"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - </td> - <?php elseif ($index === count($dayRaindrops)): ?> - <td class="planner-add-inner planner-link" colspan="2"> - <a href="#" onclick="addFronter('raindrops', 6);" class="planner-add-link"> - <img src="/assets/icons/add.svg" alt="" class="planner-add-icon"> - <span class="planner-add-text">Add new fronter</span> - </a> - </td> - <?php else: ?> - <td colspan="2" class="planner-empty"></td> - <?php endif; ?> - </tr> - <?php $index++; endfor; ?> - <tr class="planner-day planner-end-of-day"> - <td colspan="4"> - <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?> - <?= getMiniName(getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["display_name"] ?? getSystemMember("ynmuc", $dayCloudburst[count($dayCloudburst) - 1])["name"]) ?> will sleep with <?= getMiniName(getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["display_name"] ?? getSystemMember("gdapd", $dayRaindrops[count($dayRaindrops) - 1])["name"]) ?> - <?php else: ?> - Unable to calculate who will sleep with who - <?php endif; ?> - </td> - </tr> - <tr class="planner-separator"></tr> +<h2>Front planner</h2> +<table id="planner"> + <tbody> + <?php day("Today", 0) ?> + <?php day("Tomorrow", 1) ?> + <?php day(null, 2) ?> + <?php day(null, 3) ?> + <?php day(null, 4) ?> + <?php day(null, 5) ?> + <?php day(null, 6) ?> </tbody> </table> @@ -637,6 +232,20 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include cursor: pointer !important; } + .merge-mobile { + display: none; + } + + @media (max-width: 768px) { + .merge-desktop { + display: none; + } + + .merge-mobile { + display: inline; + } + } + </style> <!--suppress JSUnresolvedVariable, JSUnresolvedFunction --> @@ -703,7 +312,12 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include index: id } - document.getElementById("edit-fronter-name").innerText = names[fronting[system][date][id]] ?? fronting[system][date][id]; + if (fronting[system][date][id] === "lzlaq" || fronting[system][date][id] === "irxyh") { + document.getElementById("edit-fronter-name").innerText = "merged members"; + } else { + document.getElementById("edit-fronter-name").innerText = names[fronting[system][date][id]] ?? fronting[system][date][id]; + } + document.getElementById("edit-fronter-date").innerText = display; document.getElementById("edit-fronter-pos").innerText = ordinal(id + 1); document.getElementById("edit-fronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System"; @@ -756,11 +370,15 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include window.currentWorkingDate = date; document.getElementById("new-fronter-date").innerText = display; document.getElementById("new-fronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System"; - document.getElementById("list-" + system).style.display = ""; - document.getElementById("list-" + (system === "cloudburst" ? "raindrops" : "cloudburst")).style.display = "none"; + window.addSystem = system === "raindrops" ? "gdapd" : "ynmuc"; + + document.getElementById("list").style.display = "block"; + document.getElementById("search-results").style.display = "none"; + document.getElementById("search").value = ""; let modal = new bootstrap.Modal(document.getElementById('new-fronter')); modal.show(); + document.getElementById("search").focus(); } function confirmFronterAdd(system, id) { @@ -799,6 +417,11 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include }); } + function viewFronterPage() { + let id = fronting[window.selectedFronting["system"] === "ynmuc" ? "cloudburst" : "raindrops"][window.selectedFronting["date"]][window.selectedFronting["index"]]; + location.href = "/" + id; + } + function moveFronterUp() { Array.from(document.getElementsByClassName("edit-fronter-link")).forEach((i) => { i.classList.add("disabled"); @@ -812,7 +435,7 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include } </script> -<div class="modal fade" id="new-fronter" data-bs-backdrop="static" data-bs-keyboard="false"> +<div class="modal" id="new-fronter" data-bs-backdrop="static" data-bs-keyboard="false"> <div class="modal-dialog"> <div class="modal-content"> @@ -824,24 +447,25 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include <div class="modal-body"> <p class="text-muted">Adding for the <span id="new-fronter-system">n/a</span></p> - <div class="list-group" id="list-raindrops"> - <?php foreach (scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd") as $member): ?> - <a onclick="confirmFronterAdd('gdapd', '<?= $member['id'] ?>');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - <?php endforeach; ?> - </div> + <input type="text" placeholder="Search for a pony..." class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" id="search"> - <div class="list-group" id="list-cloudburst"> - <?php foreach (scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true), "ynmuc") as $member): ?> - <a onclick="confirmFronterAdd('ynmuc', '<?= $member['id'] ?>');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?></a> - <?php endforeach; ?> + <div id="list"> + <div class="list-group"> + <?php foreach (scoreOrderGlobal() as $member): ?> + <a id="list-pony-<?= $member['id'] ?>" onclick="confirmFronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . resolveMember($member['name']) . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a> + <?php endforeach; $member = getSystemMember("gdapd", "irxyh") ?> + <a onclick="confirmFronterAdd(window.addSystem, 'irxyh');" class="new-fronter-link member-link list-group-item list-group-item-action" href="#"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="text-muted">Multiple merged members</span></a> + </div> </div> + + <div id="search-results" class="list-group"></div> </div> </div> </div> </div> -<div class="modal fade" id="edit-fronter" data-bs-backdrop="static" data-bs-keyboard="false"> +<div class="modal" id="edit-fronter" data-bs-backdrop="static" data-bs-keyboard="false"> <div class="modal-dialog"> <div class="modal-content"> @@ -866,6 +490,10 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include <img src="/assets/icons/down.svg" style="width:24px;filter:invert(1);vertical-align: middle;"> <span style="vertical-align: middle;">Move down</span> </a> + <a class="list-group-item list-group-item-action edit-fronter-link" onclick="viewFronterPage();"> + <img src="/assets/icons/page.svg" style="width:24px;filter:invert(1);vertical-align: middle;"> + <span style="vertical-align: middle;">View page</span> + </a> </div> </div> @@ -873,6 +501,80 @@ $raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/include </div> </div> +<script src="/assets/editor/fuse.js"></script> +<!--suppress JSUnresolvedFunction --> +<script> + window.poniesList = JSON.parse(atob(`<?= base64_encode(json_encode(array_values(scoreOrderGlobal()))) ?>`)); + + const fuse = new Fuse(window.poniesList, { + includeScore: true, + keys: [ + { + name: 'name', + weight: 1 + }, + { + name: 'display_name', + weight: 1 + }, + { + name: 'id', + weight: 0.7 + }, + { + name: 'species', + weight: 0.5 + } + ] + }) + + function search(event) { + if (event.key === "Enter") { + return; + } + + let query = document.getElementById("search").value; + let results = fuse.search(query).map((i) => { + return { + id: i.item.id, + score: i.score + }; + }); + + let unfiltered = results; + + results = results.filter((i) => { + return i.score < 0.7; + }); + + console.log("Before:", unfiltered, "After:", results); + + document.getElementById("list").style.display = "none"; + document.getElementById("search-results").style.display = "block"; + document.getElementById("search-results").innerHTML = ""; + + for (let result of results) { + document.getElementById("search-results").innerHTML += document.getElementById("list-pony-" + result.id).outerHTML; + } + + console.log(results); + + if (query.trim() === "") { + document.getElementById("list").style.display = "block"; + document.getElementById("search-results").style.display = "none"; + } + } + + document.getElementById("search").onchange = document.getElementById("search").onkeyup = document.getElementById("search").onkeydown = search; + + document.getElementById("search").addEventListener("keydown", (event) => { + if (event.key === "Enter") { + document.querySelector("#search-results .new-fronter-link").click(); + event.preventDefault(); + } + }); +</script> + <?php file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json", json_encode($cloudburst)); |