-
-
Save leandromoreira/30198799a714cd4e3a1b to your computer and use it in GitHub Desktop.
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