hide all comments logic fix

This commit is contained in:
Ryan Stafford 2023-07-11 13:59:30 -04:00
parent dcc3cd4d49
commit ca47acec84
2 changed files with 7 additions and 4 deletions

View file

@ -165,6 +165,11 @@ function loadMore(e) {
function hideAllChildComments(e) {
e.preventDefault()
var comments = document.getElementsByClassName("comment")
if (e.target.innerHTML == "hide all child comments") {
e.target.innerHTML = "show all child comments"
} else {
e.target.innerHTML = "hide all child comments"
}
for (var i = 0; i < comments.length; i++) {
var comment = comments[i]
var btn = comment.getElementsByClassName("hidechildren")
@ -172,14 +177,12 @@ function hideAllChildComments(e) {
btn = btn[0]
if (btn.getAttribute("for") != comment.id) { continue }
var children = comment.getElementsByClassName("children")[0]
if (children.className.indexOf("hidden") == -1) {
if (e.target.innerHTML == "show all child comments") {
children.className = "children hidden"
btn.className = "hidechildren hidden"
e.target.innerHTML = "show all child comments"
} else {
children.className = "children"
btn.className = "hidechildren"
e.target.innerHTML = "hide all child comments"
}
}
return false

View file

@ -133,7 +133,7 @@
{{ end }}
{{ end }}
<script src="/_/static/utils.js?v=15"></script>
<script src="/_/static/utils.js?v=16"></script>
{{ template "sidebar.html" . }}
</main>
{{ end }}