Skip to content

Commit

Permalink
fix filter bug (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
winprn authored Oct 19, 2023
1 parent 10925b5 commit a2cdd8b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions templates/contest/ranking.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@
$('#apply-organization-filter').click(function () {
$('#org-check-list-wrapper').hide();

let selected_orgs = $('#org-check-list').val().map(x => x.trim());
localStorage.setItem(`filter-selected-orgs-${contest_key}`, selected_orgs);
const selected_orgs = [];
$('#org-check-list').val().forEach(function (el) {
selected_orgs.push(el.trim());
});
localStorage.setItem(`filter-selected-orgs-${contest_key}`, JSON.stringify(selected_orgs));
window.applyRankingFilter();
});

Expand Down Expand Up @@ -323,7 +326,7 @@
window.applyRankingFilter = function () {
let counter = 0;
let previous_abs_rank = -1;
let selected_orgs = localStorage.getItem(`filter-selected-orgs-${contest_key}`);
let selected_orgs = JSON.parse(localStorage.getItem(`filter-selected-orgs-${contest_key}`));

if (!selected_orgs.length) {
window.clearRankingFilter();
Expand All @@ -336,7 +339,14 @@
let org_anchor = row.find("div > div > .personal-info > .organization > a")[0];
let org = org_anchor ? org_anchor.text : 'Other';

if (!selected_orgs.includes(org.trim())) {
let should_show_org = false;
selected_orgs.forEach(function (selected_org) {
if (selected_org === org.trim()) {
should_show_org = true;
}
});

if (!should_show_org) {
row.hide();
return;
}
Expand Down

0 comments on commit a2cdd8b

Please sign in to comment.