From dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 1 Feb 2024 10:00:59 -0500 Subject: Application refactor (#591) * Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code --- ext/js/display/query-parser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ext/js/display/query-parser.js') diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js index 178bb110..daa298d2 100644 --- a/ext/js/display/query-parser.js +++ b/ext/js/display/query-parser.js @@ -21,7 +21,6 @@ import {log} from '../core/logger.js'; import {querySelectorNotNull} from '../dom/query-selector.js'; import {convertHiraganaToKatakana, convertKatakanaToHiragana, isStringEntirelyKana} from '../language/japanese.js'; import {TextScanner} from '../language/text-scanner.js'; -import {yomitan} from '../yomitan.js'; /** * @augments EventDispatcher @@ -30,8 +29,10 @@ export class QueryParser extends EventDispatcher { /** * @param {import('display').QueryParserConstructorDetails} details */ - constructor({getSearchContext, textSourceGenerator}) { + constructor({api, getSearchContext, textSourceGenerator}) { super(); + /** @type {import('../comm/api.js').API} */ + this._api = api; /** @type {import('display').GetSearchContextCallback} */ this._getSearchContext = getSearchContext; /** @type {string} */ @@ -58,6 +59,7 @@ export class QueryParser extends EventDispatcher { this._queryParserModeSelect = querySelectorNotNull(document, '#query-parser-mode-select'); /** @type {TextScanner} */ this._textScanner = new TextScanner({ + api, node: this._queryParser, getSearchContext, searchTerms: true, @@ -128,7 +130,7 @@ export class QueryParser extends EventDispatcher { /** @type {?import('core').TokenObject} */ const token = {}; this._setTextToken = token; - this._parseResults = await yomitan.api.parseText(text, this._getOptionsContext(), this._scanLength, this._useInternalParser, this._useMecabParser); + this._parseResults = await this._api.parseText(text, this._getOptionsContext(), this._scanLength, this._useInternalParser, this._useMecabParser); if (this._setTextToken !== token) { return; } this._refreshSelectedParser(); @@ -214,7 +216,7 @@ export class QueryParser extends EventDispatcher { scope: 'profile', optionsContext }; - yomitan.api.modifySettings([modification], 'search'); + this._api.modifySettings([modification], 'search'); } /** -- cgit v1.2.3