From e51ff05e3f8f86f2c460c085e6fe472cb2758608 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Mon, 19 Feb 2024 09:17:29 -0700 Subject: [PATCH] Replace selectedIndex with value statements. --- htdocs/js/AchievementList/achievementlist.js | 14 +++++++------- htdocs/js/ProblemSetList/problemsetlist.js | 10 +++++----- htdocs/js/UserList/userlist.js | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/js/AchievementList/achievementlist.js b/htdocs/js/AchievementList/achievementlist.js index 8d86a75f4f..878a90fe8c 100644 --- a/htdocs/js/AchievementList/achievementlist.js +++ b/htdocs/js/AchievementList/achievementlist.js @@ -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'); @@ -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'); @@ -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'); @@ -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(); } @@ -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'; }; diff --git a/htdocs/js/ProblemSetList/problemsetlist.js b/htdocs/js/ProblemSetList/problemsetlist.js index e66cee6cec..bdcfd6814a 100644 --- a/htdocs/js/ProblemSetList/problemsetlist.js +++ b/htdocs/js/ProblemSetList/problemsetlist.js @@ -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( @@ -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'); @@ -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(); } @@ -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'; }; diff --git a/htdocs/js/UserList/userlist.js b/htdocs/js/UserList/userlist.js index 02907d31eb..338b9e6f8f 100644 --- a/htdocs/js/UserList/userlist.js +++ b/htdocs/js/UserList/userlist.js @@ -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'; }; @@ -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'); @@ -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');