Fix .js on removed comments. Removed duplicate post_comment
This commit is contained in:
parent
b87df9db36
commit
09c84030b5
2 changed files with 11 additions and 48 deletions
|
@ -144,44 +144,6 @@ function delete_commentModal(id) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
post_comment=function(fullname){
|
|
||||||
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('formkey', formkey());
|
|
||||||
form.append('parent_fullname', fullname);
|
|
||||||
form.append('submission', document.getElementById('reply-form-submission-'+fullname).value);
|
|
||||||
form.append('body', document.getElementById('reply-form-body-'+fullname).value);
|
|
||||||
form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]);
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("post", "/comment");
|
|
||||||
xhr.withCredentials=true;
|
|
||||||
xhr.onload=function(){
|
|
||||||
if (xhr.status==200) {
|
|
||||||
commentForm=document.getElementById('comment-form-space-'+fullname);
|
|
||||||
commentForm.innerHTML=JSON.parse(xhr.response)["html"];
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
|
||||||
myToast.hide();
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var commentError = document.getElementById("comment-error-text");
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.hide();
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
|
||||||
myToast.show();
|
|
||||||
commentError.textContent = JSON.parse(xhr.response)["error"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.send(form)
|
|
||||||
|
|
||||||
document.getElementById('save-reply-to-'+fullname).classList.add('disabled');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
post_reply=function(id){
|
post_reply=function(id){
|
||||||
|
|
||||||
var form = new FormData();
|
var form = new FormData();
|
||||||
|
@ -248,7 +210,7 @@ comment_edit=function(id){
|
||||||
}
|
}
|
||||||
xhr.send(form)
|
xhr.send(form)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post_comment=function(fullname, postId){
|
post_comment=function(fullname, postId){
|
||||||
|
|
||||||
|
@ -259,6 +221,7 @@ post_comment=function(fullname, postId){
|
||||||
form.append('submission', document.getElementById('reply-form-submission-'+fullname).value);
|
form.append('submission', document.getElementById('reply-form-submission-'+fullname).value);
|
||||||
form.append('body', document.getElementById('reply-form-body-'+fullname).value);
|
form.append('body', document.getElementById('reply-form-body-'+fullname).value);
|
||||||
form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]);
|
form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]);
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("post", "/comment");
|
xhr.open("post", "/comment");
|
||||||
xhr.withCredentials=true;
|
xhr.withCredentials=true;
|
||||||
|
|
|
@ -64,9 +64,9 @@
|
||||||
<div id="comment-{{c.id}}-only">
|
<div id="comment-{{c.id}}-only">
|
||||||
|
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span>
|
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span>
|
||||||
{% if standalone and c.over_18 %}<span class="badge badge-danger">+18</span> {% endif %}
|
{% if standalone and c.over_18 %}<span class="badge badge-danger">+18</span> {% endif %}
|
||||||
[{% if c.is_banned %}Removed by admins{% elif c.deleted_utc > 0 %}Deleted by author{% elif c.is_blocking %}You are blocking @{{c.author.username}}{% elif c.is_blocked %}This user has blocked you{% endif %}]
|
[{% if c.is_banned %}Removed by admins{% elif c.deleted_utc > 0 %}Deleted by author{% elif c.is_blocking %}You are blocking @{{c.author.username}}{% elif c.is_blocked %}This user has blocked you{% endif %}]
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -518,15 +518,15 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(() => {
|
(() => {
|
||||||
const date = new Date('{{c.created_datetime}}');
|
const date = new Date('{{c.created_datetime}}');
|
||||||
document.getElementById('timestamp-{{c.id}}').title = date.toString();
|
document.getElementById('timestamp-{{c.id}}').title = date.toString();
|
||||||
})()
|
})()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% for comment in comments %}
|
{% for comment in comments %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue