forked from rDrama/rDrama
allow ppl to make multiple comments to the same parents without reloading the page
parent
008f12a1f3
commit
46786e117b
|
@ -201,7 +201,7 @@ function comment_edit(id){
|
|||
xhr.send(form)
|
||||
}
|
||||
|
||||
function post_comment(fullname){
|
||||
function post_comment(fullname, hide){
|
||||
const btn = document.getElementById('save-reply-to-'+fullname)
|
||||
btn.disabled = true
|
||||
btn.classList.add('disabled');
|
||||
|
@ -227,19 +227,41 @@ function post_comment(fullname){
|
|||
try {data = JSON.parse(xhr.response)}
|
||||
catch(e) {console.log(e)}
|
||||
if (data && data["comment"]) {
|
||||
commentForm=document.getElementById('comment-form-space-'+fullname);
|
||||
commentForm.innerHTML = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '');
|
||||
console.log(hide)
|
||||
document.getElementById(hide).classList.add('d-none');
|
||||
|
||||
let id = fullname.split('_')[1];
|
||||
let name = 'comment-form-space-' + fullname;
|
||||
commentForm = document.getElementById(name);
|
||||
|
||||
let comments = document.getElementById('replies-of-' + id);
|
||||
let comment = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '');
|
||||
|
||||
comments.innerHTML = comment + comments.innerHTML;
|
||||
|
||||
bs_trigger(commentForm);
|
||||
|
||||
let placeholder = document.getElementById("placeholder-comment");
|
||||
if(placeholder){
|
||||
comments.classList.remove('text-center');
|
||||
comments.classList.remove('py-7');
|
||||
placeholder.parentNode.removeChild(placeholder);
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('disabled');
|
||||
|
||||
document.getElementById('reply-form-body-'+fullname).value = ''
|
||||
}
|
||||
else {
|
||||
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
|
||||
else document.getElementById('toast-post-error-text').innerText = "Error, please try again later."
|
||||
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show();
|
||||
setTimeout(() => {
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('disabled');
|
||||
}, 2000);
|
||||
}
|
||||
setTimeout(() => {
|
||||
btn.disabled = false;
|
||||
btn.classList.remove('disabled');
|
||||
}, 2000);
|
||||
}
|
||||
xhr.send(form)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue