Skip to content

Commit

Permalink
Reviews: sort site filter list & remember selection on page reload
Browse files Browse the repository at this point in the history
  • Loading branch information
makyen committed Sep 10, 2020
1 parent 8c2587a commit 93c70c2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/javascript/review.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ route(/\/review\/[\w-]+\/?\d*$/i, async () => {
loadNextPost();
});

// Sort the site filter list
const siteSelect = $('#site_id');
const siteSelectOptions = siteSelect.find('option').toArray();
siteSelect.append(siteSelectOptions.sort((a, b) => {
if (a.value < 5 || b.value < 5) {
return a.value - b.value;
}
return a.textContent.trim().localeCompare(b.textContent.trim());
}));
// Keep site filter selection through page reload
siteSelect.val(localStorage['review-site-filter'] || 0);
siteSelect.on('change', () => {
localStorage['review-site-filter'] = siteSelect.val();
});

adjustReviewPageTitle();
});

Expand Down

0 comments on commit 93c70c2

Please sign in to comment.