correct setting functions
This commit is contained in:
parent
64c1ebff0c
commit
92329580b2
|
@ -47,9 +47,14 @@
|
|||
setConf("FLASH_LIGHT_DURATIONS", [800, 1600, 3200]);
|
||||
setConf("FLASH_LIGHT_COLOR", "#E3E");
|
||||
|
||||
function isSetting(key) {
|
||||
return Object.prototype.hasOwnProperty.call(Conf, key) ||
|
||||
Object.prototype.hasOwnProperty.call(localStorage, key);
|
||||
}
|
||||
|
||||
function getSetting(key) {
|
||||
let type = undefined;
|
||||
let value;
|
||||
let value = undefined;
|
||||
|
||||
/* get default value from configuration */
|
||||
if (Object.prototype.hasOwnProperty.call(Conf, key)) {
|
||||
|
@ -61,9 +66,13 @@
|
|||
if (Object.prototype.hasOwnProperty.call(localStorage, key)) {
|
||||
value = localStorage.getItem(key);
|
||||
|
||||
/* get type from localStore if no default is set */
|
||||
if (type === "undefined") {
|
||||
type = localStorage.getItem(key + "_type");
|
||||
/* get type from localStorage if no default is set */
|
||||
if (type === undefined) {
|
||||
if (Object.prototype.hasOwnProperty.call(localStorage, key + "_key")) {
|
||||
type = localStorage.getItem(key + "_type");
|
||||
} else {
|
||||
type = "string";
|
||||
}
|
||||
}
|
||||
|
||||
/* cast from string to type */
|
||||
|
@ -102,7 +111,7 @@
|
|||
|
||||
/* if not set type is defined from value */
|
||||
if (type === undefined) {
|
||||
typeof value;
|
||||
type = typeof value;
|
||||
}
|
||||
|
||||
/* storage value in localstorage */
|
||||
|
|
Loading…
Reference in New Issue