From 1c5e3e6d397f22de99494e147cc53b106e1d16b4 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 11 Feb 2021 22:57:38 -0500 Subject: 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 --- ext/mixed/js/display.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ext/mixed/js') 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; + } } -- cgit v1.2.3