|
|
|
@ -1,45 +1,30 @@
|
|
|
|
|
// 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.Search = class Search extends app.View {
|
|
|
|
|
static initClass() {
|
|
|
|
|
SEARCH_PARAM = app.config.search_param;
|
|
|
|
|
|
|
|
|
|
this.el = "._search";
|
|
|
|
|
this.activeClass = "_search-active";
|
|
|
|
|
|
|
|
|
|
this.elements = {
|
|
|
|
|
app.views.Search = class Search extends app.View {
|
|
|
|
|
static SEARCH_PARAM = app.config.search_param;
|
|
|
|
|
|
|
|
|
|
static el = "._search";
|
|
|
|
|
static activeClass = "_search-active";
|
|
|
|
|
|
|
|
|
|
static elements = {
|
|
|
|
|
input: "._search-input",
|
|
|
|
|
resetLink: "._search-clear",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.events = {
|
|
|
|
|
static events = {
|
|
|
|
|
input: "onInput",
|
|
|
|
|
click: "onClick",
|
|
|
|
|
submit: "onSubmit",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.shortcuts = {
|
|
|
|
|
static shortcuts = {
|
|
|
|
|
typing: "focus",
|
|
|
|
|
altG: "google",
|
|
|
|
|
altS: "stackoverflow",
|
|
|
|
|
altD: "duckduckgo",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.routes = { after: "afterRoute" };
|
|
|
|
|
static routes = { after: "afterRoute" };
|
|
|
|
|
|
|
|
|
|
HASH_RGX = new RegExp(`^#${SEARCH_PARAM}=(.*)`);
|
|
|
|
|
}
|
|
|
|
|
static HASH_RGX = new RegExp(`^#${Search.SEARCH_PARAM}=(.*)`);
|
|
|
|
|
|
|
|
|
|
init() {
|
|
|
|
|
this.addSubview((this.scope = new app.views.SearchScope(this.el)));
|
|
|
|
@ -70,11 +55,7 @@
|
|
|
|
|
if (app.isMobile() || $.isAndroid() || $.isIOS()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
(document.activeElement != null
|
|
|
|
|
? document.activeElement.tagName
|
|
|
|
|
: undefined) === "INPUT"
|
|
|
|
|
) {
|
|
|
|
|
if (document.activeElement?.tagName === "INPUT") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (app.settings.get("noAutofocus")) {
|
|
|
|
@ -134,11 +115,7 @@
|
|
|
|
|
|
|
|
|
|
this.hasResults = null;
|
|
|
|
|
this.flags = { urlSearch: url, initialResults: true };
|
|
|
|
|
this.searcher.find(
|
|
|
|
|
this.scope.getScope().entries.all(),
|
|
|
|
|
"text",
|
|
|
|
|
this.value,
|
|
|
|
|
);
|
|
|
|
|
this.searcher.find(this.scope.getScope().entries.all(), "text", this.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchUrl() {
|
|
|
|
@ -217,11 +194,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
afterRoute(name, context) {
|
|
|
|
|
if (
|
|
|
|
|
(app.shortcuts.eventInProgress != null
|
|
|
|
|
? app.shortcuts.eventInProgress.name
|
|
|
|
|
: undefined) === "escape"
|
|
|
|
|
) {
|
|
|
|
|
if (app.shortcuts.eventInProgress?.name === "escape") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!context.init && app.router.isIndex()) {
|
|
|
|
@ -234,8 +207,8 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extractHashValue() {
|
|
|
|
|
let value;
|
|
|
|
|
if ((value = this.getHashValue()) != null) {
|
|
|
|
|
let value = this.getHashValue();
|
|
|
|
|
if (value != null) {
|
|
|
|
|
app.router.replaceHash();
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
@ -243,19 +216,7 @@
|
|
|
|
|
|
|
|
|
|
getHashValue() {
|
|
|
|
|
try {
|
|
|
|
|
return __guard__(
|
|
|
|
|
HASH_RGX.exec($.urlDecode(location.hash)),
|
|
|
|
|
(x) => x[1],
|
|
|
|
|
);
|
|
|
|
|
return Search.HASH_RGX.exec($.urlDecode(location.hash))?.[1];
|
|
|
|
|
} catch (error) {}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
app.views.Search.initClass();
|
|
|
|
|
return app.views.Search;
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
function __guard__(value, transform) {
|
|
|
|
|
return typeof value !== "undefined" && value !== null
|
|
|
|
|
? transform(value)
|
|
|
|
|
: undefined;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|