aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/search-query-parser.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/search-query-parser.js')
-rw-r--r--ext/bg/js/search-query-parser.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 06316ce2..6e18073b 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -28,11 +28,10 @@
class QueryParser extends TextScanner {
constructor(search) {
- super(document.querySelector('#query-parser-content'), [], [], []);
+ super(document.querySelector('#query-parser-content'), [], []);
this.search = search;
this.parseResults = [];
- this.selectedParser = null;
this.queryParser = document.querySelector('#query-parser-content');
this.queryParserSelect = document.querySelector('#query-parser-select-container');
@@ -79,9 +78,7 @@ class QueryParser extends TextScanner {
onParserChange(e) {
const selectedParser = e.target.value;
- this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
- this.renderParseResult();
}
getMouseEventListeners() {
@@ -112,19 +109,16 @@ class QueryParser extends TextScanner {
refreshSelectedParser() {
if (this.parseResults.length > 0) {
- if (this.selectedParser === null) {
- this.selectedParser = this.search.options.parsing.selectedParser;
- }
- if (this.selectedParser === null || !this.getParseResult()) {
+ if (!this.getParseResult()) {
const selectedParser = this.parseResults[0].id;
- this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
}
}
}
getParseResult() {
- return this.parseResults.find((r) => r.id === this.selectedParser);
+ const {selectedParser} = this.options.parsing;
+ return this.parseResults.find((r) => r.id === selectedParser);
}
async setText(text) {
@@ -176,7 +170,8 @@ class QueryParser extends TextScanner {
renderParserSelect() {
this.queryParserSelect.textContent = '';
if (this.parseResults.length > 1) {
- const select = this.queryParserGenerator.createParserSelect(this.parseResults, this.selectedParser);
+ const {selectedParser} = this.options.parsing;
+ const select = this.queryParserGenerator.createParserSelect(this.parseResults, selectedParser);
select.addEventListener('change', this.onParserChange.bind(this));
this.queryParserSelect.appendChild(select);
}