diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index d3fa9a15f..aadff07bc 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -17,7 +17,6 @@ function report_commentModal(id, author) { document.getElementById("comment-author").textContent = author; document.getElementById("reportCommentFormBefore").classList.remove('d-none'); - document.getElementById("reportCommentFormAfter").classList.add('d-none'); reportCommentButton.innerHTML='Report comment'; reportCommentButton.disabled = false; @@ -39,9 +38,19 @@ function report_commentModal(id, author) { form.append("formkey", formkey()); form.append("reason", reason_comment.value); - xhr.onload=function() { - document.getElementById("reportCommentFormBefore").classList.add('d-none'); - document.getElementById("reportCommentFormAfter").classList.remove('d-none'); + xhr.onload = function() { + let data + try {data = JSON.parse(xhr.response)} + catch(e) {console.log(e)} + if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) { + document.getElementById("reportCommentFormBefore").classList.add('d-none'); + document.getElementById('toast-post-success-text').innerText = data["message"]; + bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show(); + } else { + document.getElementById('toast-post-error-text').innerText = "Error, please try again later." + if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; + bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); + } }; xhr.onerror=function(){alert(errortext)}; diff --git a/files/assets/js/report_post_modal.js b/files/assets/js/report_post_modal.js index 0a12b9a4d..421438d80 100644 --- a/files/assets/js/report_post_modal.js +++ b/files/assets/js/report_post_modal.js @@ -14,7 +14,6 @@ reason_post.addEventListener('keydown', (e) => { function report_postModal(id) { document.getElementById("reportPostFormBefore").classList.remove('d-none'); - document.getElementById("reportPostFormAfter").classList.add('d-none'); reportPostButton.disabled = false; reportPostButton.classList.remove('disabled'); reportPostButton.innerHTML='Report post'; @@ -37,9 +36,19 @@ function report_postModal(id) { form.append("formkey", formkey()); form.append("reason", reason_post.value); - xhr.onload=function() { - document.getElementById("reportPostFormBefore").classList.add('d-none'); - document.getElementById("reportPostFormAfter").classList.remove('d-none'); + xhr.onload = function() { + let data + try {data = JSON.parse(xhr.response)} + catch(e) {console.log(e)} + if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) { + document.getElementById("reportPostFormBefore").classList.add('d-none'); + document.getElementById('toast-post-success-text').innerText = data["message"]; + bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success')).show(); + } else { + document.getElementById('toast-post-error-text').innerText = "Error, please try again later." + if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; + bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); + } }; xhr.onerror=function(){alert(errortext)}; diff --git a/files/templates/comments.html b/files/templates/comments.html index 6555ab06c..1551be810 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -811,16 +811,6 @@ - -
- - -
diff --git a/files/templates/report_post_modal.html b/files/templates/report_post_modal.html index 9930c3038..61edbdb30 100644 --- a/files/templates/report_post_modal.html +++ b/files/templates/report_post_modal.html @@ -19,17 +19,8 @@ -
- - -
- \ No newline at end of file + \ No newline at end of file diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html index ff85b26ee..33355889f 100644 --- a/files/templates/util/assetcache.html +++ b/files/templates/util/assetcache.html @@ -19,7 +19,7 @@ set CACHE_VER = { 'js/bootstrap.js': 4000, 'js/category_modal.js': 4000, 'js/comments_admin.js': 4000, - 'js/comments_v.js': 4000, + 'js/comments_v.js': 4001, 'js/submission_listing.js': 4000, 'js/emoji_modal.js': 4001, 'js/formatting.js': 4000,