/1-top-comments.js Secret
Last active
December 22, 2015 13:56
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var top10LatestCommentsFrom = (userId) => { | |
var onSuccess = (rawData) => { | |
var topLatestComments = [] | |
var allComments = rawData.data.comments | |
allComments = allComments.sort((date1, date2) => { | |
return new Date(date1.date) - new Date(date1.date) | |
}) | |
allComments.forEach((comment) => { | |
if (comment.isTop()) { | |
topLatestComments.push(comment) | |
} | |
} | |
app.topComments = topLatestComments.slice(0,10) | |
} | |
var onError = (error) => { | |
this.sendError(error) | |
app.topComments = [] | |
} | |
this.ajax(`/all/${userId}/comments/`, onSuccess, onError) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment