forked from rDrama/rDrama
90 lines
3.2 KiB
HTML
90 lines
3.2 KiB
HTML
<script>
|
|
// Report Submission
|
|
|
|
report_postModal = function(id, author) {
|
|
|
|
document.getElementById("post-author").textContent = author;
|
|
|
|
submitbutton=document.getElementById("reportPostButton");
|
|
|
|
submitbutton.onclick = function() {
|
|
|
|
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Reporting post';
|
|
this.disabled = true;
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("POST", '/flag/post/'+id, true);
|
|
var form = new FormData()
|
|
form.append("formkey", formkey());
|
|
form.append("reason", document.getElementById("reason").value);
|
|
|
|
xhr.withCredentials=true;
|
|
|
|
xhr.onload=function() {
|
|
document.getElementById("reportPostFormBefore").classList.add('d-none');
|
|
document.getElementById("reportPostFormAfter").classList.remove('d-none');
|
|
};
|
|
|
|
xhr.onerror=function(){alert(errortext)};
|
|
xhr.send(form);
|
|
|
|
}
|
|
};
|
|
|
|
document.getElementById('reportPostModal').addEventListener('hidden.bs.modal', function () {
|
|
|
|
var button = document.getElementById("reportPostButton");
|
|
|
|
var beforeModal = document.getElementById("reportPostFormBefore");
|
|
var afterModal = document.getElementById("reportPostFormAfter");
|
|
|
|
button.innerHTML='Report post';
|
|
button.disabled= false;
|
|
|
|
afterModal.classList.add('d-none');
|
|
|
|
if ( beforeModal.classList.contains('d-none') ) {
|
|
beforeModal.classList.remove('d-none');
|
|
}
|
|
|
|
});
|
|
</script>
|
|
|
|
<!-- Report Post Modal -->
|
|
<div class="modal fade" id="reportPostModal" tabindex="-1" role="dialog" aria-labelledby="reportPostModalTitle" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Report <span id="post-author"></span>'s post</h5>
|
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
|
</button>
|
|
</div>
|
|
<!-- Before report is made, show this -->
|
|
<div class="" id="reportPostFormBefore">
|
|
<form id="report-post-form" method="post">
|
|
<div class="modal-body">
|
|
<div class="h6">We're sorry something here is wrong.</div>
|
|
<small class="form-text text-muted">Please enter a reason for reporting below.</small>
|
|
<pre></pre>
|
|
<input maxlength="100" id="reason" class="form-control"/>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="button" id="reportPostButton" class="btn btn-danger">Report post</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<!-- After report is made, show this -->
|
|
<div class="d-none" id="reportPostFormAfter">
|
|
<div class="modal-body">
|
|
<div class="h6">Thank you for reporting this post!</div>
|
|
<small class="form-text text-muted">We'll take it from here.</small>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |