From a2713ffcd5db570fceeae5767ac9677d25cf281a Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Tue, 9 Jan 2024 21:45:13 -0700 Subject: [PATCH] Run prettier on manager lists js files. --- htdocs/js/AchievementList/achievementlist.js | 46 ++++++++---- htdocs/js/ProblemSetList/problemsetlist.js | 73 ++++++++++++-------- htdocs/js/UserList/userlist.js | 56 ++++++++++----- 3 files changed, 114 insertions(+), 61 deletions(-) diff --git a/htdocs/js/AchievementList/achievementlist.js b/htdocs/js/AchievementList/achievementlist.js index bfde6f1ecb..8a67794511 100644 --- a/htdocs/js/AchievementList/achievementlist.js +++ b/htdocs/js/AchievementList/achievementlist.js @@ -5,13 +5,17 @@ if (achievement.checked) return true; } document.getElementById('select_achievement_err_msg')?.classList.remove('d-none'); - document.getElementById('achievement-table')?.addEventListener('change', e => { - document.getElementById('select_achievement_err_msg')?.classList.add('d-none'); - }, { once : true }); + document.getElementById('achievement-table')?.addEventListener( + 'change', + (e) => { + document.getElementById('select_achievement_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); return false; }; - document.getElementById('achievement-list')?.addEventListener('submit', e => { + document.getElementById('achievement-list')?.addEventListener('submit', (e) => { const action = document.getElementById('current_action')?.value || ''; if (['edit', 'assign', 'export', 'score'].includes(action)) { if (!is_achievement_selected()) { @@ -25,10 +29,14 @@ e.stopPropagation(); document.getElementById('create_file_err_msg')?.classList.remove('d-none'); create_text.classList.add('is-invalid'); - create_text.addEventListener('change', e => { - document.getElementById('create_file_err_msg')?.classList.add('d-none'); - document.getElementById('create_text')?.classList.remove('is-invalid'); - }, { once : true }); + create_text.addEventListener( + 'change', + (e) => { + document.getElementById('create_file_err_msg')?.classList.add('d-none'); + document.getElementById('create_text')?.classList.remove('is-invalid'); + }, + { once: true } + ); } else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_achievement_selected()) { e.preventDefault(); e.stopPropagation(); @@ -43,18 +51,26 @@ e.stopPropagation(); document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none'); delete_confirm.classList.add('is-invalid'); - delete_confirm.addEventListener('change', e => { - document.getElementById('delete_select')?.classList.remove('is-invalid'); - document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); - }, { once : true }); + delete_confirm.addEventListener( + 'change', + (e) => { + document.getElementById('delete_select')?.classList.remove('is-invalid'); + document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } }); // Remove select error message when changing tabs. for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) { - tab.addEventListener('shown.bs.tab', e => { - document.getElementById('select_achievement_err_msg')?.classList.add('d-none'); - }, { once : true }); + tab.addEventListener( + 'shown.bs.tab', + (e) => { + document.getElementById('select_achievement_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } })(); diff --git a/htdocs/js/ProblemSetList/problemsetlist.js b/htdocs/js/ProblemSetList/problemsetlist.js index ff42dc7b6e..9ce418dc57 100644 --- a/htdocs/js/ProblemSetList/problemsetlist.js +++ b/htdocs/js/ProblemSetList/problemsetlist.js @@ -5,13 +5,17 @@ if (set.checked) return true; } document.getElementById('select_set_err_msg')?.classList.remove('d-none'); - document.getElementById('set_table_id')?.addEventListener('change', e => { - document.getElementById('select_set_err_msg')?.classList.add('d-none'); - }, { once : true }); + document.getElementById('set_table_id')?.addEventListener( + 'change', + (e) => { + document.getElementById('select_set_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); return false; }; - document.getElementById('problemsetlist')?.addEventListener('submit', e => { + document.getElementById('problemsetlist')?.addEventListener('submit', (e) => { const action = document.getElementById('current_action')?.value || ''; if (action === 'filter') { const filter = document.getElementById('filter_select')?.selectedIndex || 0; @@ -24,10 +28,14 @@ e.stopPropagation(); document.getElementById('filter_err_msg')?.classList.remove('d-none'); filter_text.classList.add('is-invalid'); - filter_text.addEventListener('change', e => { - document.getElementById('filter_err_msg')?.classList.add('d-none'); - document.getElementById('filter_text')?.classList.remove('is-invalid'); - }, { once : true }); + filter_text.addEventListener( + 'change', + (e) => { + document.getElementById('filter_err_msg')?.classList.add('d-none'); + document.getElementById('filter_text')?.classList.remove('is-invalid'); + }, + { once: true } + ); } } else if (['edit', 'publish', 'export', 'save_export', 'score'].includes(action)) { if (!is_set_selected()) { @@ -41,10 +49,14 @@ e.stopPropagation(); document.getElementById('import_file_err_msg')?.classList.remove('d-none'); import_select.classList.add('is-invalid'); - import_select.addEventListener('change', e => { - document.getElementById('import_source_select')?.classList.remove('is-invalid'); - document.getElementById('import_file_err_msg')?.classList.add('d-none'); - }, { once : true }); + import_select.addEventListener( + 'change', + (e) => { + document.getElementById('import_source_select')?.classList.remove('is-invalid'); + document.getElementById('import_file_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } else if (action === 'create') { const create_text = document.getElementById('create_text'); @@ -53,10 +65,14 @@ e.stopPropagation(); document.getElementById('create_file_err_msg')?.classList.remove('d-none'); create_text.classList.add('is-invalid'); - create_text.addEventListener('change', e => { - document.getElementById('create_file_err_msg')?.classList.add('d-none'); - document.getElementById('create_text')?.classList.remove('is-invalid'); - }, { once : true }); + create_text.addEventListener( + 'change', + (e) => { + document.getElementById('create_file_err_msg')?.classList.add('d-none'); + document.getElementById('create_text')?.classList.remove('is-invalid'); + }, + { once: true } + ); } else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_set_selected()) { e.preventDefault(); e.stopPropagation(); @@ -71,17 +87,21 @@ e.stopPropagation(); document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none'); delete_confirm.classList.add('is-invalid'); - delete_confirm.addEventListener('change', e => { - document.getElementById('delete_select')?.classList.remove('is-invalid'); - document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); - }, { once : true }); + delete_confirm.addEventListener( + 'change', + (e) => { + document.getElementById('delete_select')?.classList.remove('is-invalid'); + document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } }); // Remove select error message when changing tabs. for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) { - tab.addEventListener('shown.bs.tab', e => { + tab.addEventListener('shown.bs.tab', (e) => { document.getElementById('select_set_err_msg')?.classList.add('d-none'); }); } @@ -135,17 +155,16 @@ // Initialize the date/time picker for the import form. const importDateShift = document.getElementById('import_date_shift'); if (importDateShift) { - luxon.Settings.defaultLocale = importDateShift.dataset.locale ?? 'en'; // Compute the time difference between the current browser timezone and the course timezone. // flatpickr gives the time in the browser's timezone, and this is used to adjust to the course timezone. // Note that this is in seconds. - const timezoneAdjustment = ( - (new Date((new Date).toLocaleString('en-US'))).getTime() - - (new Date((new Date).toLocaleString('en-US', - { timeZone: importDateShift.dataset.timezone ?? 'America/New_York' }))).getTime() - ); + const timezoneAdjustment = + new Date(new Date().toLocaleString('en-US')).getTime() - + new Date( + new Date().toLocaleString('en-US', { timeZone: importDateShift.dataset.timezone ?? 'America/New_York' }) + ).getTime(); const fp = flatpickr(importDateShift.parentNode, { allowInput: true, diff --git a/htdocs/js/UserList/userlist.js b/htdocs/js/UserList/userlist.js index 43945214e9..02372e8c35 100644 --- a/htdocs/js/UserList/userlist.js +++ b/htdocs/js/UserList/userlist.js @@ -31,13 +31,17 @@ if (user.checked) return true; } document.getElementById('select_user_err_msg')?.classList.remove('d-none'); - document.getElementById('classlist-table')?.addEventListener('change', e => { - document.getElementById('select_user_err_msg')?.classList.add('d-none'); - }, { once : true }); + document.getElementById('classlist-table')?.addEventListener( + 'change', + (e) => { + document.getElementById('select_user_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); return false; }; - document.getElementById('user-list-form')?.addEventListener('submit', e => { + document.getElementById('user-list-form')?.addEventListener('submit', (e) => { const action = document.getElementById('current_action')?.value || ''; if (action === 'filter') { const filter = document.getElementById('filter_select')?.selectedIndex || 0; @@ -50,10 +54,14 @@ e.stopPropagation(); document.getElementById('filter_err_msg')?.classList.remove('d-none'); filter_text.classList.add('is-invalid'); - filter_text.addEventListener('change', e => { - document.getElementById('filter_text')?.classList.remove('is-invalid'); - document.getElementById('filter_err_msg')?.classList.add('d-none'); - }, { once : true }); + filter_text.addEventListener( + 'change', + (e) => { + document.getElementById('filter_text')?.classList.remove('is-invalid'); + document.getElementById('filter_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } else if (action === 'edit' || action === 'password') { if (!is_user_selected()) { @@ -65,16 +73,22 @@ if (!is_user_selected()) { e.preventDefault(); e.stopPropagation(); - } else if (document.getElementById('export_select_target')?.value === 'new' && - export_filename.value === '') { + } else if ( + document.getElementById('export_select_target')?.value === 'new' && + export_filename.value === '' + ) { e.preventDefault(); e.stopPropagation(); document.getElementById('export_file_err_msg')?.classList.remove('d-none'); export_filename.classList.add('is-invalid'); - export_filename.addEventListener('change', e => { - document.getElementById('export_filename')?.classList.remove('is-invalid'); - document.getElementById('export_file_err_msg')?.classList.add('d-none'); - }, { once : true }); + export_filename.addEventListener( + 'change', + (e) => { + document.getElementById('export_filename')?.classList.remove('is-invalid'); + document.getElementById('export_file_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } else if (action === 'delete') { const delete_confirm = document.getElementById('delete_select'); @@ -86,17 +100,21 @@ e.stopPropagation(); document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none'); delete_confirm.classList.add('is-invalid'); - delete_confirm.addEventListener('change', e => { - document.getElementById('delete_select')?.classList.remove('is-invalid'); - document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); - }, { once : true }); + delete_confirm.addEventListener( + 'change', + (e) => { + document.getElementById('delete_select')?.classList.remove('is-invalid'); + document.getElementById('delete_confirm_err_msg')?.classList.add('d-none'); + }, + { once: true } + ); } } }); // Remove select error message when changing tabs. for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) { - tab.addEventListener('shown.bs.tab', e => { + tab.addEventListener('shown.bs.tab', (e) => { document.getElementById('select_user_err_msg')?.classList.add('d-none'); }); }