diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-26 19:08:35 -0500 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-26 19:08:35 -0500 | 
| commit | 007789ffa07149daeeb857ae3587aa4a0da85c40 (patch) | |
| tree | bbbd7e8e7f4f134dbb586fd869d0b03ae70073e8 | |
| parent | 0c1b250b4f72a0de6348b119a050d19c6e767113 (diff) | |
Organize, remove unnecessary null checks
| -rw-r--r-- | ext/bg/js/search.js | 33 | 
1 files changed, 14 insertions, 19 deletions
| diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 59cb8636..209a5feb 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -55,27 +55,19 @@ class DisplaySearch extends Display {              const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); -            if (this.search !== null) { -                this.search.addEventListener('click', (e) => this.onSearch(e), false); -            } -            if (this.query !== null) { -                document.documentElement.dataset.searchMode = mode; -                this.query.addEventListener('input', () => this.onSearchInput(), false); - -                if (this.wanakanaEnable !== null) { -                    if (this.options.general.enableWanakana === true) { -                        this.wanakanaEnable.checked = true; -                        window.wanakana.bind(this.query); -                    } else { -                        this.wanakanaEnable.checked = false; -                    } -                    this.wanakanaEnable.addEventListener('change', (e) => this.onWanakanaEnableChange(e)); -                } +            document.documentElement.dataset.searchMode = mode; -                this.setQuery(query); -                this.onSearchQueryUpdated(this.query.value, false); +            if (this.options.general.enableWanakana === true) { +                this.wanakanaEnable.checked = true; +                window.wanakana.bind(this.query); +            } else { +                this.wanakanaEnable.checked = false;              } -            if (this.clipboardMonitorEnable !== null && mode !== 'popup') { + +            this.setQuery(query); +            this.onSearchQueryUpdated(this.query.value, false); + +            if (mode !== 'popup') {                  if (this.options.general.enableClipboardMonitor === true) {                      this.clipboardMonitorEnable.checked = true;                      this.clipboardMonitor.start(); @@ -87,6 +79,9 @@ class DisplaySearch extends Display {              chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); +            this.search.addEventListener('click', (e) => this.onSearch(e), false); +            this.query.addEventListener('input', () => this.onSearchInput(), false); +            this.wanakanaEnable.addEventListener('change', (e) => this.onWanakanaEnableChange(e));              window.addEventListener('popstate', (e) => this.onPopState(e));              window.addEventListener('copy', (e) => this.onCopy(e)); |