summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/search.js58
-rw-r--r--ext/bg/search.html2
2 files changed, 18 insertions, 42 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index fc857368..d95fd5e4 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -63,11 +63,14 @@ class DisplaySearch extends Display {
this.on('contentUpdating', this._onContentUpdating.bind(this));
+ this.queryParserVisible = true;
this.setHistorySettings({useBrowserHistory: true});
const options = this.getOptions();
- const {queryParams: {query='', mode=''}} = parseUrl(window.location.href);
+ const urlSearchParams = new URLSearchParams(location.search);
+ let mode = urlSearchParams.get('mode');
+ if (mode === null) { mode = ''; }
document.documentElement.dataset.searchMode = mode;
@@ -78,8 +81,6 @@ class DisplaySearch extends Display {
this._wanakanaEnable.checked = false;
}
- this._setQuery(query);
-
if (mode !== 'popup') {
if (options.general.enableClipboardMonitor === true) {
this._clipboardMonitorEnable.checked = true;
@@ -147,14 +148,24 @@ class DisplaySearch extends Display {
if (!this._isPrepared) { return; }
const query = this._query.value;
if (query) {
- this._setQuery(query);
this._onSearchQueryUpdated(query, false);
}
}
+ postProcessQuery(query) {
+ if (this._isWanakanaEnabled()) {
+ try {
+ query = wanakana.toKana(query);
+ } catch (e) {
+ // NOP
+ }
+ }
+ return query;
+ }
+
// Private
- _onContentUpdating({type, source, content, urlSearchParams}) {
+ _onContentUpdating({type, content, source}) {
let animate = false;
let valid = false;
switch (type) {
@@ -173,13 +184,8 @@ class DisplaySearch extends Display {
if (typeof source !== 'string') { source = ''; }
- let full = urlSearchParams.get('full');
- if (full === null) { full = source; }
-
- this._closePopups();
- this._setQuery(full);
+ this._query.value = source;
this._setIntroVisible(!valid, animate);
- this._setTitleText(source);
this._updateSearchButton();
}
@@ -289,19 +295,6 @@ class DisplaySearch extends Display {
return this._wanakanaEnable !== null && this._wanakanaEnable.checked;
}
- _setQuery(query) {
- let interpretedQuery = query;
- if (this._isWanakanaEnabled()) {
- try {
- interpretedQuery = wanakana.toKana(query);
- } catch (e) {
- // NOP
- }
- }
- this._query.value = interpretedQuery;
- this.setQueryParserText(interpretedQuery);
- }
-
_setIntroVisible(visible, animate) {
if (this._introVisible === visible) {
return;
@@ -362,19 +355,6 @@ class DisplaySearch extends Display {
this._search.disabled = this._introVisible && (this._query === null || this._query.value.length === 0);
}
- _setTitleText(text) {
- // Chrome limits title to 1024 characters
- if (text.length > 1000) {
- text = text.substring(0, 1000) + '...';
- }
-
- if (text.length === 0) {
- document.title = 'Yomichan Search';
- } else {
- document.title = `${text} - Yomichan Search`;
- }
- }
-
async _prepareNestedPopups() {
let complete = false;
@@ -401,8 +381,4 @@ class DisplaySearch extends Display {
await onOptionsUpdated();
}
-
- _closePopups() {
- yomichan.trigger('closePopups');
- }
}
diff --git a/ext/bg/search.html b/ext/bg/search.html
index 653a708f..eb85e368 100644
--- a/ext/bg/search.html
+++ b/ext/bg/search.html
@@ -46,7 +46,7 @@
<div id="spinner" hidden><img src="/mixed/img/spinner.gif"></div>
- <div class="scan-disable">
+ <div class="scan-disable" id="query-parser-container">
<div id="query-parser-select-container" class="input-group"></div>
<div id="query-parser-content"></div>
</div>