aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/query-parser.js29
1 files changed, 12 insertions, 17 deletions
diff --git a/ext/bg/js/query-parser.js b/ext/bg/js/query-parser.js
index b0ef2d78..a2a04606 100644
--- a/ext/bg/js/query-parser.js
+++ b/ext/bg/js/query-parser.js
@@ -36,15 +36,18 @@ class QueryParser extends EventDispatcher {
node: this._queryParser,
ignoreElements: () => [],
ignorePoint: null,
- search: this._search.bind(this),
- documentUtil
+ getOptionsContext,
+ documentUtil,
+ searchTerms: true,
+ searchKanji: false,
+ searchOnClick: true
});
}
async prepare() {
await this._queryParserGenerator.prepare();
this._textScanner.prepare();
- this._queryParser.addEventListener('click', this._onClick.bind(this));
+ this._textScanner.on('searched', this._onSearched.bind(this));
}
setOptions({selectedParser, termSpacing, scanning}) {
@@ -76,18 +79,12 @@ class QueryParser extends EventDispatcher {
// Private
- _onClick(e) {
- this._textScanner.searchAt(e.clientX, e.clientY, 'click');
- }
-
- async _search(textSource, cause) {
- if (textSource === null) { return null; }
-
- const optionsContext = this._getOptionsContext();
- const results = await this._textScanner.findTerms(textSource, optionsContext);
- if (results === null) { return null; }
-
- const {definitions, sentence, type} = results;
+ _onSearched({type, definitions, sentence, cause, textSource, optionsContext, error}) {
+ if (error !== null) {
+ yomichan.logError(error);
+ return;
+ }
+ if (type === null) { return; }
this.trigger('searched', {
type,
@@ -97,8 +94,6 @@ class QueryParser extends EventDispatcher {
textSource,
optionsContext
});
-
- return {definitions, type};
}
_onParserChange(e) {