summaryrefslogtreecommitdiff
path: root/ext/bg/js/query-parser.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-08 12:35:32 -0500
committerGitHub <noreply@github.com>2020-11-08 12:35:32 -0500
commit12e6e377854a9163b322a16f3effe816d0222c67 (patch)
tree79783eeaa2503461608e6cb5f905f3c2fe90678b /ext/bg/js/query-parser.js
parent8cf10d685d52d5ae75d65c4aea4adcb6d101e9a4 (diff)
Query parser generator refactor (#1006)
* Simplify select generation * Refactor text generation * Change optional argument * Remove query-parser-templates.html * Simplify prepare * Simplify preview
Diffstat (limited to 'ext/bg/js/query-parser.js')
-rw-r--r--ext/bg/js/query-parser.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/ext/bg/js/query-parser.js b/ext/bg/js/query-parser.js
index dc3cc581..8f17a5c1 100644
--- a/ext/bg/js/query-parser.js
+++ b/ext/bg/js/query-parser.js
@@ -44,8 +44,7 @@ class QueryParser extends EventDispatcher {
});
}
- async prepare() {
- await this._queryParserGenerator.prepare();
+ prepare() {
this._textScanner.prepare();
this._textScanner.on('searched', this._onSearched.bind(this));
}
@@ -125,13 +124,9 @@ class QueryParser extends EventDispatcher {
}
_setPreview(text) {
- const previewTerms = [];
- for (let i = 0, ii = text.length; i < ii; i += 2) {
- const tempText = text.substring(i, i + 2);
- previewTerms.push([{text: tempText, reading: ''}]);
- }
+ const terms = [[{text, reading: ''}]];
this._queryParser.textContent = '';
- this._queryParser.appendChild(this._queryParserGenerator.createParseResult(previewTerms, true));
+ this._queryParser.appendChild(this._queryParserGenerator.createParseResult(terms, true));
}
_renderParserSelect() {
@@ -148,6 +143,6 @@ class QueryParser extends EventDispatcher {
const parseResult = this._getParseResult();
this._queryParser.textContent = '';
if (!parseResult) { return; }
- this._queryParser.appendChild(this._queryParserGenerator.createParseResult(parseResult.content));
+ this._queryParser.appendChild(this._queryParserGenerator.createParseResult(parseResult.content, false));
}
}