diff options
Diffstat (limited to 'ext/bg/js')
| -rw-r--r-- | ext/bg/js/search-frontend.js | 7 | ||||
| -rw-r--r-- | ext/bg/js/search-query-parser.js | 17 | ||||
| -rw-r--r-- | ext/bg/js/search.js | 16 | 
3 files changed, 14 insertions, 26 deletions
| diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index a470e873..2d2aa8d4 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -30,12 +30,7 @@ async function searchFrontendSetup() {      const options = await apiOptionsGet(optionsContext);      if (!options.scanning.enableOnSearchPage) { return; } -    const ignoreNodes = ['.scan-disable', '.scan-disable *']; -    if (!options.scanning.enableOnPopupExpressions) { -        ignoreNodes.push('.source-text', '.source-text *'); -    } - -    window.frontendInitializationData = {depth: 1, ignoreNodes, proxy: false}; +    window.frontendInitializationData = {depth: 1, proxy: false};      const scriptSrcs = [          '/mixed/js/text-scanner.js', 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);          } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index e2bdff73..8b8ee55e 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -247,15 +247,12 @@ class DisplaySearch extends Display {      }      onWanakanaEnableChange(e) { -        const {queryParams: {query=''}} = parseUrl(window.location.href);          const enableWanakana = e.target.checked;          if (enableWanakana) {              window.wanakana.bind(this.query);          } else {              window.wanakana.unbind(this.query);          } -        this.setQuery(query); -        this.onSearchQueryUpdated(this.query.value, false);          apiOptionsSet({general: {enableWanakana}}, this.getOptionsContext());      } @@ -278,19 +275,20 @@ class DisplaySearch extends Display {          }      } -    async updateOptions(options) { -        await super.updateOptions(options); +    async updateOptions() { +        await super.updateOptions();          this.queryParser.setOptions(this.options); +        const query = this.query.value; +        if (query) { +            this.setQuery(query); +            this.onSearchQueryUpdated(query, false); +        }      }      isWanakanaEnabled() {          return this.wanakanaEnable !== null && this.wanakanaEnable.checked;      } -    getOptionsContext() { -        return this.optionsContext; -    } -      setQuery(query) {          const interpretedQuery = this.isWanakanaEnabled() ? window.wanakana.toKana(query) : query;          this.query.value = interpretedQuery; |