new modal for deleting tags and items

This commit is contained in:
x
2026-01-23 20:52:49 +01:00
parent e9c377dc87
commit ee6fda8f06
4 changed files with 186 additions and 21 deletions

View File

@@ -184,13 +184,40 @@
if (!ctx) return;
const { postid, poster } = ctx;
if (!confirm(`Reason for deleting f0ckpost ${postid} by ${poster} (Weihnachten™)`))
return;
const res = await post("/api/v2/admin/deletepost", {
postid: postid
});
if (!res.success) {
alert(res.msg);
const modal = document.getElementById('delete-item-modal');
const idEl = document.getElementById('delete-item-id');
const posterEl = document.getElementById('delete-item-poster');
const confirmBtn = document.getElementById('delete-item-confirm');
const cancelBtn = document.getElementById('delete-item-cancel');
if (modal) {
idEl.textContent = postid;
posterEl.textContent = poster || 'unknown';
modal.style.display = 'flex';
const closeModal = () => {
modal.style.display = 'none';
confirmBtn.onclick = null;
cancelBtn.onclick = null;
};
cancelBtn.onclick = closeModal;
confirmBtn.onclick = async () => {
confirmBtn.textContent = 'Deleting...';
confirmBtn.disabled = true;
const res = await post("/api/v2/admin/deletepost", {
postid: postid
});
if (!res.success) {
alert(res.msg);
confirmBtn.textContent = 'Delete';
confirmBtn.disabled = false;
} else {
closeModal();
window.location.href = '/';
}
};
}
};