new modal for deleting tags and items
This commit is contained in:
@@ -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 = '/';
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user