diff options
author | Jan Müller <jpmueller@gmx.net> | 2013-11-23 22:06:59 +0100 |
---|---|---|
committer | Jan Müller <jpmueller@gmx.net> | 2013-11-23 22:06:59 +0100 |
commit | 18024acc4c3008e294d4301c39e20ca7c4f28919 (patch) | |
tree | 45736f21ad8ce50a4733635cab50e4d30c6ad735 /pelican-bootstrap3/static/js | |
parent | 7ef242b7580306f953756a7ea3d2632c70ef30b8 (diff) | |
download | pelican-themes-18024acc4c3008e294d4301c39e20ca7c4f28919.tar.gz |
github activity: allow sorting by an arbitrary attribute (GITHUB_SORT_ATTRIBUTE) and ascending/descending (GITHUB_SORT_DESCENDING)
Diffstat (limited to 'pelican-bootstrap3/static/js')
-rw-r--r-- | pelican-bootstrap3/static/js/github.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/pelican-bootstrap3/static/js/github.js b/pelican-bootstrap3/static/js/github.js index 7bdb6a4..0ac60ef 100644 --- a/pelican-bootstrap3/static/js/github.js +++ b/pelican-bootstrap3/static/js/github.js @@ -24,13 +24,11 @@ var github = (function(){ repos.push(data.data[i]); } repos.sort(function(a, b) { - var aDate = new Date(a.pushed_at).valueOf(), - bDate = new Date(b.pushed_at).valueOf(); - - if (aDate === bDate) { return 0; } - return aDate > bDate ? -1 : 1; + if (a[options.sort_attribute] > b[options.sort_attribute]) { return 1; } + if (a[options.sort_attribute] < b[options.sort_attribute]) { return -1; } + return 0; }); - + if (options.sort_descending) { repos.reverse(); } if (options.count) { repos.splice(options.count); } render(options.target, repos); } |