/0-top-comments.js Secret
Last active
December 20, 2015 19:58
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 topComments = (id) => { | |
var succCB = (d) => { | |
var a = d.data.comments | |
var top = [] | |
a.sort((d1, d2) => { | |
return new Date(d1.date) - new Date(d2.date) | |
}) | |
a.forEach((c) => { | |
if (c.isTop()) { | |
top.push(c) | |
} | |
} | |
app.topComments = top.slice(0,10) | |
} | |
var errCB = (e) => { | |
this.sendError(e) | |
app.topComments = [] | |
} | |
this.ajax(`/all/${id}/comments/`, succCB, errCB) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment