summaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-11 22:57:38 -0500
committerGitHub <noreply@github.com>2021-02-11 22:57:38 -0500
commit1c5e3e6d397f22de99494e147cc53b106e1d16b4 (patch)
tree4e700bb6d923617146ef9fa1a4efb305bb0c5995 /ext/mixed/js
parent94db6c69fa4aa25231e213c6d0e185197bfe3418 (diff)
Search decouple (#1369)
* Update how query post-processing is implemented * Update DisplaySearch to not subclass Display * Update display construction * Make display initialization consistent * Remove unused * Fix wanakana binding * Use own frame/tab ID * DisplaySearch => SearchDisplayController * Fix globals
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/display.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index c8b7b14b..2acc0d3f 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -117,6 +117,7 @@ class Display extends EventDispatcher {
this._displayAudio = new DisplayAudio(this);
this._ankiNoteNotification = null;
this._ankiNoteNotificationEventListeners = null;
+ this._queryPostProcessor = null;
this._hotkeyHandler.registerActions([
['close', () => { this._onHotkeyClose(); }],
@@ -405,8 +406,8 @@ class Display extends EventDispatcher {
return data.data;
}
- postProcessQuery(query) {
- return query;
+ setQueryPostProcessor(func) {
+ this._queryPostProcessor = func;
}
close() {
@@ -573,10 +574,10 @@ class Display extends EventDispatcher {
this._query = query;
clear = false;
const isTerms = (type === 'terms');
- query = this.postProcessQuery(query);
+ query = this._postProcessQuery(query);
this._rawQuery = query;
let queryFull = urlSearchParams.get('full');
- queryFull = (queryFull !== null ? this.postProcessQuery(queryFull) : query);
+ queryFull = (queryFull !== null ? this._postProcessQuery(queryFull) : query);
const wildcardsEnabled = (urlSearchParams.get('wildcards') !== 'off');
const lookup = (urlSearchParams.get('lookup') !== 'false');
await this._setContentTermsOrKanji(token, isTerms, query, queryFull, lookup, wildcardsEnabled, eventArgs);
@@ -1930,4 +1931,9 @@ class Display extends EventDispatcher {
}
return false;
}
+
+ _postProcessQuery(query) {
+ const queryPostProcessor = this._queryPostProcessor;
+ return typeof queryPostProcessor === 'function' ? queryPostProcessor(query) : query;
+ }
}