Skip to content

Commit

Permalink
Replace selectedIndex with value statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
somiaj committed Feb 24, 2024
1 parent 4d3f77e commit e51ff05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions htdocs/js/AchievementList/achievementlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
const action = document.getElementById('current_action')?.value || '';
if (action === 'filter') {
const filter_select = document.getElementById('filter_select');
const filter = filter_select?.selectedIndex || 0;
const filter = filter_select?.value || '';
const filter_text = document.getElementById('filter_text');
const filter_category = document.getElementById('filter_category');
if (filter === 1 && !is_achievement_selected()) {
if (filter === 'selected' && !is_achievement_selected()) {
e.preventDefault();
e.stopPropagation();
filter_select?.classList.add('is-invalid');
Expand All @@ -37,7 +37,7 @@
},
{ once: true }
);
} else if (filter === 2 && filter_text?.value === '') {
} else if (filter === 'match_ids' && filter_text?.value === '') {
e.preventDefault();
e.stopPropagation();
document.getElementById('filter_text_err_msg')?.classList.remove('d-none');
Expand All @@ -61,7 +61,7 @@
},
{ once: true }
);
} else if (filter === 3 && filter_category?.value === '') {
} else if (filter === 'match_category' && filter_category?.value === '') {
e.preventDefault();
e.stopPropagation();
document.getElementById('filter_category_err_msg')?.classList.remove('d-none');
Expand Down Expand Up @@ -177,7 +177,7 @@
},
{ once: true }
);
} else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_achievement_selected()) {
} else if (document.getElementById('create_select')?.value == 'copy' && !is_achievement_selected()) {
e.preventDefault();
e.stopPropagation();
}
Expand Down Expand Up @@ -221,9 +221,9 @@
const filter_text_elements = document.getElementById('filter_text_elements');
const filter_category_elements = document.getElementById('filter_category_elements');
const filterElementToggle = () => {
if (filter_select?.selectedIndex == 2) filter_text_elements.style.display = 'flex';
if (filter_select?.value === 'match_ids') filter_text_elements.style.display = 'flex';
else filter_text_elements.style.display = 'none';
if (filter_select?.selectedIndex == 3) filter_category_elements.style.display = 'flex';
if (filter_select?.value === 'match_category' ) filter_category_elements.style.display = 'flex';
else filter_category_elements.style.display = 'none';
};

Expand Down
10 changes: 5 additions & 5 deletions htdocs/js/ProblemSetList/problemsetlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
document.getElementById('problemsetlist')?.addEventListener('submit', (e) => {
const action = document.getElementById('current_action')?.value || '';
if (action === 'filter') {
const filter = document.getElementById('filter_select')?.selectedIndex || 0;
const filter = document.getElementById('filter_select')?.value || '';
const filter_text = document.getElementById('filter_text');
if (filter === 1 && !is_set_selected()) {
if (filter === 'selected' && !is_set_selected()) {
e.preventDefault();
e.stopPropagation();
document.getElementById('filter_select')?.addEventListener(
Expand All @@ -39,7 +39,7 @@
},
{ once: true }
);
} else if (filter === 2 && filter_text.value === '') {
} else if (filter === 'match_ids' && filter_text.value === '') {
e.preventDefault();
e.stopPropagation();
document.getElementById('filter_err_msg')?.classList.remove('d-none');
Expand Down Expand Up @@ -149,7 +149,7 @@
},
{ once: true }
);
} else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_set_selected()) {
} else if (document.getElementById('create_select')?.value == 'copy' && !is_set_selected()) {
e.preventDefault();
e.stopPropagation();
}
Expand Down Expand Up @@ -192,7 +192,7 @@
const filter_select = document.getElementById('filter_select');
const filter_elements = document.getElementById('filter_elements');
const filterElementToggle = () => {
if (filter_select?.selectedIndex == 2) filter_elements.style.display = 'flex';
if (filter_select?.value == 'match_ids') filter_elements.style.display = 'flex';
else filter_elements.style.display = 'none';
};

Expand Down
8 changes: 4 additions & 4 deletions htdocs/js/UserList/userlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const export_elements = document.getElementById('export_elements');
if (!export_elements) return;

if (export_select_target.selectedIndex === 0) export_elements.style.display = 'block';
if (export_select_target.value === 'new') export_elements.style.display = 'block';
else export_elements.style.display = 'none';
};

Expand Down Expand Up @@ -48,9 +48,9 @@
const action = document.getElementById('current_action')?.value || '';
if (action === 'filter') {
const filter_select = document.getElementById('filter_select');
const filter = filter_select?.selectedIndex || 0;
const filter = filter_select?.value || '';
const filter_text = document.getElementById('filter_text');
if (filter === 1 && !is_user_selected()) {
if (filter === 'selected' && !is_user_selected()) {
e.preventDefault();
e.stopPropagation();
filter_select.classList.add('is-invalid');
Expand All @@ -62,7 +62,7 @@
},
{ once: true }
);
} else if (filter === 2 && filter_text.value === '') {
} else if (filter === 'match_regex' && filter_text.value === '') {
e.preventDefault();
e.stopPropagation();
document.getElementById('filter_err_msg')?.classList.remove('d-none');
Expand Down

0 comments on commit e51ff05

Please sign in to comment.