Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix filter bug #340

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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