Merge redundant toggle handling code (#693)

This commit is contained in:
toasted-nutbread 2020-07-26 16:53:24 -04:00 committed by GitHub
parent fca0004597
commit 104650627d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,13 +61,12 @@ async function setupOptions() {
};
const options = await api.optionsGet(optionsContext);
const toggle = document.querySelector('#enable-search');
toggle.checked = options.general.enable;
toggle.addEventListener('change', () => api.commandExec('toggle'), false);
const toggle2 = document.querySelector('#enable-search2');
toggle2.checked = options.general.enable;
toggle2.addEventListener('change', () => api.commandExec('toggle'), false);
const extensionEnabled = options.general.enable;
const onToggleChanged = () => api.commandExec('toggle');
for (const toggle of document.querySelectorAll('#enable-search,#enable-search2')) {
toggle.checked = extensionEnabled;
toggle.addEventListener('change', onToggleChanged, false);
}
setTimeout(() => {
document.body.dataset.loaded = 'true';