summaryrefslogtreecommitdiff
path: root/includes/edit-private.inc
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-03-12 19:16:53 +0100
committerRaindropsSys <contact@minteck.org>2023-03-12 19:16:53 +0100
commiteb89b15c0f044673c1206a418a21d0baba1a675e (patch)
tree39ac31a576d8b8392cbd9baf8d67621bf2cefa86 /includes/edit-private.inc
parent5385f0ed8fbb4325203a222a75e6700ffb519349 (diff)
downloadpluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.gz
pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.bz2
pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.zip
Updated 104 files, added 3 files, deleted 4 files and renamed 36 files (automated)
Diffstat (limited to 'includes/edit-private.inc')
-rw-r--r--includes/edit-private.inc142
1 files changed, 0 insertions, 142 deletions
diff --git a/includes/edit-private.inc b/includes/edit-private.inc
deleted file mode 100644
index 69f50d8..0000000
--- a/includes/edit-private.inc
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = "Editing " . $memberCommonName . " (private page) · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
-
-if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) {
- $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true));
-}
-
-?>
-
-<br>
-<div class="container">
- <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/fullbanner.inc"; ?>
-
- <p class="text-muted" id="page-content">
- <span id="editor-save-status" class="text-muted">Saved</span> · <span id="editor-size"><?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html")) : "0" ?></span> bytes · <a href="/<?= $memberData["name"] ?>">View page</a>
- </p>
-
- <!--suppress HtmlFormInputWithoutLabel -->
- <textarea id="page-editor">
- <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$memberID-private.html") : "" ?>
- </textarea>
-
- <script src="/assets/editor/editor.js"></script>
- <script>
- let editor;
- ClassicEditor
- .create( document.querySelector( '#page-editor' ), {
- toolbar: [
- 'undo', 'redo', '|', 'removeFormat', '|', 'heading', '|', 'fontSize', 'fontColor', 'fontBackgroundColor', 'alignment', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'code', '|', 'outdent', 'indent', '|', 'bulletedList', 'numberedList', '|', 'link', 'imageUpload', 'mediaEmbed', 'blockQuote', 'insertTable', 'codeBlock', '|', 'horizontalLine'
- ]
- } )
-
- .then( newEditor => {
- editor = newEditor;
- } )
- .catch( error => {
- console.error( error );
- } );
- </script>
- <style>
- :root {
- --ck-color-base-background: transparent;
- }
-
- .ck-toolbar {
- filter: invert(1);
- }
-
- .ck-tooltip__text {
- color: white !important;
- }
-
- .ck-dropdown__panel {
- background: #ddd !important;
- }
-
- .ck-color-grid__tile {
- filter: invert(1);
- }
-
- .ck-balloon-rotator {
- background-color: #ccc !important;
- }
-
- .ck-balloon-panel {
- filter: invert(1);
- }
- </style>
- <script>
- let lastSavedData = editor.getData();
- let lastFetchedData = editor.getData();
- let timeSinceLastModified = 0;
- let saving = false;
-
- async function save() {
- let data = editor.getData();
- document.getElementById("editor-save-status").innerHTML = "Saving...";
- document.getElementById("editor-save-status").classList.remove("text-danger");
- document.getElementById("editor-save-status").classList.remove("text-muted");
- document.getElementById("editor-save-status").classList.remove("text-warning");
- document.getElementById("editor-save-status").classList.add("text-primary");
- saving = true;
-
- try {
- await window.fetch("/api/save-private?system=<?= $systemID ?>&member=<?= $memberID ?>", {
- method: "POST",
- body: JSON.stringify({ content: data })
- });
- document.getElementById("editor-save-status").innerHTML = "Saved";
- document.getElementById("editor-save-status").classList.remove("text-danger");
- document.getElementById("editor-save-status").classList.add("text-muted");
- document.getElementById("editor-save-status").classList.remove("text-warning");
- document.getElementById("editor-save-status").classList.remove("text-primary");
- lastSavedData = data;
- saving = false;
- } catch (e) {
- console.error(e);
- document.getElementById("editor-save-status").innerHTML = "Failed to save";
- document.getElementById("editor-save-status").classList.add("text-danger");
- document.getElementById("editor-save-status").classList.remove("text-muted");
- document.getElementById("editor-save-status").classList.remove("text-warning");
- document.getElementById("editor-save-status").classList.remove("text-primary");
- }
- }
-
- document.onclick = async () => {
- if (saving) return;
-
- if (editor.getData() !== lastSavedData) {
- await save();
- }
- }
-
- setInterval(async () => {
- if (saving) return;
-
- document.getElementById("editor-size").innerHTML = editor.getData().length;
-
- if (editor.getData() !== lastSavedData) {
- document.getElementById("editor-save-status").innerHTML = "Modified";
- document.getElementById("editor-save-status").classList.remove("text-danger");
- document.getElementById("editor-save-status").classList.remove("text-muted");
- document.getElementById("editor-save-status").classList.add("text-warning");
- document.getElementById("editor-save-status").classList.remove("text-primary");
-
- if (editor.getData() !== lastFetchedData) {
- lastFetchedData = editor.getData();
- timeSinceLastModified = 0;
- } else {
- timeSinceLastModified++;
- }
-
- if (timeSinceLastModified > 20) {
- await save();
- }
- } else {
- timeSinceLastModified = 0;
- }
- }, 100)
- </script>
-</div>
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?> \ No newline at end of file