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)) {
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 */
/* if not set type is defined from value */
if (type === undefined) {
- typeof value;
+ type = typeof value;
}
/* storage value in localstorage */