-
-
Save agentlame/6109377 to your computer and use it in GitHub Desktop.
modtools pagination fix
This file contains hidden or 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
| // Function to sort items | |
| function sortThings(order, asc) { | |
| var pagination = $('#siteTable .nextprev'); | |
| var things = $('#siteTable .thing').sort(function (a, b) { | |
| (asc) ? (A = a, B = b) : (A = b, B = a); | |
| switch (order) { | |
| case 'age': | |
| var timeA = new Date($(A).find('time:first').attr('datetime')).getTime(), | |
| timeB = new Date($(B).find('time:first').attr('datetime')).getTime(); | |
| return timeA - timeB; | |
| case 'score': | |
| var scoreA = $(A).find('.score:visible').text().match(numberRX), | |
| scoreB = $(B).find('.score:visible').text().match(numberRX); | |
| return scoreA - scoreB; | |
| case 'reports': | |
| var reportsA = $(A).find('.reported-stamp').text().match(numberRX), | |
| reportsB = $(B).find('.reported-stamp').text().match(numberRX); | |
| return reportsA - reportsB; | |
| } | |
| }); | |
| $('#siteTable').empty().append(things).append(pagination); | |
| } | |
| sortThings(listingOrder, sortAscending); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment