|
|
|
@ -1,21 +1,5 @@
|
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
|
|
|
|
/*
|
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
|
* DS101: Remove unnecessary use of Array.from
|
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
|
|
|
|
|
* DS104: Avoid inline assignments
|
|
|
|
|
* 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 PREFERENCE_KEYS = undefined;
|
|
|
|
|
let INTERNAL_KEYS = undefined;
|
|
|
|
|
app.Settings = class Settings {
|
|
|
|
|
static initClass() {
|
|
|
|
|
PREFERENCE_KEYS = [
|
|
|
|
|
app.Settings = class Settings {
|
|
|
|
|
static PREFERENCE_KEYS = [
|
|
|
|
|
"hideDisabled",
|
|
|
|
|
"hideIntro",
|
|
|
|
|
"manualUpdate",
|
|
|
|
@ -34,16 +18,16 @@
|
|
|
|
|
"spaceTimeout",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
INTERNAL_KEYS = ["count", "schema", "version", "news"];
|
|
|
|
|
static INTERNAL_KEYS = ["count", "schema", "version", "news"];
|
|
|
|
|
|
|
|
|
|
this.prototype.LAYOUTS = [
|
|
|
|
|
static LAYOUTS = [
|
|
|
|
|
"_max-width",
|
|
|
|
|
"_sidebar-hidden",
|
|
|
|
|
"_native-scrollbars",
|
|
|
|
|
"_text-justify-hyphenate",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
this.defaults = {
|
|
|
|
|
static defaults = {
|
|
|
|
|
count: 0,
|
|
|
|
|
hideDisabled: false,
|
|
|
|
|
hideIntro: false,
|
|
|
|
@ -55,7 +39,6 @@
|
|
|
|
|
spaceScroll: 1,
|
|
|
|
|
spaceTimeout: 0.5,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.store = new CookiesStore();
|
|
|
|
@ -77,11 +60,7 @@
|
|
|
|
|
(left = this.store.get(key)) != null
|
|
|
|
|
? left
|
|
|
|
|
: this.constructor.defaults[key];
|
|
|
|
|
if (
|
|
|
|
|
key === "theme" &&
|
|
|
|
|
this.cache[key] === "auto" &&
|
|
|
|
|
!this.darkModeQuery
|
|
|
|
|
) {
|
|
|
|
|
if (key === "theme" && this.cache[key] === "auto" && !this.darkModeQuery) {
|
|
|
|
|
return (this.cache[key] = "default");
|
|
|
|
|
} else {
|
|
|
|
|
return this.cache[key];
|
|
|
|
@ -108,10 +87,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDocs() {
|
|
|
|
|
return (
|
|
|
|
|
__guard__(this.store.get("docs"), (x) => x.split("/")) ||
|
|
|
|
|
app.config.default_docs
|
|
|
|
|
);
|
|
|
|
|
return this.store.get("docs")?.split("/") || app.config.default_docs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setDocs(docs) {
|
|
|
|
@ -119,7 +95,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getTips() {
|
|
|
|
|
return __guard__(this.store.get("tips"), (x) => x.split("/")) || [];
|
|
|
|
|
return this.store.get("tips")?.split("/") || [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTips(tips) {
|
|
|
|
@ -162,7 +138,7 @@
|
|
|
|
|
|
|
|
|
|
export() {
|
|
|
|
|
const data = this.dump();
|
|
|
|
|
for (var key of Array.from(INTERNAL_KEYS)) {
|
|
|
|
|
for (var key of Settings.INTERNAL_KEYS) {
|
|
|
|
|
delete data[key];
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
@ -179,7 +155,7 @@
|
|
|
|
|
}
|
|
|
|
|
for (key in data) {
|
|
|
|
|
value = data[key];
|
|
|
|
|
if (PREFERENCE_KEYS.indexOf(key) !== -1) {
|
|
|
|
|
if (Settings.PREFERENCE_KEYS.indexOf(key) !== -1) {
|
|
|
|
|
this.set(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -196,7 +172,7 @@
|
|
|
|
|
this.del("dark");
|
|
|
|
|
}
|
|
|
|
|
this.setTheme(this.get("theme"));
|
|
|
|
|
for (var layout of Array.from(this.LAYOUTS)) {
|
|
|
|
|
for (var layout of app.Settings.LAYOUTS) {
|
|
|
|
|
this.toggleLayout(layout, this.hasLayout(layout));
|
|
|
|
|
}
|
|
|
|
|
this.initSidebarWidth();
|
|
|
|
@ -234,19 +210,7 @@
|
|
|
|
|
initSidebarWidth() {
|
|
|
|
|
const size = this.get("size");
|
|
|
|
|
if (size) {
|
|
|
|
|
document.documentElement.style.setProperty(
|
|
|
|
|
"--sidebarWidth",
|
|
|
|
|
size + "px",
|
|
|
|
|
);
|
|
|
|
|
document.documentElement.style.setProperty("--sidebarWidth", size + "px");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
app.Settings.initClass();
|
|
|
|
|
return app.Settings;
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
function __guard__(value, transform) {
|
|
|
|
|
return typeof value !== "undefined" && value !== null
|
|
|
|
|
? transform(value)
|
|
|
|
|
: undefined;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|