mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-11 06:31:51 +08:00
fixed lint warnings
This commit is contained in:
parent
b946f99011
commit
1ff80fe9db
1 changed files with 27 additions and 28 deletions
|
|
@ -3,7 +3,6 @@ import * as DB from "./db";
|
|||
import Config from "./config";
|
||||
import * as Notifications from "./notifications";
|
||||
import * as Account from "./account";
|
||||
import * as Funbox from "./funbox";
|
||||
|
||||
let defaultResultFilters = {
|
||||
difficulty: {
|
||||
|
|
@ -65,6 +64,33 @@ let defaultResultFilters = {
|
|||
|
||||
export let filters = defaultResultFilters;
|
||||
|
||||
function save() {
|
||||
window.localStorage.setItem("resultFilters", JSON.stringify(filters));
|
||||
}
|
||||
|
||||
function load() {
|
||||
// let newTags = $.cookie("activeTags");
|
||||
try {
|
||||
let newResultFilters = window.localStorage.getItem("resultFilters");
|
||||
if (
|
||||
newResultFilters != undefined &&
|
||||
newResultFilters !== "" &&
|
||||
Misc.countAllKeys(newResultFilters) >=
|
||||
Misc.countAllKeys(defaultResultFilters)
|
||||
) {
|
||||
filters = JSON.parse(newResultFilters);
|
||||
save();
|
||||
} else {
|
||||
filters = defaultResultFilters;
|
||||
save();
|
||||
}
|
||||
} catch {
|
||||
console.log("error in loading result filters");
|
||||
filters = defaultResultFilters;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
Promise.all([Misc.getLanguageList(), Misc.getFunboxList()]).then((values) => {
|
||||
let languages = values[0];
|
||||
let funboxModes = values[1];
|
||||
|
|
@ -104,33 +130,6 @@ export function loadTags(tags) {
|
|||
});
|
||||
}
|
||||
|
||||
export function save() {
|
||||
window.localStorage.setItem("resultFilters", JSON.stringify(filters));
|
||||
}
|
||||
|
||||
export function load() {
|
||||
// let newTags = $.cookie("activeTags");
|
||||
try {
|
||||
let newResultFilters = window.localStorage.getItem("resultFilters");
|
||||
if (
|
||||
newResultFilters != undefined &&
|
||||
newResultFilters !== "" &&
|
||||
Misc.countAllKeys(newResultFilters) >=
|
||||
Misc.countAllKeys(defaultResultFilters)
|
||||
) {
|
||||
filters = JSON.parse(newResultFilters);
|
||||
save();
|
||||
} else {
|
||||
filters = defaultResultFilters;
|
||||
save();
|
||||
}
|
||||
} catch {
|
||||
console.log("error in loading result filters");
|
||||
filters = defaultResultFilters;
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
filters = defaultResultFilters;
|
||||
save();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue