From f27957a7a4053ec4ba38a2bcd2b49640456f9dd4 Mon Sep 17 00:00:00 2001 From: Glenn Tanner Date: Thu, 2 Dec 2021 13:07:29 -0500 Subject: [PATCH] Added result sorting by downloads and/or stars * Was unable to add the checkboxes side-by-side, due to overlapping, thus I stacked them. * Set most downloads as the prefered order. * Selection change invokes search. * Did not add a method for default selection as I do not know how to. --- lib/install-panel.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/install-panel.js b/lib/install-panel.js index 6ea65d4ed..fd1b898aa 100644 --- a/lib/install-panel.js +++ b/lib/install-panel.js @@ -98,6 +98,14 @@ export default class InstallPanel { +
+
+ Downloads +
+
+ Stars +
+
@@ -220,6 +228,9 @@ export default class InstallPanel { this.refs.searchMessage.style.display = '' } + if (searchSortDownloadsID.checked && searchSortStarsID.checked) { packages.sort(function(a, b) {return b.downloads - a.downloads || b.stargazers_count - a.stargazers_count;}); } + else if (searchSortDownloadsID.checked) { packages.sort(function(a, b) {return b.downloads - a.downloads;}); } + else if (searchSortStarsID.checked) { packages.sort(function(a, b) {return b.stargazers_count - a.stargazers_count;}); } this.addPackageViews(this.refs.resultsContainer, packages) } catch (error) { this.refs.searchMessage.style.display = 'none'