if(typeof jQuery==='undefined'){console.error("jQuery is required for comments-toggle.js.")}jQuery(document).ready(function($){function setCommentDepths(){$('.comment').filter(function(){return $(this).parents('.comment').length===0}).each(function(){traverseComment($(this),0)})}function traverseComment($comment,depth){$comment.attr('data-depth',depth);if($comment.find(".comment-toggle-arrow").length===0){var $arrow=$('');$comment.find('.userinfo').first().prepend($arrow)}$comment.children('.comment').each(function(){traverseComment($(this),depth+1)})}function toggleComment($comment){var depth=parseInt($comment.attr('data-depth'),10)||0;$comment.toggleClass('collapsed');$comment.nextAll().each(function(){var $next=$(this);var nextDepth=parseInt($next.attr('data-depth'),10);if(isNaN(nextDepth)){return true;}if(nextDepth<=depth){return false;}$next.toggleClass('hidden')})}setCommentDepths();$('body').on('click','.comment-toggle-arrow',function(e){e.preventDefault();var $comment=$(this).closest('.comment');toggleComment($comment);if($comment.hasClass('collapsed')){$(this).html('▲')}else{$(this).html('▼')}})});