From cf5e594a01b0ad11b1365e8d3f7b1c56f352d3f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 29 Jun 2011 09:13:11 +0200 Subject: [PATCH] Add sorting Sones by posts. --- src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java | 6 ++++++ src/main/resources/templates/knownSones.html | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java index 0eedec6..ad63791 100644 --- a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -90,6 +90,12 @@ public class KnownSonesPage extends SoneTemplatePage { } else { Collections.sort(knownSones, Sone.LAST_ACTIVITY_COMPARATOR); } + } else if ("posts".equals(sortField)) { + if ("asc".equals(sortOrder)) { + Collections.sort(knownSones, new ReverseComparator(Sone.POST_COUNT_COMPARATOR)); + } else { + Collections.sort(knownSones, Sone.POST_COUNT_COMPARATOR); + } } else { if ("desc".equals(sortOrder)) { Collections.sort(knownSones, new ReverseComparator(Sone.NICE_NAME_COMPARATOR)); diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html index ab36861..d3f4846 100644 --- a/src/main/resources/templates/knownSones.html +++ b/src/main/resources/templates/knownSones.html @@ -7,7 +7,7 @@ $(document).ready(function() { $("select[name=sort]").change(function() { value = $(this).val(); - if (value == "activity") { + if ((value == "activity") || (value == "posts")) { $("select[name=order]").val("desc"); } else if (value == "name") { $("select[name=order]").val("asc"); @@ -29,6 +29,7 @@