rDrama/files/assets/js/report_post_modal.js

37 lines
953 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) => {
2023-08-06 03:33:34 +00:00
if (!((e.ctrlKey || e.metaKey) && e.key === "Enter")) return;
2022-07-16 21:00:02 +00:00
const targetDOM = document.activeElement;
2023-08-06 03:33:34 +00:00
if (!(targetDOM instanceof HTMLInputElement)) return;
2022-07-16 21:00:02 +00:00
reportPostButton.click()
2023-10-02 06:04:05 +00:00
bootstrap.Modal.getOrCreateInstance(document.getElementById('reportPostModal')).hide()
2022-07-16 21:00:02 +00:00
});
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.disabled = true;
this.classList.add('disabled');
postToast(this, '/report/post/' + reportPostButton.dataset.id,
{
"reason": reason_post.value
},
() => {}
);
}