aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/query-parser.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-01 10:00:59 -0500
committerGitHub <noreply@github.com>2024-02-01 15:00:59 +0000
commitdfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch)
tree04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/display/query-parser.js
parent2356223942a21d1683ac38eed8e7b9485f453d87 (diff)
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code
Diffstat (limited to 'ext/js/display/query-parser.js')
-rw-r--r--ext/js/display/query-parser.js10
1 files changed, 6 insertions, 4 deletions
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<import('query-parser').Events>
@@ -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');
}
/**