diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-03 12:02:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 12:02:21 -0400 |
commit | e36bc8771fd0b79a43cd809041002879f862487d (patch) | |
tree | f817984be2b95c71975892cc1c58a5c9c3b9d0fd /ext/bg/js | |
parent | 6ede83f2934195cb1dc5f261834b7c1bca8bfa90 (diff) |
Display refactor (#643)
* Remove statics
* Move orphan detection and error handling to Display
* Add clearContent function
* Add/use public get/set functions for optionsContext
* Add public getOptions
* Move interactive assignment
* Mark fields as private
* Mark functions as private
* Change stray getter into a function
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/search.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index e968e8cf..e9ec2b85 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -33,10 +33,10 @@ class DisplaySearch extends Display { this._isPrepared = false; - this.optionsContext = { + this.setOptionsContext({ depth: 0, url: window.location.href - }; + }); this.queryParser = new QueryParser({ getOptionsContext: this.getOptionsContext.bind(this), @@ -80,12 +80,13 @@ class DisplaySearch extends Display { await this.updateOptions(); yomichan.on('optionsUpdated', () => this.updateOptions()); await this.queryParser.prepare(); + const options = this.getOptions(); const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); document.documentElement.dataset.searchMode = mode; - if (this.options.general.enableWanakana === true) { + if (options.general.enableWanakana === true) { this.wanakanaEnable.checked = true; wanakana.bind(this.query); } else { @@ -96,7 +97,7 @@ class DisplaySearch extends Display { this.onSearchQueryUpdated(this.query.value, false); if (mode !== 'popup') { - if (this.options.general.enableClipboardMonitor === true) { + if (options.general.enableClipboardMonitor === true) { this.clipboardMonitorEnable.checked = true; this.clipboardMonitor.start(); } else { @@ -121,10 +122,6 @@ class DisplaySearch extends Display { this._isPrepared = true; } - onError(error) { - yomichan.logError(error); - } - onEscape() { if (this.query === null) { return; @@ -241,7 +238,7 @@ class DisplaySearch extends Display { url: window.location.href }}); } else { - this.container.textContent = ''; + this.clearContent(); } this.setTitleText(query); window.parent.postMessage('popupClose', '*'); @@ -299,7 +296,8 @@ class DisplaySearch extends Display { async updateOptions() { await super.updateOptions(); - this.queryParser.setOptions(this.options); + const options = this.getOptions(); + this.queryParser.setOptions(options); if (!this._isPrepared) { return; } const query = this.query.value; if (query) { |