MarseyWorld/files/assets/js/delete_post_modal.js

34 lines
1.0 KiB
JavaScript

const deletePostModal = document.getElementById('deletePostModal');
const deletePostButton = document.getElementById("deletePostButton");
function delete_postModal(id) {
deletePostButton.dataset.id = id
}
deletePostButton.onclick = () => {
const id = deletePostButton.dataset.id
postToast(deletePostButton, `/delete/post/${id}`,
{},
() => {
if (location.pathname == '/admin/reported/posts')
{
document.getElementById("reports-"+id).remove()
document.getElementById("post-"+id).remove()
}
else
{
document.getElementById(`post-${id}`).classList.add('deleted');
document.getElementById(`delete-${id}`).classList.add('d-none');
document.getElementById(`undelete-${id}`).classList.remove('d-none');
document.getElementById(`delete2-${id}`).classList.add('d-none');
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
}
}
);
};
deletePostModal.addEventListener('keydown', (e) => {
if (e.key === "Enter" && deletePostModal.classList.value == 'modal fade show')
deletePostButton.click()
})