MarseyWorld/files/assets/js/report_post_modal.js

38 lines
985 B
JavaScript
Raw Normal View History

2022-07-16 21:00:02 +00:00
const reason_post = document.getElementById("reason_post")
const reportPostButton = document.getElementById("reportPostButton");
reason_post.addEventListener('keydown', (e) => {
if(!((e.ctrlKey || e.metaKey) && e.key === "Enter")) return;
const targetDOM = document.activeElement;
if(!(targetDOM instanceof HTMLInputElement)) return;
reportPostButton.click()
bootstrap.Modal.getOrCreateInstance(document.getElementById('reportPostModal')).hide()
});
function report_postModal(id) {
reportPostButton.disabled = false;
reportPostButton.classList.remove('disabled');
reportPostButton.innerHTML='Report post';
reportPostButton.dataset.id = id
2022-07-16 21:00:02 +00:00
reason_post.value = ""
setTimeout(() => {
reason_post.focus()
}, 500);
};
reportPostButton.onclick = function() {
this.innerHTML='Reporting post';
this.disabled = true;
this.classList.add('disabled');
postToast(this, '/report/post/' + reportPostButton.dataset.id,
{
"reason": reason_post.value
},
() => {}
);
}