From 38d7dfd7e3d3516475993bf1238fabd76f7e7c48 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 3 Mar 2018 22:36:18 -0600 Subject: [PATCH] Allow for collapsing and expanding of Reddit comments --- src/helpers.cr | 8 ++++---- src/views/watch.ecr | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/helpers.cr b/src/helpers.cr index e4674c3e..a8beb16f 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -321,12 +321,12 @@ def template_comments(root) content = <<-END_HTML

- [ - ] - #{score} - #{author} + [ - ] #{score} #{author}

-

#{body_html}

+
+ #{body_html} #{replies_html} +
END_HTML if child["data"]["depth"].as_i > 0 diff --git a/src/views/watch.ecr b/src/views/watch.ecr index 4e75cc7e..f2a205d5 100644 --- a/src/views/watch.ecr +++ b/src/views/watch.ecr @@ -61,8 +61,15 @@ var player = videojs('player', options, function() { }); }); -function dismiss(target) { - target.style.display = 'none'; +function toggle(target) { + body = target.parentNode.parentNode.children[1]; + if (body.style.display === null || body.style.display === '') { + target.innerHTML = '[ + ]'; + body.style.display = 'none'; + } else { + target.innerHTML = '[ - ]'; + body.style.display = ''; + } }