summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-26 19:04:21 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-26 19:04:21 -0500
commit0c1b250b4f72a0de6348b119a050d19c6e767113 (patch)
treea631769b66a8127dbad3ccfac4a52b44fae76367 /ext/bg
parent81fbe60da9c4cd7de27ef68c39805b96680bc24d (diff)
Move event handler function bodies
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/search.js64
1 files changed, 34 insertions, 30 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 98e167ad..59cb8636 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -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);