Add post and image deletion

This one was kind of a doozy. This also adds a custom 403 error page and
fixes some permission denied behavior that I was having issues with for
a while.

This is also set up in a way that hopefully will allow me to easily
implement user post deletion.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-13 15:19:20 -07:00
parent 6ff64a3299
commit 83533b5fb4
9 changed files with 147 additions and 3 deletions

View File

@@ -3,7 +3,8 @@ const OPEN = "open";
const CLOSED = "closed";
const replyWindowName = "reply-window";
const postWindowName = "post-window";
const reportWindowName = "report-window"
const reportWindowName = "report-window";
const deleteWindowName = "delete-window";
const WINDOW_INNER_PADDING = 25;
@@ -204,6 +205,31 @@ function openReportWindow(reportUrl) {
reportWindow.show();
}
////////////////////////////////////////////////////////////////////////////////
// Post delete window
////////////////////////////////////////////////////////////////////////////////
function getDeleteWindow() {
return window.top.jsFrame.getWindowByName(deleteWindowName);
}
function openDeleteWindow(deleteUrl) {
if (window.top.jsFrame.containsWindowName(deleteWindowName)) {
getDeleteWindow().closeFrame();
}
let deleteWindow = window.top.jsFrame.create({
title: "Deleting post",
name: deleteWindowName,
width: 475,
url: deleteUrl,
});
$(deleteWindow.iframe, "iframe").on("load", () => {
fitWindowToContent(deleteWindow);
deleteWindow.setResizable(false);
});
deleteWindow.show();
}
////////////////////////////////////////////////////////////////////////////////
// Post hiding
////////////////////////////////////////////////////////////////////////////////
@@ -365,4 +391,13 @@ window.menuItemFactories.push(
addHiddenPost(id);
}
})
);
window.menuItemFactories.push(
(postElement) => $("<a>")
.text("Delete post")
.attr("href", "#")
.on("click", (e) => {
e.preventDefault();
openDeleteWindow($(postElement).attr("data-delete-url"));
})
);