From e64c13fe6069e752e64bb8c3095c042333ec3164 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Wed, 10 Oct 2018 20:43:35 +0800 Subject: [PATCH] fix/style: code style improvement --- src/disqus.js | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/disqus.js b/src/disqus.js index 94b343e..e1bd0e2 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -41,7 +41,7 @@ try { localStorage.setItem(key, value); } catch (o) { - console.log(o + " Failed to set localStorage item"); + console.log("Failed to set localStorage item"); } }, @@ -50,9 +50,8 @@ }, dateFormat = (date) => { - return `${date.getUTCFullYear().toString()}/${(date.getUTCMonth() + 1).toString()}/${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}:${date.getUTCSeconds()}` + return `${date.getUTCFullYear().toString()}/${(date.getUTCMonth() + 1).toString()}/${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}:${date.getUTCSeconds()}`; //yyyy-MM-dd hh:mm:ss - }; /* @@ -68,7 +67,7 @@ s.src = 'https://' + disqusjs.config.shortname + '.disqus.com/embed.js'; s.setAttribute('data-timestamp', + new Date()); (d.head || d.body).appendChild(s); - } + }; /* * Name: checkDisqus() @@ -215,11 +214,11 @@ var topLevelComments = []; var childComments = []; - data.forEach(comment => { + data.forEach((comment) => { (comment.parent ? childComments : topLevelComments)['push'](comment); - }) + }); - var commentLists = topLevelComments.map(comment => { + var commentLists = topLevelComments.map((comment) => { return { comment, author: comment.author.name, @@ -229,7 +228,9 @@ }); function getChildren(id) { - if (childComments.length === 0) return null; + if (childComments.length === 0) { + return null + }; var list = []; for (let comment of childComments) { @@ -276,7 +277,7 @@ } - data.map(s => { + data.map((s) => { let childrenComments = (s) => { var nesting = s.nesting @@ -292,7 +293,7 @@ var html = ''; @@ -334,23 +335,23 @@ if (comment.author.profileUrl) { comment.avatarEl = ``; - comment.authorEl = `${comment.author.name}` + comment.authorEl = `${comment.author.name}`; } else { comment.avatarEl = ``; - comment.authorEl = `${comment.author.name}` + comment.authorEl = `${comment.author.name}`; } if (s.isPrimary) { - comment.authorEl += `${disqusjs.config.adminLabel}` + comment.authorEl += `${disqusjs.config.adminLabel}`; } if (s.children) { - s.nesting = 1 + s.nesting = 1; } - let html = `
  • ` + let html = `
  • `; - html += renderCommentItem(comment) + html += renderCommentItem(comment); html += `${childrenComments(s)}
  • `;