mirror of
https://github.com/simon987/sist2.git
synced 2025-04-18 17:56:44 +00:00
Load defaults when LocalStorage is outdated
This commit is contained in:
parent
5fa343d40f
commit
e6fde38c24
@ -19,7 +19,7 @@
|
|||||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||||
|
|
||||||
|
|
||||||
static const char *const Version = "2.1.0";
|
static const char *const Version = "2.1.1";
|
||||||
static const char *const usage[] = {
|
static const char *const usage[] = {
|
||||||
"sist2 scan [OPTION]... PATH",
|
"sist2 scan [OPTION]... PATH",
|
||||||
"sist2 index [OPTION]... INDEX",
|
"sist2 index [OPTION]... INDEX",
|
||||||
|
@ -73,18 +73,23 @@ function Settings() {
|
|||||||
|
|
||||||
this._onUpdate = function () {
|
this._onUpdate = function () {
|
||||||
$("#fuzzyToggle").prop("checked", this.options.fuzzy);
|
$("#fuzzyToggle").prop("checked", this.options.fuzzy);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.load = function () {
|
this.load = function () {
|
||||||
const raw = window.localStorage.getItem("options");
|
const raw = window.localStorage.getItem("options");
|
||||||
if (raw === null) {
|
if (raw === null) {
|
||||||
this.options = _defaults;
|
this.options = _defaults;
|
||||||
} else {
|
} else {
|
||||||
this.options = JSON.parse(raw);
|
const j = JSON.parse(raw);
|
||||||
|
if (!j || Object.keys(_defaults).some(k => !j.hasOwnProperty(k))) {
|
||||||
|
this.options = _defaults;
|
||||||
|
} else {
|
||||||
|
this.options = j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._onUpdate();
|
this._onUpdate();
|
||||||
}
|
};
|
||||||
|
|
||||||
this.save = function () {
|
this.save = function () {
|
||||||
window.localStorage.setItem("options", JSON.stringify(this.options));
|
window.localStorage.setItem("options", JSON.stringify(this.options));
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">2.1.0</span>
|
<span class="badge badge-pill version">2.1.1</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
||||||
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user