Skip to content

Commit

Permalink
hide all comments logic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rystaf committed Jul 11, 2023
1 parent dcc3cd4 commit ca47ace
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions public/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,24 @@ 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")
if (!btn.length) { continue }
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
Expand Down
2 changes: 1 addition & 1 deletion templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit ca47ace

Please sign in to comment.