Add option to hide all reddit comments

This commit is contained in:
Omar Roth 2018-03-12 18:36:08 -05:00
parent d7168815aa
commit 2bae09e018
1 changed files with 19 additions and 1 deletions

View File

@ -71,7 +71,18 @@ function toggle(target) {
target.innerHTML = '[ - ]'; target.innerHTML = '[ - ]';
body.style.display = ''; body.style.display = '';
} }
};
function toggle_comments(target) {
body = target.parentNode.parentNode.parentNode.children[1];
if (body.style.display === null || body.style.display === '') {
target.innerHTML = '[ + ]';
body.style.display = 'none';
} else {
target.innerHTML = '[ - ]';
body.style.display = '';
} }
};
</script> </script>
<div class="l-box"> <div class="l-box">
@ -116,13 +127,20 @@ function toggle(target) {
</div> </div>
<hr style="margin-left:1em; margin-right:1em;"> <hr style="margin-left:1em; margin-right:1em;">
<% if reddit_thread && !reddit_html.empty? %> <% if reddit_thread && !reddit_html.empty? %>
<div>
<div style="overflow-wrap:break-word; word-wrap:break-word;"> <div style="overflow-wrap:break-word; word-wrap:break-word;">
<h3><%= reddit_thread.data.title %></h3> <h3>
<a href="javascript:void(0)" onclick="toggle_comments(this)">[ - ]</a>
<%= reddit_thread.data.title %>
</h3>
<b> <b>
<a target="_blank" href="https://reddit.com<%= reddit_thread.data.permalink %>">View more comments on Reddit</a> <a target="_blank" href="https://reddit.com<%= reddit_thread.data.permalink %>">View more comments on Reddit</a>
</b> </b>
</div>
<div>
<%= reddit_html %> <%= reddit_html %>
</div> </div>
</div>
<% end %> <% end %>
</div> </div>
</div> </div>