Fixed reply-twice bug on submission page.

This commit is contained in:
Michael House 2022-06-29 00:25:11 -05:00 committed by GitHub
parent 17217d56c2
commit db185a9ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View file

@ -240,12 +240,24 @@ 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, '');
let id = fullname.split('_')[1];
let name = 'comment-form-space-' + fullname;
commentForm = document.getElementById(name);
// dynamically insert comment into the comments section of the current comment/post
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);
// remove the placeholder if it exists
let placeholder = document.getElementById("placeholder-comment");
if(placeholder){
// clear out the text-center classes etc.
comments.classList.remove('text-center');
comments.classList.remove('py-7');
placeholder.parentNode.removeChild(placeholder);
}
}