summaryrefslogtreecommitdiff
path: root/includes/planner.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/planner.inc')
-rw-r--r--includes/planner.inc1025
1 files changed, 1025 insertions, 0 deletions
diff --git a/includes/planner.inc b/includes/planner.inc
new file mode 100644
index 0000000..da25770
--- /dev/null
+++ b/includes/planner.inc
@@ -0,0 +1,1025 @@
+<?php
+
+require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/travelling.inc"; global $travelling;
+require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/score.inc";
+require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/pronouns.inc";
+require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/bitset.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; global $isUserLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/rainbow.inc";
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
+
+$cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json"), true);
+$raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json"), true);
+
+foreach ($cloudburst as $id => $day) {
+ foreach ($day as $index => $fronter) {
+ if (is_string($fronter)) {
+ $cloudburst[$id][$index] = [$fronter];
+ } else if (is_array($fronter)) {
+ if (count($fronter) < 2) {
+ if (!isset($cloudburst[$id][$index][0])) $cloudburst[$id][$index][0] = null;
+ $cloudburst[$id][$index][1] = null;
+ } else if (count($fronter) > 2) {
+ $array = [];
+
+ if (isset($cloudburst[$id][$index][0])) {
+ $array[0] = $cloudburst[$id][$index][0];
+ } else {
+ $array[0] = null;
+ }
+
+ if (isset($cloudburst[$id][$index][1])) {
+ $array[1] = $cloudburst[$id][$index][1];
+ } else {
+ $array[1] = null;
+ }
+
+ $cloudburst[$id][$index] = $array;
+ }
+ }
+ }
+}
+
+foreach ($raindrops as $id => $day) {
+ foreach ($day as $index => $fronter) {
+ if (is_string($fronter)) {
+ $raindrops[$id][$index] = [$fronter];
+ } else if (is_array($fronter)) {
+ if (count($fronter) < 2) {
+ if (!isset($raindrops[$id][$index][0])) $raindrops[$id][$index][0] = null;
+ $raindrops[$id][$index][1] = null;
+ } else if (count($fronter) > 2) {
+ $array = [];
+
+ if (isset($raindrops[$id][$index][0])) {
+ $array[0] = $raindrops[$id][$index][0];
+ } else {
+ $array[0] = null;
+ }
+
+ if (isset($raindrops[$id][$index][1])) {
+ $array[1] = $raindrops[$id][$index][1];
+ } else {
+ $array[1] = null;
+ }
+
+ $raindrops[$id][$index] = $array;
+ }
+ }
+ }
+}
+
+function day($display, $diff): void { if ($diff < 0) $disabled = true; else $disabled = false; global $cloudburst; global $raindrops; ?>
+ <?php if (!isset($display)) {
+ $display = date('l', time() + (86400 * $diff));
+ }?>
+ <tr class="planner-day" id="planner-header-<?= $diff ?>" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>>
+ <td colspan="10"><?= $display ?></td>
+ <?php
+
+ 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);
+ $lengthRaindrops = count($dayRaindrops);
+ $biggest = max($lengthCloudburst, $lengthRaindrops);
+
+ ?>
+ </tr>
+ <tr class="planner-header" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>>
+ <td colspan="5">Cloudburst System</td>
+ <td colspan="5">Raindrops System</td>
+ </tr>
+ <?php for ($i = 0; $i <= $biggest; $i++): ?>
+ <tr class="planner-member" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>>
+ <?php if (isset($dayCloudburst[$index])): ?>
+ <td class="planner-member-id">
+ <?= $index + 1 ?>
+ </td>
+ <td class="planner-link" style="width:50vw;" <?php if (!isset($dayCloudburst[$index][1])): ?>colspan="3" <?php else: ?>colspan="2"<?php endif; ?>>
+ <?php $member = getMemberWithoutSystem($dayCloudburst[$index][0]); ?>
+ <?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="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a>
+ <?php else: ?>
+ <a class="member-link" onclick="openEditFronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a>
+ <?php endif; ?>
+ </td>
+ <?php if (!isset($dayCloudburst[$index][1])): ?>
+ <td class="planner-cofronter-inner planner-link" style="width:5%;text-align:center;">
+ <a href="#" onclick="addCofronter('cloudburst', <?= $diff ?>, <?= $index ?>);" class="planner-add-link">
+ <img src="/assets/icons/add.svg" alt="" class="planner-add-icon">
+ </a>
+ </td>
+ <?php else: ?>
+ <td class="planner-link" style="width:41.35vw;" colspan="2">
+ <?php $member = getMemberWithoutSystem($dayCloudburst[$index][1]); ?>
+ <?php if ($member["name"] === "fusion"): ?>
+ <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a>
+ <?php else: ?>
+ <a class="member-link" onclick="openEditCofronter('cloudburst', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a>
+ <?php endif; ?>
+ </td>
+ <?php endif; ?>
+ <?php elseif ($index === count($dayCloudburst)): ?>
+ <td class="planner-add-inner planner-link" colspan="5">
+ <a href="#" onclick="addFronter('cloudburst', <?= $diff ?>, <?= $index ?>);" 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="5" class="planner-empty"></td>
+ <?php endif; ?>
+ <?php if (isset($dayRaindrops[$index])): ?>
+ <td class="planner-member-id">
+ <?= $index + 1 ?>
+ </td>
+ <?php $member = getMemberWithoutSystem($dayRaindrops[$index][0]); ?>
+ <td class="planner-link" style="width:50vw;" <?php if (!isset($dayRaindrops[$index][1])): ?>colspan="3" <?php else: ?>colspan="2"<?php endif; ?>>
+ <?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="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a>
+ <?php else: ?>
+ <a class="member-link" onclick="openEditFronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a>
+ <?php endif; ?>
+ </td>
+ <?php if (!isset($dayRaindrops[$index][1])): ?>
+ <td class="planner-cofronter-inner planner-link" style="width:5%;text-align:center;">
+ <a href="#" onclick="addCofronter('raindrops', <?= $diff ?>, <?= $index ?>);" class="planner-add-link">
+ <img src="/assets/icons/add.svg" alt="" class="planner-add-icon">
+ </a>
+ </td>
+ <?php else: ?>
+ <td class="planner-link" style="width:41.35vw;" colspan="2">
+ <?php $member = getMemberWithoutSystem($dayRaindrops[$index][1]); ?>
+ <?php if ($member["name"] === "fusion"): ?>
+ <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="/assets/logo/logo.png" style="width:24px;"> <span class="member-link-text"><span class="text-muted merge-desktop">Multiple merged members</span><span class="text-muted merge-mobile">Merge</span></span></a>
+ <?php else: ?>
+ <a class="member-link" onclick="openEditCofronter('raindrops', <?= $index ?>, '<?= date('Y-m-d', time() + (86400 * $diff)) ?>')"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <span class="member-link-text"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></a>
+ <?php endif; ?>
+ </td>
+ <?php endif; ?>
+ <?php elseif ($index === count($dayRaindrops)): ?>
+ <td class="planner-add-inner planner-link" colspan="5">
+ <a href="#" onclick="addFronter('raindrops', <?= $diff ?>, <?= $index ?>);" 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="5" class="planner-empty"></td>
+ <?php endif; ?>
+ </tr>
+ <?php $index++; endfor; ?>
+ <tr class="planner-day planner-end-of-day" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>>
+ <td colspan="10">
+ <?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?>
+ <?= getMiniName(getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["name"]) ?> will sleep with <?= getMiniName(getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["name"]) ?>
+ <?php else: ?>
+ Unable to calculate who will sleep with who
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr class="planner-separator"></tr>
+<?php
+}
+?>
+
+<h2>Front planner</h2>
+<table id="planner">
+ <tbody>
+ <?php day("Yesterday", -1) ?>
+ <?php day("Today", 0) ?>
+ <?php day("Tomorrow", 1) ?>
+ <?php
+
+ $factor = 1;
+ $lastDay = time() + 86400;
+ $lastDayWeek = date('W', $lastDay);
+ $tomorrowWeek = date('W', time() + 86400);
+
+ while ($lastDayWeek === $tomorrowWeek) {
+ $factor++;
+ $lastDay = time() + (86400 * $factor);
+ $lastDayWeek = date('W', $lastDay);
+
+ if ($lastDayWeek === $tomorrowWeek) {
+ day(null, $factor);
+ }
+ }
+
+ ?>
+ </tbody>
+</table>
+
+<style>
+ #planner {
+ margin-top: 10px;
+ border-collapse: collapse;
+ width: 100%;
+ }
+
+ .planner-header {
+ font-weight: bold;
+ text-align: center;
+ }
+
+ .planner-header td {
+ width: 50%;
+ }
+
+ td {
+ border: 1px solid rgba(255, 255, 255, .25);
+ padding: 5px 10px;
+ }
+
+ .planner-day {
+ text-align: center;
+ color: rgba(255, 255, 255, .5);
+ font-weight: bold;
+ }
+
+ .planner-end-of-day {
+ font-weight: normal;
+ }
+
+ .planner-end-of-day td {
+ border-bottom-left-radius: 10px;
+ }
+
+ .planner-separator {
+ height: 20px;
+ }
+
+ .planner-member-id {
+ width: 10%;
+ text-align: right;
+ }
+
+ .planner-link {
+ padding: 0;
+ }
+
+ .planner-link a {
+ padding: 5px 10px;
+ display: block;
+ }
+
+ .planner-add-link {
+ color: rgba(255, 255, 255, .75);
+ text-decoration: none;
+ }
+
+ .planner-add-link:hover {
+ color: rgba(255, 255, 255, .75);
+ }
+
+ .planner-link:hover {
+ background-color: rgba(255, 255, 255, .125);
+ }
+
+ .planner-link:active {
+ background-color: rgba(255, 255, 255, .25);
+ }
+
+ .planner-add-icon {
+ filter: invert(1);
+ width: 24px;
+ vertical-align: middle;
+ opacity: .75;
+ }
+
+ .planner-add-text {
+ vertical-align: middle;
+ }
+
+ .modal-header {
+ border-bottom: 1px solid #353738;
+ }
+
+ .modal-content {
+ border: 1px solid rgba(255, 255, 255, .2);
+ background-color: #111;
+ }
+
+ .btn-close {
+ filter: invert(1);
+ }
+
+ .list-group-item {
+ color: #fff;
+ background-color: #222;
+ border: 1px solid rgba(255, 255, 255, .125);
+ }
+
+ .list-group-item.disabled {
+ color: #fff;
+ background-color: #222;
+ border-color: rgba(255, 255, 255, .125);
+ opacity: .75;
+ }
+
+ .list-group-item:hover {
+ background-color: #252525;
+ color: #ddd;
+ }
+
+ .list-group-item:active, .list-group-item:focus {
+ background-color: #272727;
+ color: #bbb;
+ }
+
+ .member-link, .list-group-item-action {
+ cursor: pointer !important;
+ }
+
+ .merge-mobile {
+ display: none;
+ }
+
+ @media (max-width: 768px) {
+ .merge-desktop {
+ display: none;
+ }
+
+ .merge-mobile {
+ display: inline;
+ }
+ }
+
+ @media (max-width: 991px) {
+ .member-link-text {
+ display: none;
+ }
+
+ .planner-link .member-link {
+ text-align: center;
+ }
+ }
+
+</style>
+
+<!--suppress JSUnresolvedVariable, JSUnresolvedFunction -->
+<script>
+ window.currentWorkingDate;
+ window.fronting = JSON.parse(window.atob(`<?= base64_encode(json_encode([
+ "raindrops" => $raindrops,
+ "cloudburst" => $cloudburst
+ ])) ?>`));
+ window.names = JSON.parse(window.atob(`<?php
+
+ $names = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) {
+ $names[$member['id']] = $member['display_name'] ?? $member['name'];
+ }
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) {
+ $names[$member['id']] = $member['display_name'] ?? $member['name'];
+ }
+
+ echo(base64_encode(json_encode($names))) ?>`));
+ window.relations = JSON.parse(window.atob(`<?php
+
+ $relations = [];
+ foreach (scoreOrderGlobal() as $member) {
+ $relations[$member['id']] = array_map(function ($i) {
+ return explode("/", $i)[1];
+ }, [...($member["_metadata"]["marefriends"] ?? []), ...($member["_metadata"]["sisters"] ?? []), ...($member["_metadata"]["caretakers"] ?? [])]);
+ }
+
+ echo(base64_encode(json_encode($relations))) ?>`));
+
+ function getSuggestedPonies() {
+ if (window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex]) {
+ let otherPony = window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex][0];
+ let availablePonies = window.relations[window.fronting[window.addSystem === "gdapd" ? "cloudburst" : "raindrops"][window.currentWorkingDate][window.addIndex][0]];
+
+ document.getElementById("associated-results").innerHTML = "";
+
+ for (let pony of availablePonies) {
+ document.getElementById("associated-results").innerHTML += document.getElementById("list-pony-" + pony).outerHTML;
+ }
+
+ document.getElementById("list").style.display = "none";
+ document.getElementById("associated-results").style.display = "";
+ }
+ }
+
+ function ordinal(n) {
+ let s = ["th", "st", "nd", "rd"];
+ let v = n % 100;
+ return n + (s[(v - 20) % 10] || s[v] || s[0]);
+ }
+
+ function openEditFronter(system, id, date) {
+ let display;
+
+ switch (date) {
+ case "<?= date('Y-m-d') ?>":
+ display = "today";
+ break;
+
+ case "<?= date('Y-m-d', time() + 86400) ?>":
+ display = "tomorrow";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 2)) ?>":
+ display = "on <?= date('l', time() + (86400 * 2)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 3)) ?>":
+ display = "on <?= date('l', time() + (86400 * 3)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 4)) ?>":
+ display = "on <?= date('l', time() + (86400 * 4)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 5)) ?>":
+ display = "on <?= date('l', time() + (86400 * 5)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 6)) ?>":
+ display = "on <?= date('l', time() + (86400 * 6)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 7)) ?>":
+ display = "on <?= date('l', time() + (86400 * 7)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 8)) ?>":
+ display = "on <?= date('l', time() + (86400 * 8)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 9)) ?>":
+ display = "on <?= date('l', time() + (86400 * 9)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 10)) ?>":
+ display = "on <?= date('l', time() + (86400 * 10)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 11)) ?>":
+ display = "on <?= date('l', time() + (86400 * 11)) ?>";
+ break;
+ }
+
+ window.selectedFronting = {
+ system: system === "cloudburst" ? "ynmuc" : "gdapd",
+ date: date,
+ index: id
+ }
+
+ if (fronting[system][date][id][0] === "lzlaq" || fronting[system][date][id][0] === "irxyh") {
+ document.getElementById("edit-fronter-name").innerText = "merged members";
+ } else {
+ document.getElementById("edit-fronter-name").innerText = names[fronting[system][date][id][0]] ?? fronting[system][date][id][0];
+ }
+
+ 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";
+
+ let modal = new bootstrap.Modal(document.getElementById('edit-fronter'));
+ modal.show();
+ }
+
+ function openEditCofronter(system, id, date) {
+ let display;
+
+ switch (date) {
+ case "<?= date('Y-m-d') ?>":
+ display = "today";
+ break;
+
+ case "<?= date('Y-m-d', time() + 86400) ?>":
+ display = "tomorrow";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 2)) ?>":
+ display = "on <?= date('l', time() + (86400 * 2)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 3)) ?>":
+ display = "on <?= date('l', time() + (86400 * 3)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 4)) ?>":
+ display = "on <?= date('l', time() + (86400 * 4)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 5)) ?>":
+ display = "on <?= date('l', time() + (86400 * 5)) ?>";
+ break;
+
+ case "<?= date('Y-m-d', time() + (86400 * 6)) ?>":
+ display = "on <?= date('l', time() + (86400 * 6)) ?>";
+ break;
+ }
+
+ window.selectedFronting = {
+ system: system === "cloudburst" ? "ynmuc" : "gdapd",
+ date: date,
+ index: id
+ }
+
+ document.getElementById("edit-cofronter-name").innerText = names[fronting[system][date][id][1]] ?? fronting[system][date][id][1];
+ document.getElementById("edit-cofronter-name2").innerText = names[fronting[system][date][id][0]] ?? fronting[system][date][id][0];
+
+ document.getElementById("edit-cofronter-date").innerText = display;
+ document.getElementById("edit-cofronter-pos").innerText = ordinal(id + 1);
+ document.getElementById("edit-cofronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
+
+ let modal = new bootstrap.Modal(document.getElementById('edit-cofronter'));
+ modal.show();
+ }
+
+ function addCofronter(system, offset, index) {
+ let date;
+ let display;
+
+ switch (offset) {
+ case 0:
+ date = "<?= date('Y-m-d') ?>";
+ display = "today";
+ break;
+
+ case 1:
+ date = "<?= date('Y-m-d', time() + 86400) ?>";
+ display = "tomorrow";
+ break;
+
+ case 2:
+ date = "<?= date('Y-m-d', time() + (86400 * 2)) ?>";
+ display = "on <?= date('l', time() + (86400 * 2)) ?>";
+ break;
+
+ case 3:
+ date = "<?= date('Y-m-d', time() + (86400 * 3)) ?>";
+ display = "on <?= date('l', time() + (86400 * 3)) ?>";
+ break;
+
+ case 4:
+ date = "<?= date('Y-m-d', time() + (86400 * 4)) ?>";
+ display = "on <?= date('l', time() + (86400 * 4)) ?>";
+ break;
+
+ case 5:
+ date = "<?= date('Y-m-d', time() + (86400 * 5)) ?>";
+ display = "on <?= date('l', time() + (86400 * 5)) ?>";
+ break;
+
+ case 6:
+ date = "<?= date('Y-m-d', time() + (86400 * 6)) ?>";
+ display = "on <?= date('l', time() + (86400 * 6)) ?>";
+ break;
+ }
+
+ window.selectedFronting = {
+ system: system === "cloudburst" ? "ynmuc" : "gdapd",
+ date: date,
+ index: index
+ }
+
+ window.currentWorkingDate = date;
+ document.getElementById("new-cofronter-date").innerText = display;
+ document.getElementById("new-cofronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
+ window.addSystem = system === "raindrops" ? "gdapd" : "ynmuc";
+
+ if (fronting[system][date][index][0] === "lzlaq" || fronting[system][date][index][0] === "irxyh") {
+ document.getElementById("new-cofronter-main").innerText = "merged members";
+ } else {
+ document.getElementById("new-cofronter-main").innerText = names[fronting[system][date][index][0]] ?? fronting[system][date][index][0];
+ }
+
+ document.getElementById("list2").style.display = "block";
+ document.getElementById("search2-results").style.display = "none";
+ document.getElementById("search2").value = "";
+
+ let modal = new bootstrap.Modal(document.getElementById('new-cofronter'));
+ modal.show();
+ document.getElementById("search2").focus();
+ }
+
+ function addFronter(system, offset, index) {
+ let date;
+ let display;
+
+ switch (offset) {
+ case 0:
+ date = "<?= date('Y-m-d') ?>";
+ display = "today";
+ break;
+
+ case 1:
+ date = "<?= date('Y-m-d', time() + 86400) ?>";
+ display = "tomorrow";
+ break;
+
+ case 2:
+ date = "<?= date('Y-m-d', time() + (86400 * 2)) ?>";
+ display = "on <?= date('l', time() + (86400 * 2)) ?>";
+ break;
+
+ case 3:
+ date = "<?= date('Y-m-d', time() + (86400 * 3)) ?>";
+ display = "on <?= date('l', time() + (86400 * 3)) ?>";
+ break;
+
+ case 4:
+ date = "<?= date('Y-m-d', time() + (86400 * 4)) ?>";
+ display = "on <?= date('l', time() + (86400 * 4)) ?>";
+ break;
+
+ case 5:
+ date = "<?= date('Y-m-d', time() + (86400 * 5)) ?>";
+ display = "on <?= date('l', time() + (86400 * 5)) ?>";
+ break;
+
+ case 6:
+ date = "<?= date('Y-m-d', time() + (86400 * 6)) ?>";
+ display = "on <?= date('l', time() + (86400 * 6)) ?>";
+ break;
+
+ case 7:
+ date = "<?= date('Y-m-d', time() + (86400 * 7)) ?>";
+ display = "on <?= date('l', time() + (86400 * 7)) ?>";
+ break;
+
+ case 8:
+ date = "<?= date('Y-m-d', time() + (86400 * 8)) ?>";
+ display = "on <?= date('l', time() + (86400 * 8)) ?>";
+ break;
+
+ case 9:
+ date = "<?= date('Y-m-d', time() + (86400 * 9)) ?>";
+ display = "on <?= date('l', time() + (86400 * 9)) ?>";
+ break;
+
+ case 10:
+ date = "<?= date('Y-m-d', time() + (86400 * 10)) ?>";
+ display = "on <?= date('l', time() + (86400 * 10)) ?>";
+ break;
+
+ case 11:
+ date = "<?= date('Y-m-d', time() + (86400 * 11)) ?>";
+ display = "on <?= date('l', time() + (86400 * 11)) ?>";
+ break;
+ }
+
+ window.currentWorkingDate = date;
+ window.addIndex = index;
+ document.getElementById("new-fronter-date").innerText = display;
+ document.getElementById("new-fronter-system").innerText = system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
+ window.addSystem = system === "raindrops" ? "gdapd" : "ynmuc";
+
+ document.getElementById("list").style.display = "block";
+ getSuggestedPonies();
+ 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) {
+ Array.from(document.getElementsByClassName("new-fronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("new-fronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=add&d=" + window.currentWorkingDate + "&m=" + id + "&s=" + system).then(() => {
+ location.reload();
+ });
+ }
+
+ function confirmCofronterAdd(system, id) {
+ Array.from(document.getElementsByClassName("new-cofronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("new-cofronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=cofront&d=" + window.selectedFronting["date"] + "&m=" + id + "&s=" + system + "&i=" + window.selectedFronting["index"]).then(() => {
+ location.reload();
+ });
+ }
+
+ function deleteFronter() {
+ Array.from(document.getElementsByClassName("edit-fronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("edit-fronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=delete&d=" + window.selectedFronting["date"] + "&i=" + window.selectedFronting["index"] + "&s=" + window.selectedFronting["system"]).then(() => {
+ location.reload();
+ });
+ }
+
+ function deleteCofronter() {
+ Array.from(document.getElementsByClassName("edit-cofronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("edit-cofronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=codelete&d=" + window.selectedFronting["date"] + "&i=" + window.selectedFronting["index"] + "&s=" + window.selectedFronting["system"]).then(() => {
+ location.reload();
+ });
+ }
+
+ function moveFronterDown() {
+ Array.from(document.getElementsByClassName("edit-fronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("edit-fronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=down&d=" + window.selectedFronting["date"] + "&i=" + window.selectedFronting["index"] + "&s=" + window.selectedFronting["system"]).then(() => {
+ location.reload();
+ });
+ }
+
+ function viewFronterPage() {
+ let id = fronting[window.selectedFronting["system"] === "ynmuc" ? "cloudburst" : "raindrops"][window.selectedFronting["date"]][window.selectedFronting["index"]][0];
+ location.href = "/" + id;
+ }
+
+ function viewCofronterPage() {
+ let id = fronting[window.selectedFronting["system"] === "ynmuc" ? "cloudburst" : "raindrops"][window.selectedFronting["date"]][window.selectedFronting["index"]][1];
+ location.href = "/" + id;
+ }
+
+ function moveFronterUp() {
+ Array.from(document.getElementsByClassName("edit-fronter-link")).forEach((i) => {
+ i.classList.add("disabled");
+ });
+
+ document.getElementById("edit-fronter-close").classList.add("disabled");
+
+ window.fetch("/api/fronter?t=up&d=" + window.selectedFronting["date"] + "&i=" + window.selectedFronting["index"] + "&s=" + window.selectedFronting["system"]).then(() => {
+ location.reload();
+ });
+ }
+</script>
+
+<div class="modal" id="new-fronter" data-bs-backdrop="static" data-bs-keyboard="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <h4 class="modal-title">Add new fronter <span id="new-fronter-date">n/a</span></h4>
+ <button id="new-fronter-close" type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+
+ <div class="modal-body">
+ <p class="text-muted">Adding for the <span id="new-fronter-system">n/a</span></p>
+
+ <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 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="<?= getAsset($member["system"], $member["id"], "heads") ?>" 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 id="associated-results" class="list-group"></div>
+ </div>
+
+ </div>
+ </div>
+</div>
+
+<div class="modal" id="new-cofronter" data-bs-backdrop="static" data-bs-keyboard="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <h4 class="modal-title">Add new co-fronter <span id="new-cofronter-date">n/a</span> with <span id="new-cofronter-main">n/a</span></h4>
+ <button id="new-cofronter-close" type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+
+ <div class="modal-body">
+ <p class="text-muted">Adding for the <span id="new-cofronter-system">n/a</span></p>
+
+ <input type="text" placeholder="Search for a pony..." class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" id="search2">
+
+ <div id="list2">
+ <div class="list-group">
+ <?php foreach (scoreOrderGlobal() as $member): ?>
+ <a id="list2-pony-<?= $member['id'] ?>" onclick="confirmCofronterAdd(window.addSystem, '<?= $member['id'] ?>');" class="new-cofronter-link member-link list-group-item list-group-item-action" href="#"><img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= getMiniName($member["display_name"] ?? $member["name"]) ?><peh-schedule-add></peh-schedule-add></a>
+ <?php endforeach; $member = getSystemMember("gdapd", "irxyh") ?>
+ </div>
+ </div>
+
+ <div id="search2-results" class="list-group"></div>
+ </div>
+
+ </div>
+ </div>
+</div>
+
+<div class="modal" id="edit-fronter" data-bs-backdrop="static" data-bs-keyboard="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <h4 class="modal-title">Edit <span id="edit-fronter-name">n/a</span> fronting in <span id="edit-fronter-pos">n/a</span> <span id="edit-fronter-date">n/a</span></h4>
+ <button id="edit-fronter-close" type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+
+ <div class="modal-body">
+ <p class="text-muted">Editing for the <span id="edit-fronter-system">n/a</span></p>
+
+ <div class="list-group" id="list-cloudburst">
+ <a class="list-group-item list-group-item-action edit-fronter-link" onclick="deleteFronter();">
+ <img src="/assets/icons/delete.svg" style="width:24px;filter:invert(1);vertical-align: middle;">
+ <span style="vertical-align: middle;">Delete</span>
+ </a>
+ <a class="list-group-item list-group-item-action edit-fronter-link" onclick="moveFronterUp();">
+ <img src="/assets/icons/up.svg" style="width:24px;filter:invert(1);vertical-align: middle;">
+ <span style="vertical-align: middle;">Move up</span>
+ </a>
+ <a class="list-group-item list-group-item-action edit-fronter-link" onclick="moveFronterDown();">
+ <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>
+
+ </div>
+ </div>
+</div>
+
+<div class="modal" id="edit-cofronter" data-bs-backdrop="static" data-bs-keyboard="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <h4 class="modal-title">Edit <span id="edit-cofronter-name">n/a</span> fronting with <span id="edit-cofronter-name2">n/a</span> in <span id="edit-cofronter-pos">n/a</span> <span id="edit-cofronter-date">n/a</span></h4>
+ <button id="edit-cofronter-close" type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+
+ <div class="modal-body">
+ <p class="text-muted">Editing for the <span id="edit-cofronter-system">n/a</span></p>
+
+ <div class="list-group" id="list-cloudburst">
+ <a class="list-group-item list-group-item-action edit-cofronter-link" onclick="deleteCofronter();">
+ <img src="/assets/icons/delete.svg" style="width:24px;filter:invert(1);vertical-align: middle;">
+ <span style="vertical-align: middle;">Delete</span>
+ </a>
+ <!--<a class="list-group-item list-group-item-action edit-fronter-link" onclick="invertCofronter();">
+ <img src="/assets/icons/invert.svg" style="width:24px;filter:invert(1);vertical-align: middle;">
+ <span style="vertical-align: middle;">Invert main and secondary fronters</span>
+ </a>-->
+ <a class="list-group-item list-group-item-action edit-cofronter-link" onclick="viewCofronterPage();">
+ <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>
+
+ </div>
+ </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";
+ getSuggestedPonies();
+ 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();
+ }
+ });
+
+ function search2(event) {
+ if (event.key === "Enter") {
+ return;
+ }
+
+ let query = document.getElementById("search2").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("list2").style.display = "none";
+ document.getElementById("search2-results").style.display = "block";
+ document.getElementById("search2-results").innerHTML = "";
+
+ for (let result of results) {
+ document.getElementById("search2-results").innerHTML += document.getElementById("list2-pony-" + result.id).outerHTML;
+ }
+
+ console.log(results);
+
+ if (query.trim() === "") {
+ document.getElementById("list2").style.display = "block";
+ document.getElementById("search2-results").style.display = "none";
+ }
+ }
+
+ document.getElementById("search2").onchange = document.getElementById("search2").onkeyup = document.getElementById("search2").onkeydown = search2;
+
+ document.getElementById("search2").addEventListener("keydown", (event) => {
+ if (event.key === "Enter") {
+ document.querySelector("#search2-results .new-cofronter-link").click();
+ event.preventDefault();
+ }
+ });
+</script>
+
+<?php
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json", json_encode($cloudburst));
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json", json_encode($raindrops));
+
+?> \ No newline at end of file