diff options
| author | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-09 21:47:11 +0200 | 
|---|---|---|
| committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-09 21:51:33 +0200 | 
| commit | 21bad6c6e380c9c0dbd03f82563a1570bf22963c (patch) | |
| tree | 08c853f680b2c87785343bf772bc5af40bc53d96 | |
| parent | 4e59c2d55684b5a0b1d9edc580dd4c43bfc46211 (diff) | |
simplify setQuery kana conversion
| -rw-r--r-- | ext/bg/js/search.js | 23 | 
1 files changed, 7 insertions, 16 deletions
| diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index feadefe4..1baee904 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -69,22 +69,17 @@ class DisplaySearch extends Display {                          const {query=''} = DisplaySearch.parseQueryStringFromLocation(window.location.href);                          if (e.target.checked) {                              window.wanakana.bind(this.query); -                            this.setQuery(window.wanakana.toKana(query));                              apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext());                          } else {                              window.wanakana.unbind(this.query); -                            this.setQuery(query);                              apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext());                          } +                        this.setQuery(query);                          this.onSearchQueryUpdated(this.query.value, false);                      });                  } -                if (this.isWanakanaEnabled()) { -                    this.setQuery(window.wanakana.toKana(query)); -                } else { -                    this.setQuery(query); -                } +                this.setQuery(query);                  this.onSearchQueryUpdated(this.query.value, false);              }              if (this.clipboardMonitorEnable !== null && mode !== 'popup') { @@ -164,12 +159,7 @@ class DisplaySearch extends Display {      onPopState() {          const {query='', mode=''} = DisplaySearch.parseQueryStringFromLocation(window.location.href);          document.documentElement.dataset.searchMode = mode; -        if (this.isWanakanaEnabled()) { -            this.setQuery(window.wanakana.toKana(query)); -        } else { -            this.setQuery(query); -        } - +        this.setQuery(query);          this.onSearchQueryUpdated(this.query.value, false);      } @@ -203,7 +193,7 @@ class DisplaySearch extends Display {      }      onClipboardText(text) { -        this.setQuery(this.isWanakanaEnabled() ? window.wanakana.toKana(text) : text); +        this.setQuery(text);          window.history.pushState(null, '', `${window.location.pathname}?query=${encodeURIComponent(text)}`);          this.onSearchQueryUpdated(this.query.value, true);      } @@ -256,8 +246,9 @@ class DisplaySearch extends Display {      }      setQuery(query) { -        this.query.value = query; -        this.queryParser.setText(query); +        const interpretedQuery = this.isWanakanaEnabled() ? window.wanakana.toKana(query) : query; +        this.query.value = interpretedQuery; +        this.queryParser.setText(interpretedQuery);      }      setIntroVisible(visible, animate) { |