correct eslint errors
This commit is contained in:
parent
549b176ac9
commit
6ebcc0284d
|
@ -35,7 +35,7 @@
|
|||
if (typeof Conf[parameterName] === "undefined") {
|
||||
Conf[parameterName] = defaultValue;
|
||||
} else if (typeof Conf[parameterName] !== typeof defaultValue) {
|
||||
alert("Head's up - configuration " + parameterName + " does not have the right type. It should be a " + (typeof defaultValue) + ", it is a " + (typeof Conf[parameterName]));
|
||||
myAlert("Head's up - configuration " + parameterName + " does not have the right type. It should be a " + (typeof defaultValue) + ", it is a " + (typeof Conf[parameterName]));
|
||||
throw new Error("Wrong type for configuration " + parameterName + ", expected " + (typeof defaultValue) + ", got " + (typeof Conf[parameterName]));
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,8 @@
|
|||
}
|
||||
|
||||
function getSetting(key) {
|
||||
let type = undefined;
|
||||
let value = undefined;
|
||||
let type;
|
||||
let value;
|
||||
|
||||
/* get default value from configuration */
|
||||
if (Object.prototype.hasOwnProperty.call(Conf, key)) {
|
||||
|
@ -72,7 +72,7 @@
|
|||
value = localStorage.getItem(key);
|
||||
|
||||
/* get type from localStorage if no default is set */
|
||||
if (type === undefined) {
|
||||
if (typeof type === "undefined") {
|
||||
if (Object.prototype.hasOwnProperty.call(localStorage, key + "_key")) {
|
||||
type = localStorage.getItem(key + "_type");
|
||||
} else {
|
||||
|
@ -98,7 +98,7 @@
|
|||
}
|
||||
|
||||
function setSetting(key, value) {
|
||||
let type = undefined;
|
||||
let type;
|
||||
|
||||
/* try to retrieve type from configuration */
|
||||
if (Object.prototype.hasOwnProperty.call(Conf, key)) {
|
||||
|
@ -106,21 +106,19 @@
|
|||
}
|
||||
|
||||
/* try to retrieve type from localstorage */
|
||||
if (type === undefined) {
|
||||
if (typeof type === "undefined") {
|
||||
if (Object.prototype.hasOwnProperty.call(localStorage, key)) {
|
||||
type = localStorage.getItem(key + "_type");
|
||||
}
|
||||
}
|
||||
|
||||
/* if not set type is defined from value */
|
||||
if (type === undefined) {
|
||||
if (typeof type === "undefined") {
|
||||
type = typeof value;
|
||||
}
|
||||
|
||||
/* storage value in localstorage */
|
||||
if (type !== typeof value) {
|
||||
console.error("incoherent type");
|
||||
} else {
|
||||
if (type === typeof value) {
|
||||
if (type === "object") {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
|
@ -137,6 +135,8 @@
|
|||
} else {
|
||||
console.error("Unsupported type");
|
||||
}
|
||||
} else {
|
||||
console.error("incoherent type");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue