Remove display query post process (#1967)
* Remove search query post-processing * Remove _rawQuery, as it is redundant with _query
This commit is contained in:
parent
ba267a545c
commit
729abbf561
@ -72,7 +72,6 @@ class Display extends EventDispatcher {
|
|||||||
this._defaultTitle = document.title;
|
this._defaultTitle = document.title;
|
||||||
this._titleMaxLength = 1000;
|
this._titleMaxLength = 1000;
|
||||||
this._query = '';
|
this._query = '';
|
||||||
this._rawQuery = '';
|
|
||||||
this._fullQuery = '';
|
this._fullQuery = '';
|
||||||
this._documentUtil = new DocumentUtil();
|
this._documentUtil = new DocumentUtil();
|
||||||
this._progressIndicator = document.querySelector('#progress-indicator');
|
this._progressIndicator = document.querySelector('#progress-indicator');
|
||||||
@ -107,7 +106,6 @@ class Display extends EventDispatcher {
|
|||||||
this._tagNotification = null;
|
this._tagNotification = null;
|
||||||
this._footerNotificationContainer = document.querySelector('#content-footer');
|
this._footerNotificationContainer = document.querySelector('#content-footer');
|
||||||
this._displayAudio = new DisplayAudio(this);
|
this._displayAudio = new DisplayAudio(this);
|
||||||
this._queryPostProcessor = null;
|
|
||||||
this._optionToggleHotkeyHandler = new OptionToggleHotkeyHandler(this);
|
this._optionToggleHotkeyHandler = new OptionToggleHotkeyHandler(this);
|
||||||
this._elementOverflowController = new ElementOverflowController();
|
this._elementOverflowController = new ElementOverflowController();
|
||||||
this._displayAnki = new DisplayAnki(this, japaneseUtil);
|
this._displayAnki = new DisplayAnki(this, japaneseUtil);
|
||||||
@ -401,10 +399,6 @@ class Display extends EventDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setQueryPostProcessor(func) {
|
|
||||||
this._queryPostProcessor = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
switch (this._pageType) {
|
switch (this._pageType) {
|
||||||
case 'popup':
|
case 'popup':
|
||||||
@ -423,7 +417,7 @@ class Display extends EventDispatcher {
|
|||||||
searchLast() {
|
searchLast() {
|
||||||
const type = this._contentType;
|
const type = this._contentType;
|
||||||
if (type === 'clear') { return; }
|
if (type === 'clear') { return; }
|
||||||
const query = this._rawQuery;
|
const query = this._query;
|
||||||
const state = (
|
const state = (
|
||||||
this._historyHasState() ?
|
this._historyHasState() ?
|
||||||
clone(this._history.state) :
|
clone(this._history.state) :
|
||||||
@ -589,7 +583,6 @@ class Display extends EventDispatcher {
|
|||||||
this._historyHasChanged = true;
|
this._historyHasChanged = true;
|
||||||
this._contentType = type;
|
this._contentType = type;
|
||||||
this._query = '';
|
this._query = '';
|
||||||
this._rawQuery = '';
|
|
||||||
const eventArgs = {type, urlSearchParams, token};
|
const eventArgs = {type, urlSearchParams, token};
|
||||||
|
|
||||||
// Set content
|
// Set content
|
||||||
@ -597,16 +590,14 @@ class Display extends EventDispatcher {
|
|||||||
case 'terms':
|
case 'terms':
|
||||||
case 'kanji':
|
case 'kanji':
|
||||||
{
|
{
|
||||||
let query = urlSearchParams.get('query');
|
const query = urlSearchParams.get('query');
|
||||||
if (query === null) { break; }
|
if (query === null) { break; }
|
||||||
|
|
||||||
this._query = query;
|
this._query = query;
|
||||||
clear = false;
|
clear = false;
|
||||||
const isTerms = (type === 'terms');
|
const isTerms = (type === 'terms');
|
||||||
query = this._postProcessQuery(query);
|
|
||||||
this._rawQuery = query;
|
|
||||||
let queryFull = urlSearchParams.get('full');
|
let queryFull = urlSearchParams.get('full');
|
||||||
queryFull = (queryFull !== null ? this._postProcessQuery(queryFull) : query);
|
queryFull = (queryFull !== null ? queryFull : query);
|
||||||
const wildcardsEnabled = (urlSearchParams.get('wildcards') !== 'off');
|
const wildcardsEnabled = (urlSearchParams.get('wildcards') !== 'off');
|
||||||
const lookup = (urlSearchParams.get('lookup') !== 'false');
|
const lookup = (urlSearchParams.get('lookup') !== 'false');
|
||||||
await this._setContentTermsOrKanji(token, isTerms, query, queryFull, lookup, wildcardsEnabled, eventArgs);
|
await this._setContentTermsOrKanji(token, isTerms, query, queryFull, lookup, wildcardsEnabled, eventArgs);
|
||||||
@ -1539,11 +1530,6 @@ class Display extends EventDispatcher {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_postProcessQuery(query) {
|
|
||||||
const queryPostProcessor = this._queryPostProcessor;
|
|
||||||
return typeof queryPostProcessor === 'function' ? queryPostProcessor(query) : query;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _logDictionaryEntryData(index) {
|
async _logDictionaryEntryData(index) {
|
||||||
if (index < 0 || index >= this._dictionaryEntries.length) { return; }
|
if (index < 0 || index >= this._dictionaryEntries.length) { return; }
|
||||||
const dictionaryEntry = this._dictionaryEntries[index];
|
const dictionaryEntry = this._dictionaryEntries[index];
|
||||||
|
@ -72,7 +72,6 @@ class SearchDisplayController {
|
|||||||
this._display.autoPlayAudioDelay = 0;
|
this._display.autoPlayAudioDelay = 0;
|
||||||
this._display.queryParserVisible = true;
|
this._display.queryParserVisible = true;
|
||||||
this._display.setHistorySettings({useBrowserHistory: true});
|
this._display.setHistorySettings({useBrowserHistory: true});
|
||||||
this._display.setQueryPostProcessor(this._postProcessQuery.bind(this));
|
|
||||||
|
|
||||||
this._searchButton.addEventListener('click', this._onSearch.bind(this), false);
|
this._searchButton.addEventListener('click', this._onSearch.bind(this), false);
|
||||||
this._wanakanaEnableCheckbox.addEventListener('change', this._onWanakanaEnableChange.bind(this));
|
this._wanakanaEnableCheckbox.addEventListener('change', this._onWanakanaEnableChange.bind(this));
|
||||||
@ -409,17 +408,6 @@ class SearchDisplayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_postProcessQuery(query) {
|
|
||||||
if (this._wanakanaEnabled) {
|
|
||||||
try {
|
|
||||||
query = this._japaneseUtil.convertToKana(query);
|
|
||||||
} catch (e) {
|
|
||||||
// NOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
_registerMessageHandlers(handlers) {
|
_registerMessageHandlers(handlers) {
|
||||||
for (const [name, handlerInfo] of handlers) {
|
for (const [name, handlerInfo] of handlers) {
|
||||||
this._messageHandlers.set(name, handlerInfo);
|
this._messageHandlers.set(name, handlerInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user