module.exports = function() { this.compilePostCommentsHtml = (comments, next_comment, post_id, post_url, morechildren_ids, post_author, viewing_comment, user_preferences, last_known_depth) => { return new Promise((resolve, reject) => { (async () => { let comments_html function commentAuthor(comment, classlist, submitter, moderator) { let classes = classlist.join(' ') if (comment.author === '[deleted]') { var reveddit_url = "https://www.reveddit.com" + post_url.substr(post_url.indexOf('/r/')) + comments.id return `[deleted]` } else { return `${comment.author}${submitter || ''}${moderator || ''}` } } if(!user_preferences) user_preferences = {} if(comments.author !== undefined && comments.body_html !== undefined) { let classlist = [] let submitter_link = '' let moderator = false let submitter = false let edited_span = '' let controversial_span = '' if(post_author === comments.author) { classlist.push('submitter') submitter_link = `[S]` submitter = true } if(comments.distinguished === 'moderator') { classlist.push('green') moderator_badge = ` [M]` moderator = true } if(comments.score_hidden) { ups = `[score hidden]` } else { ups = `${kFormatter(comments.ups)} points` } if(comments.edited) { edited_span = `*` } if(comments.controversiality > 0) { controversial_span = `†` } comments_html = `
[M]` moderator = true } if(comment.score_hidden) { ups = `[score hidden]` } else { ups = `${kFormatter(comment.ups)} points` } if(comment.edited) { edited_span = `*` } if(comment.controversiality > 0) { controversial_span = `†` } comments_html += `${ups}
${timeDifference(comment.created)}${edited_span}
${comment.stickied ? 'stickied comment' : ''}
${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}
${ups}
${timeDifference(comments.created)}${edited_span}
${comments.stickied ? 'stickied comment' : ''}
${commentAuthor(comments, classlist, submitter && submitter_link, moderator && moderator_badge)}
${comments.user_flair}
${ups}${controversial_span}
${timeDifference(comments.created)}${edited_span}
${comments.stickied ? 'stickied comment' : ''}