correct eslint errors
authorLaurent Mazet <mazet@softndesign.org>
Sun, 13 Sep 2020 20:46:43 +0000 (22:46 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sun, 13 Sep 2020 20:46:43 +0000 (22:46 +0200)
public/trivabble.js

index 7172b68613a3a47383ba30017e4183102fdf9aee..ec9f35271c0770fdbbd5570da945ff2d5104fe7a 100644 (file)
@@ -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)) {
         }
 
         /* 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);
             }
             } else {
                 console.error("Unsupported type");
             }
+        } else {
+            console.error("incoherent type");
         }
     }