|
|
|
@ -1,35 +1,20 @@
|
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
|
|
|
|
/*
|
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
|
|
|
|
|
* DS206: Consider reworking classes to avoid initClass
|
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
|
|
|
*/
|
|
|
|
|
(function () {
|
|
|
|
|
let SEARCH_PARAM = undefined;
|
|
|
|
|
let HASH_RGX = undefined;
|
|
|
|
|
app.views.SearchScope = class SearchScope extends app.View {
|
|
|
|
|
static initClass() {
|
|
|
|
|
SEARCH_PARAM = app.config.search_param;
|
|
|
|
|
|
|
|
|
|
this.elements = {
|
|
|
|
|
app.views.SearchScope = class SearchScope extends app.View {
|
|
|
|
|
static SEARCH_PARAM = app.config.search_param;
|
|
|
|
|
|
|
|
|
|
static elements = {
|
|
|
|
|
input: "._search-input",
|
|
|
|
|
tag: "._search-tag",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.events = {
|
|
|
|
|
static events = {
|
|
|
|
|
click: "onClick",
|
|
|
|
|
keydown: "onKeydown",
|
|
|
|
|
textInput: "onTextInput",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.routes = { after: "afterRoute" };
|
|
|
|
|
static routes = { after: "afterRoute" };
|
|
|
|
|
|
|
|
|
|
HASH_RGX = new RegExp(`^#${SEARCH_PARAM}=(.+?) .`);
|
|
|
|
|
}
|
|
|
|
|
static HASH_RGX = new RegExp(`^#${SearchScope.SEARCH_PARAM}=(.+?) .`);
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
this.placeholder = this.input.getAttribute("placeholder");
|
|
|
|
@ -173,8 +158,8 @@
|
|
|
|
|
let value;
|
|
|
|
|
if ((value = this.getHashValue())) {
|
|
|
|
|
const newHash = $.urlDecode(location.hash).replace(
|
|
|
|
|
`#${SEARCH_PARAM}=${value} `,
|
|
|
|
|
`#${SEARCH_PARAM}=`,
|
|
|
|
|
`#${SearchScope.SEARCH_PARAM}=${value} `,
|
|
|
|
|
`#${SearchScope.SEARCH_PARAM}=`,
|
|
|
|
|
);
|
|
|
|
|
app.router.replaceHash(newHash);
|
|
|
|
|
return value;
|
|
|
|
@ -183,10 +168,7 @@
|
|
|
|
|
|
|
|
|
|
getHashValue() {
|
|
|
|
|
try {
|
|
|
|
|
return __guard__(
|
|
|
|
|
HASH_RGX.exec($.urlDecode(location.hash)),
|
|
|
|
|
(x) => x[1],
|
|
|
|
|
);
|
|
|
|
|
return SearchScope.HASH_RGX.exec($.urlDecode(location.hash))?.[1];
|
|
|
|
|
} catch (error) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -195,13 +177,4 @@
|
|
|
|
|
this.selectDoc(context.doc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
app.views.SearchScope.initClass();
|
|
|
|
|
return app.views.SearchScope;
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
function __guard__(value, transform) {
|
|
|
|
|
return typeof value !== "undefined" && value !== null
|
|
|
|
|
? transform(value)
|
|
|
|
|
: undefined;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|