Merge redundant toggle handling code (#693)
This commit is contained in:
parent
fca0004597
commit
104650627d
@ -61,13 +61,12 @@ async function setupOptions() {
|
|||||||
};
|
};
|
||||||
const options = await api.optionsGet(optionsContext);
|
const options = await api.optionsGet(optionsContext);
|
||||||
|
|
||||||
const toggle = document.querySelector('#enable-search');
|
const extensionEnabled = options.general.enable;
|
||||||
toggle.checked = options.general.enable;
|
const onToggleChanged = () => api.commandExec('toggle');
|
||||||
toggle.addEventListener('change', () => api.commandExec('toggle'), false);
|
for (const toggle of document.querySelectorAll('#enable-search,#enable-search2')) {
|
||||||
|
toggle.checked = extensionEnabled;
|
||||||
const toggle2 = document.querySelector('#enable-search2');
|
toggle.addEventListener('change', onToggleChanged, false);
|
||||||
toggle2.checked = options.general.enable;
|
}
|
||||||
toggle2.addEventListener('change', () => api.commandExec('toggle'), false);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.body.dataset.loaded = 'true';
|
document.body.dataset.loaded = 'true';
|
||||||
|
Loading…
Reference in New Issue
Block a user