diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 6584c6380..b4911963f 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -152,9 +152,19 @@ function post_reply(id){ try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} if (data && data["comment"]) { - commentForm=document.getElementById('comment-form-space-'+id); - commentForm.innerHTML = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '').replace('comment-collapse-desktop d-none d-md-block','d-none').replace('border-left: 2px solid','padding-left:0;border-left: 0px solid'); - bs_trigger(commentForm); + const comments = document.getElementById('replies-of-c_' + id); + const comment = data["comment"].replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, ''); + + comments.innerHTML = comments.innerHTML + comment; + + bs_trigger(comments); + + btn.disabled = false; + btn.classList.remove('disabled'); + + document.getElementById('reply-form-body-'+id).value = '' + document.getElementById('message-reply-'+id).innerHTML = '' + ToggleReplyBox('reply-message-'+id) } else { if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; diff --git a/files/templates/comments.html b/files/templates/comments.html index 6ca262425..b75e244d0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -895,18 +895,20 @@ const detectionDiv = document.querySelector('#detection'); const isAutoDark = getComputedStyle(detectionDiv).backgroundColor != 'rgb(255, 255, 255)'; if (!isAutoDark) { - const element = document.getElementsByClassName('comment-section')[0]; - let color = getComputedStyle(element).getPropertyValue('background-color'); - color = 'rgba' + color.slice(3,-1) + ', 0.1)' + const element = document.getElementsByClassName('comment-section')[0] + if (element) { + let color = getComputedStyle(element).getPropertyValue('background-color'); + color = 'rgba' + color.slice(3,-1) + ', 0.1)' - const markTemplate = (name) => { - return `${name}`; - }; - const base64Mark = btoa(markTemplate("{{v.id}}")); - - var style = document.createElement('style'); - style.innerHTML = `.actual-post:not(.deleted):not(.banned),.comment-section>.comment{background-image:url("data:image/svg+xml;base64,${base64Mark}")}`; - document.getElementsByTagName('head')[0].appendChild(style); + const markTemplate = (name) => { + return `${name}`; + }; + const base64Mark = btoa(markTemplate("{{v.id}}")); + + var style = document.createElement('style'); + style.innerHTML = `.actual-post:not(.deleted):not(.banned),.comment-section>.comment{background-image:url("data:image/svg+xml;base64,${base64Mark}")}`; + document.getElementsByTagName('head')[0].appendChild(style); + } } {% endif %} diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html index 1c117e3ce..3ca6f25e1 100644 --- a/files/templates/util/assetcache.html +++ b/files/templates/util/assetcache.html @@ -18,7 +18,7 @@ set CACHE_VER = { 'js/award_modal.js': 4001, 'js/bootstrap.js': 4006, 'js/comments_admin.js': 4000, - 'js/comments_v.js': 4002, + 'js/comments_v.js': 4003, 'js/submission_listing.js': 4000, 'js/emoji_modal.js': 4004, 'js/formatting.js': 4000,