summaryrefslogtreecommitdiff
path: root/pages/docs.inc
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-20 16:20:07 +0200
committerRaindropsSys <contact@minteck.org>2023-04-20 16:20:07 +0200
commitb4bcb0912c5fe1c7f00c7ac76e5b67620781d3cc (patch)
tree027238ccdf43719ae4bbb65eedeaf9823fff6471 /pages/docs.inc
parentb484fc41a94e18f679f2494d598ac3d0ae72e3f8 (diff)
downloadpluralconnect-b4bcb0912c5fe1c7f00c7ac76e5b67620781d3cc.tar.gz
pluralconnect-b4bcb0912c5fe1c7f00c7ac76e5b67620781d3cc.tar.bz2
pluralconnect-b4bcb0912c5fe1c7f00c7ac76e5b67620781d3cc.zip
Updated 12 files and added 3 files (automated)
Diffstat (limited to 'pages/docs.inc')
-rw-r--r--pages/docs.inc38
1 files changed, 28 insertions, 10 deletions
diff --git a/pages/docs.inc b/pages/docs.inc
index a94f92e..84d9d87 100644
--- a/pages/docs.inc
+++ b/pages/docs.inc
@@ -36,7 +36,12 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
function showDocument($item) { ?>
<div style="display: grid; grid-template-columns: 2fr repeat(3, 1fr);">
- <?= $item["name"] ?>&nbsp;
+ <span>
+ <?= $item["name"] ?>
+ <?php if ($item["nsfw"]): ?>
+ <span class="badge bg-danger rounded-pill">NSFW</span>
+ <?php endif; ?>
+ </span>
<?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>
<span class="badge bg-warning rounded-pill text-black" style="width: max-content;">Deleting in <?= round((($item["last"]["date"] + 86400) - time()) / 3600) ?> hours</span>
<?php else: ?>
@@ -53,11 +58,15 @@ function showDocument($item) { ?>
<div class="container">
<div>
<?php if (isset($data)): ?><div id="page-content">
+ <?php if ($data["nsfw"]): ?><script>requestExplicit("back");</script><?php endif; ?>
<h2>
<span contenteditable="true" id="document-name" style="outline: none;"><?= $data["name"] ?></span>
<a href="/-/docs" class="small btn btn-outline-light" style="float:right;margin-top:5px;vertical-align:middle;opacity:1 !important; color:white;">Back</a>
</h2>
- <p><b>Category:</b> <span id="category" contenteditable="true" style="outline: none;"><?= $data["category"] ?? "Unsorted" ?></span></p>
+ <p><b>Category:</b> <span id="category" contenteditable="true" style="outline: none;"><?= $data["category"] ?? "Unsorted" ?></span> ยท <label style="margin-bottom:5px;">
+ <input <?= $data["nsfw"] ? "checked" : "" ?> class="form-check-input" type="checkbox" id="explicit">
+ Explicit
+ </label></p>
<p>
<?php if ($data["last"]["date"] === 0): ?>
Last modified <span id="last-edit-time" class="relative-time" data-relative-timestamp="">never</span>
@@ -139,8 +148,8 @@ function showDocument($item) { ?>
<script>
let titleBase = "<?= $titleBase ?>";
- let lastSavedData = editor.getData();
- let lastFetchedData = editor.getData();
+ let lastSavedData = getData();
+ let lastFetchedData = getData();
let timeSinceLastModified = 0;
let saving = false;
@@ -156,7 +165,7 @@ function showDocument($item) { ?>
try {
await window.fetch("/api/docs?id=<?= $_documentId ?>", {
method: "POST",
- body: JSON.stringify({ content: data, name: document.getElementById("document-name").innerText, category: document.getElementById("category").innerText })
+ body: JSON.stringify({ content: data, name: document.getElementById("document-name").innerText, category: document.getElementById("category").innerText, explicit: document.getElementById("explicit").checked })
});
document.getElementById("last-edit-time").setAttribute("data-relative-timestamp", (new Date().getTime() / 1000).toFixed(0));
if (document.getElementById("last-edit-author")) document.getElementById("last-edit-author").outerHTML = "";
@@ -166,7 +175,7 @@ function showDocument($item) { ?>
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;
+ lastSavedData = getData();
saving = false;
} catch (e) {
console.error(e);
@@ -181,23 +190,32 @@ function showDocument($item) { ?>
document.onclick = async () => {
if (saving) return;
- if (editor.getData() !== lastSavedData) {
+ if (getData() !== lastSavedData) {
await save();
}
}
+ function getData() {
+ return JSON.stringify({
+ document: editor.getData(),
+ name: document.getElementById("document-name").innerText,
+ category: document.getElementById("category").innerText,
+ explicit: document.getElementById("explicit").checked
+ });
+ }
+
setInterval(async () => {
if (saving) return;
- if (editor.getData() !== lastSavedData) {
+ if (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();
+ if (getData() !== lastFetchedData) {
+ lastFetchedData = getData();
timeSinceLastModified = 0;
} else {
timeSinceLastModified++;