|
79 | 79 |
|
80 | 80 | const countLine = document.getElementById('library_count_line'); |
81 | 81 |
|
| 82 | + const settingStoreID = `WW.${document.getElementsByName('hidden_course_id')[0]?.value ?? 'unknownCourse'}.${ |
| 83 | + document.getElementsByName('user')[0]?.value ?? 'unknownUser' |
| 84 | + }.setmaker`; |
| 85 | + const includeOPLInitialStatus = includeOPL?.checked; |
| 86 | + const includeContribInitialStatus = includeContrib?.checked; |
| 87 | + if (includeOPL) |
| 88 | + includeOPL.checked = localStorage.getItem(`${settingStoreID}.includeOPLChecked`) !== 'false' ? true : false; |
| 89 | + if (includeContrib) |
| 90 | + includeContrib.checked = |
| 91 | + localStorage.getItem(`${settingStoreID}.includeContribChecked`) !== 'false' ? true : false; |
| 92 | + |
82 | 93 | const lib_update = async (who, what) => { |
83 | 94 | const child = { subject: 'chapter', chapter: 'section', section: 'count' }; |
84 | 95 |
|
|
200 | 211 | libraryChapter?.addEventListener('change', () => lib_update('section', 'get')); |
201 | 212 | librarySubject?.addEventListener('change', () => lib_update('chapter', 'get')); |
202 | 213 | librarySection?.addEventListener('change', () => lib_update('count', 'clear')); |
203 | | - includeOPL?.addEventListener('change', () => lib_update('count', 'clear')); |
204 | | - includeContrib?.addEventListener('change', () => lib_update('count', 'clear')); |
| 214 | + includeOPL?.addEventListener('change', () => { |
| 215 | + localStorage.setItem(`${settingStoreID}.includeOPLChecked`, includeOPL.checked); |
| 216 | + lib_update('count', 'clear'); |
| 217 | + }); |
| 218 | + includeContrib?.addEventListener('change', () => { |
| 219 | + localStorage.setItem(`${settingStoreID}.includeContribChecked`, includeContrib.checked); |
| 220 | + lib_update('count', 'clear'); |
| 221 | + }); |
205 | 222 | levels.forEach((level) => level.addEventListener('change', () => lib_update('count', 'clear'))); |
206 | 223 | libraryKeywords?.addEventListener('change', () => lib_update('count', 'clear')); |
207 | 224 |
|
| 225 | + // If the local storage status of the checks are different than what they |
| 226 | + // were when the page loaded, then the count needs to be updated. |
| 227 | + if (includeOPL?.checked !== includeOPLInitialStatus || includeContrib?.checked !== includeContribInitialStatus) |
| 228 | + lib_update('count', 'clear'); |
| 229 | + |
208 | 230 | // Set up the advanced view selects to submit the form when changed. |
209 | 231 | const libraryBrowserForm = document.forms['library_browser_form']; |
210 | 232 | if (libraryBrowserForm) { |
|
0 commit comments