feat: finish renderComment

feat/fix/umd
SukkaW 7 years ago
parent 10e66a97f9
commit 2a4a918259

@ -295,6 +295,12 @@ function DisqusJS(config) {
return commentLists; return commentLists;
} }
/*
* renderCommentData(data) - 渲染评论列表
*
* @param {Object} data - getComment() 获取到的 JSON
*/
let renderComment = (data) => {
/* /*
* processData(data) - 处理评论列表 * processData(data) - 处理评论列表
* *
@ -358,22 +364,45 @@ function DisqusJS(config) {
return html; return html;
} }
let childrenComments = (data) => {
var nesting = data.nesting,
children = (data.children || []);
if (!children) {
return;
}
/* let html = (() => {
* renderCommentData(data) - 渲染评论列表 // 如果当前评论嵌套数大于 4 则不再右移
* if (nesting < 4) {
* @param {Object} data - getComment() 获取到的 JSON return '<ul class="dsqjs-post-list dsqjs-children">';
*/ } else {
let renderComment = (data) => { return '<ul class="dsqjs-post-list">';
var html = ''; }
})();
html += children.map((comment) => {
comment = processData(comment);
comment.nesting = nesting + 1;
return `<li data-id="comment-${comment.comment.id}">${renderPostItem(comment.comment)}${childrenComments(comment)}</li>`;
});
html += '</ul>';
if (html.length !== 0) {
return html;
} else {
return;
}
}
let html = ''
data = parseCommentData(data); data = parseCommentData(data);
data.map((comment) => { html += data.map((comment) => {
comment = processData(comment); comment = processData(comment);
console.log(comment) return `<ul class="dsqjs-post-list"><li data-id="comment-${comment.comment.id}">${renderPostItem(comment.comment)}${childrenComments(comment)}</li></ul>`;
html += `<li data-id="comment-${comment.comment.id}">${renderPostItem(comment.comment)}${childrenComments(s)}</li>`; });
})
console.log(html) console.log(html)
} }

Loading…
Cancel
Save