function buildCommentHTML(comment) { var depthClass = ""; var githubIcon = ""; var twitterIcon = ""; var customClass = ""; var detailsStartHTML = ""; var detailsFinishHTML = ""; var body = ""; if (!comment.newly_created) { depthClass="child flat-node" } else if (comment.depth == 0 ){ depthClass = "root"; } else if (comment.depth < 3) { depthClass="child" } else { depthClass="child flat-node" } if (comment.user.twitter_username && comment.user.twitter_username.length > 0) { twitterIcon = '<%= image_tag("twitter-logo.svg", class:"icon-img", alt: "twitter logo") %>' } if (comment.user.github_username && comment.user.github_username.length > 0) { githubIcon = '<%= image_tag("github-logo.svg", class:"icon-img", alt: "github logo") %>' } if (comment.newly_created) { customClass = "comment-created-via-fetch" } if (comment.depth < 3) { detailsStartHTML = '
 ' detailsFinishHTML = '
' } body = '\ '+detailsStartHTML+'\
\
\
\
\ \ '+comment.user.username+'\ '+comment.user.name+'\ \ '+twitterIcon+'\ '+githubIcon+'\ \ \ \
\
\ '+comment.body_html+'\ '+reactions(comment)+'\
\ '+actions(comment)+'\
\
\ '+detailsFinishHTML; return body; } function actions(comment) { if (comment.newly_created) { return '
\ \ DELETE\ EDIT\ \ Reply\
'; } else { return '
\ VIEW/REPLY\
'; } } function reactions(comment) { if (comment.newly_created) { return ''; } else { if (comment.heart_ids.indexOf(userData().id) > -1) { var reactedClass = "reacted"; } else { var reactedClass = "" } return ''; } }