diff options
author | Minteck <contact@minteck.org> | 2022-12-21 18:09:20 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-12-21 18:09:20 +0100 |
commit | ae766d28c07628e71629a72452261898ea72057a (patch) | |
tree | 79bf1110a59f8339ce685b80c12d18f3650700d8 /includes/planner.inc | |
parent | 9d5e468be5e58269f8730305745eee29b9d957d5 (diff) | |
download | pluralconnect-ae766d28c07628e71629a72452261898ea72057a.tar.gz pluralconnect-ae766d28c07628e71629a72452261898ea72057a.tar.bz2 pluralconnect-ae766d28c07628e71629a72452261898ea72057a.zip |
Update - This is an automated commit
Diffstat (limited to 'includes/planner.inc')
-rw-r--r-- | includes/planner.inc | 209 |
1 files changed, 60 insertions, 149 deletions
diff --git a/includes/planner.inc b/includes/planner.inc index 72c82a5..c537d17 100644 --- a/includes/planner.inc +++ b/includes/planner.inc @@ -73,9 +73,18 @@ foreach ($raindrops as $id => $day) { 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)); - }?> + } + + $d = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/days.json"), true); + $t = date('Y-m-d', time() + (86400 * $diff)); + + if (isset($d[$t])) { + $display = "$display ($d[$t])"; + } + + ?> <tr class="planner-day" id="planner-header-<?= $diff ?>" <?php if ($disabled): ?>style="opacity: .75; pointer-events: none;"<?php endif; ?>> - <td colspan="10"><?= $display ?></td> + <td colspan="10" contenteditable="true"><?= $display ?></td> <?php if (!isset($cloudburst[date('Y-m-d', time() + (86400 * $diff))])) $cloudburst[date('Y-m-d', time() + (86400 * $diff))] = []; @@ -403,57 +412,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis } 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; - } + let display = formatDate(date).display; window.selectedFronting = { system: system === "cloudburst" ? "ynmuc" : "gdapd", @@ -476,37 +435,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis } 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; - } + let display = formatDate(offset).display; window.selectedFronting = { system: system === "cloudburst" ? "ynmuc" : "gdapd", @@ -525,47 +454,91 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis modal.show(); } - function addCofronter(system, offset, index) { + function formatDate(offset) { let date; let display; switch (offset) { case 0: + case "<?= date('Y-m-d', time()) ?>": date = "<?= date('Y-m-d') ?>"; display = "today"; break; case 1: + case "<?= date('Y-m-d', time() + (86400)) ?>": date = "<?= date('Y-m-d', time() + 86400) ?>"; display = "tomorrow"; break; case 2: + case "<?= date('Y-m-d', time() + (86400 * 2)) ?>": date = "<?= date('Y-m-d', time() + (86400 * 2)) ?>"; display = "on <?= date('l', time() + (86400 * 2)) ?>"; break; case 3: + case "<?= date('Y-m-d', time() + (86400 * 3)) ?>": date = "<?= date('Y-m-d', time() + (86400 * 3)) ?>"; display = "on <?= date('l', time() + (86400 * 3)) ?>"; break; case 4: + case "<?= date('Y-m-d', time() + (86400 * 4)) ?>": date = "<?= date('Y-m-d', time() + (86400 * 4)) ?>"; display = "on <?= date('l', time() + (86400 * 4)) ?>"; break; case 5: + case "<?= date('Y-m-d', time() + (86400 * 5)) ?>": date = "<?= date('Y-m-d', time() + (86400 * 5)) ?>"; display = "on <?= date('l', time() + (86400 * 5)) ?>"; break; case 6: + case "<?= date('Y-m-d', time() + (86400 * 6)) ?>": date = "<?= date('Y-m-d', time() + (86400 * 6)) ?>"; display = "on <?= date('l', time() + (86400 * 6)) ?>"; break; + + case 7: + case "<?= date('Y-m-d', time() + (86400 * 7)) ?>": + date = "<?= date('Y-m-d', time() + (86400 * 7)) ?>"; + display = "on <?= date('l', time() + (86400 * 7)) ?>"; + break; + + case 8: + case "<?= date('Y-m-d', time() + (86400 * 8)) ?>": + date = "<?= date('Y-m-d', time() + (86400 * 8)) ?>"; + display = "on <?= date('l', time() + (86400 * 8)) ?>"; + break; + + case 9: + case "<?= date('Y-m-d', time() + (86400 * 9)) ?>": + date = "<?= date('Y-m-d', time() + (86400 * 9)) ?>"; + display = "on <?= date('l', time() + (86400 * 9)) ?>"; + break; + + case 10: + case "<?= date('Y-m-d', time() + (86400 * 10)) ?>": + date = "<?= date('Y-m-d', time() + (86400 * 10)) ?>"; + display = "on <?= date('l', time() + (86400 * 10)) ?>"; + break; + + case 11: + case "<?= date('Y-m-d', time() + (86400 * 11)) ?>": + date = "<?= date('Y-m-d', time() + (86400 * 11)) ?>"; + display = "on <?= date('l', time() + (86400 * 11)) ?>"; + break; } + return {date, display}; + } + + function addCofronter(system, offset, index) { + let date = formatDate(offset).date; + let display = formatDate(offset).display; + window.selectedFronting = { system: system === "cloudburst" ? "ynmuc" : "gdapd", date: date, @@ -593,70 +566,8 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis } 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; - } + let date = formatDate(offset).date; + let display = formatDate(offset).display; window.currentWorkingDate = date; window.addIndex = index; |