Move event handler function bodies
This commit is contained in:
parent
81fbe60da9
commit
0c1b250b4f
@ -69,18 +69,7 @@ class DisplaySearch extends Display {
|
||||
} else {
|
||||
this.wanakanaEnable.checked = false;
|
||||
}
|
||||
this.wanakanaEnable.addEventListener('change', (e) => {
|
||||
const {queryParams: {query: query2=''}} = parseUrl(window.location.href);
|
||||
if (e.target.checked) {
|
||||
window.wanakana.bind(this.query);
|
||||
apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext());
|
||||
} else {
|
||||
window.wanakana.unbind(this.query);
|
||||
apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext());
|
||||
}
|
||||
this.setQuery(query2);
|
||||
this.onSearchQueryUpdated(this.query.value, false);
|
||||
});
|
||||
this.wanakanaEnable.addEventListener('change', (e) => this.onWanakanaEnableChange(e));
|
||||
}
|
||||
|
||||
this.setQuery(query);
|
||||
@ -93,24 +82,7 @@ class DisplaySearch extends Display {
|
||||
} else {
|
||||
this.clipboardMonitorEnable.checked = false;
|
||||
}
|
||||
this.clipboardMonitorEnable.addEventListener('change', (e) => {
|
||||
if (e.target.checked) {
|
||||
chrome.permissions.request(
|
||||
{permissions: ['clipboardRead']},
|
||||
(granted) => {
|
||||
if (granted) {
|
||||
this.clipboardMonitor.start();
|
||||
apiOptionsSet({general: {enableClipboardMonitor: true}}, this.getOptionsContext());
|
||||
} else {
|
||||
e.target.checked = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.clipboardMonitor.stop();
|
||||
apiOptionsSet({general: {enableClipboardMonitor: false}}, this.getOptionsContext());
|
||||
}
|
||||
});
|
||||
this.clipboardMonitorEnable.addEventListener('change', (e) => this.onClipboardMonitorEnableChange(e));
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
|
||||
@ -253,6 +225,38 @@ class DisplaySearch extends Display {
|
||||
}
|
||||
}
|
||||
|
||||
onWanakanaEnableChange(e) {
|
||||
const {queryParams: {query=''}} = parseUrl(window.location.href);
|
||||
const enableWanakana = e.target.checked;
|
||||
if (enableWanakana) {
|
||||
window.wanakana.bind(this.query);
|
||||
} else {
|
||||
window.wanakana.unbind(this.query);
|
||||
}
|
||||
this.setQuery(query);
|
||||
this.onSearchQueryUpdated(this.query.value, false);
|
||||
apiOptionsSet({general: {enableWanakana}}, this.getOptionsContext());
|
||||
}
|
||||
|
||||
onClipboardMonitorEnableChange(e) {
|
||||
if (e.target.checked) {
|
||||
chrome.permissions.request(
|
||||
{permissions: ['clipboardRead']},
|
||||
(granted) => {
|
||||
if (granted) {
|
||||
this.clipboardMonitor.start();
|
||||
apiOptionsSet({general: {enableClipboardMonitor: true}}, this.getOptionsContext());
|
||||
} else {
|
||||
e.target.checked = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.clipboardMonitor.stop();
|
||||
apiOptionsSet({general: {enableClipboardMonitor: false}}, this.getOptionsContext());
|
||||
}
|
||||
}
|
||||
|
||||
async updateOptions(options) {
|
||||
await super.updateOptions(options);
|
||||
this.queryParser.setOptions(this.options);
|
||||
|
Loading…
Reference in New Issue
Block a user