2017-09-24 00:12:12 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2017-11-07 00:36:44 +01:00
|
|
|
(function(){
|
2017-09-24 00:12:12 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var scope;
|
|
|
|
if ((typeof exports) !== "undefined"){
|
|
|
|
scope = exports;
|
|
|
|
}
|
|
|
|
else {
|
2017-11-07 00:36:44 +01:00
|
|
|
scope = {};
|
|
|
|
window.scope.settings = scope;
|
2017-09-24 00:12:12 +02:00
|
|
|
}
|
|
|
|
|
2018-09-15 21:13:25 +02:00
|
|
|
const logging = require("./logging");
|
2017-11-07 00:36:44 +01:00
|
|
|
const settingDefinitions = require("./settingDefinitions.js");
|
2018-09-16 01:22:40 +02:00
|
|
|
const settingContainers = require("./settingContainers");
|
2017-12-03 23:47:49 +01:00
|
|
|
const definitionsByName = {};
|
|
|
|
const defaultSymbol = "";
|
2017-11-07 00:36:44 +01:00
|
|
|
|
2017-12-03 23:47:49 +01:00
|
|
|
const eventHandler = {any: {}};
|
|
|
|
eventHandler.any[defaultSymbol] = [];
|
2017-11-07 00:36:44 +01:00
|
|
|
eventHandler.all = eventHandler.any;
|
|
|
|
const settings = {};
|
2017-09-24 00:12:12 +02:00
|
|
|
|
2017-12-03 23:47:49 +01:00
|
|
|
function isDefinitionInvalid(settingDefinition, newValue){
|
|
|
|
if (newValue === undefined && settingDefinition.optional){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (settingDefinition.fixed){
|
|
|
|
return "fixed";
|
|
|
|
}
|
|
|
|
else if ((typeof newValue) !== (typeof settingDefinition.defaultValue)){
|
|
|
|
return "wrongType";
|
|
|
|
}
|
|
|
|
else if (Array.isArray(settingDefinition.defaultValue)){
|
|
|
|
if (!Array.isArray(newValue)){
|
2017-11-14 01:07:27 +01:00
|
|
|
return "wrongType";
|
2017-11-07 00:36:44 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
var entriesInvalid = newValue.reduce(function(v, entry){
|
|
|
|
v = v || settingDefinition.entries.reduce(function(v, entryDefinition){
|
|
|
|
return v || isDefinitionInvalid(entryDefinition, entry[entryDefinition.name]);
|
|
|
|
}, false);
|
|
|
|
if (!v){
|
|
|
|
if (Object.keys(entry).some(function(key){
|
|
|
|
return !settingDefinition.entries.some(function(entryDefinition){
|
|
|
|
return key === entryDefinition.name;
|
|
|
|
});
|
|
|
|
})){
|
|
|
|
return "noOption";
|
|
|
|
}
|
2017-11-14 01:07:27 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
return v;
|
|
|
|
}, false);
|
|
|
|
if (entriesInvalid){
|
|
|
|
return entriesInvalid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (
|
|
|
|
settingDefinition.options &&
|
|
|
|
!settingDefinition.options.includes(newValue)
|
|
|
|
){
|
|
|
|
return "noOption";
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createGetter(settingDefinition){
|
|
|
|
if (settingDefinition.dynamic){
|
|
|
|
return function getValue(){
|
|
|
|
return settingDefinition.getter(scope);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if (settingDefinition.urlSpecific){
|
|
|
|
return function getValue(url){
|
|
|
|
if (url){
|
2018-09-16 01:22:40 +02:00
|
|
|
var match = settingContainers.getUrlValueContainer(settingDefinition.name, url);
|
|
|
|
if (match){
|
|
|
|
return match[settingDefinition.name];
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
2017-11-14 01:07:27 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
return settings[settingDefinition.name];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return function getValue(){
|
|
|
|
return settings[settingDefinition.name];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createSetter(settingDefinition){
|
|
|
|
if (settingDefinition.dynamic){
|
|
|
|
return function setValue(newValue){
|
|
|
|
settingDefinition.setter(scope);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const name = settingDefinition.name;
|
|
|
|
const isValid = function isValid(newValue){
|
|
|
|
var invalid = settingDefinition.invalid(newValue);
|
|
|
|
if (invalid){
|
|
|
|
if (invalid === "fixed"){
|
|
|
|
logging.warning("Trying to set the fixed setting", name, ":", newValue);
|
|
|
|
}
|
|
|
|
else if (invalid === "wrongType"){
|
|
|
|
logging.warning("Wrong type provided for setting", name, ":", newValue);
|
|
|
|
}
|
|
|
|
else if (invalid === "noOption"){
|
|
|
|
logging.warning("Provided value outside specified options for ", name, ":", newValue);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
logging.warning("Unknown invalid state:", invalid);
|
|
|
|
}
|
|
|
|
return false;
|
2017-11-14 01:07:27 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
const storeValue = function storeValue(newValue){
|
2018-07-12 01:18:49 +02:00
|
|
|
logging.verbose("Trying to store new value for %s", name, newValue);
|
2017-11-10 23:45:09 +01:00
|
|
|
settings[name] = newValue;
|
|
|
|
if (!settingDefinition.transient){
|
|
|
|
var storeObject = {};
|
|
|
|
storeObject[name] = newValue;
|
2018-07-17 12:54:10 +02:00
|
|
|
var promise = browser.storage.local.set(storeObject);
|
|
|
|
promise.then(function(){
|
2018-07-12 01:18:49 +02:00
|
|
|
logging.verbose("New value stored for %s:", name, newValue);
|
|
|
|
}, function(err){
|
|
|
|
logging.warning("Unable to store new value for %s:", name, newValue, err);
|
|
|
|
});
|
2018-07-17 12:54:10 +02:00
|
|
|
return promise;
|
2018-07-12 01:18:49 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
logging.warning("Transient setting %s cannot be stored.", name);
|
2017-11-10 23:45:09 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
if (settingDefinition.urlSpecific){
|
|
|
|
return function setValue(newValue, url){
|
2018-07-12 01:18:49 +02:00
|
|
|
logging.verbose("New value for %s (%s):", name, url, newValue);
|
2017-12-03 23:47:49 +01:00
|
|
|
if (isValid(newValue)){
|
|
|
|
if (url){
|
2018-09-16 01:22:40 +02:00
|
|
|
return settingContainers.setUrlValue(name, newValue, url);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-07-17 12:54:10 +02:00
|
|
|
return storeValue(newValue);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-12 01:18:49 +02:00
|
|
|
else{
|
|
|
|
logging.warning("Invalid value for %s (%s):", name, url, newValue);
|
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return function setValue(newValue){
|
|
|
|
logging.verbose("New value for %s:", name, newValue);
|
|
|
|
if (isValid(newValue)){
|
2018-07-17 12:54:10 +02:00
|
|
|
return storeValue(newValue);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
2018-07-12 01:18:49 +02:00
|
|
|
else{
|
|
|
|
logging.warning("Invalid value for %s:", name, newValue);
|
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createResetter(settingDefinition){
|
|
|
|
if (settingDefinition.dynamic){
|
|
|
|
return function(){};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const name = settingDefinition.name;
|
|
|
|
let reset = function(){
|
|
|
|
settings[name] = settingDefinition.defaultValue;
|
|
|
|
browser.storage.local.remove(name);
|
|
|
|
};
|
|
|
|
if (settingDefinition.urlSpecific){
|
|
|
|
return function(url){
|
|
|
|
if (url){
|
2018-09-16 01:22:40 +02:00
|
|
|
settingContainers.resetUrlValue(name, url);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
};
|
2017-11-10 23:45:09 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
else {
|
|
|
|
return reset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-02 00:29:41 +02:00
|
|
|
scope.on = function onSettingsChange(name, callback, url){
|
|
|
|
if (Array.isArray(name)){
|
|
|
|
name.forEach(function(name){
|
|
|
|
onSettingsChange(name, callback, url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eventHandler.hasOwnProperty(name)){
|
|
|
|
if (!url){
|
|
|
|
url = defaultSymbol;
|
|
|
|
}
|
|
|
|
if (!eventHandler[name].hasOwnProperty(url)){
|
|
|
|
eventHandler[name][url] = [];
|
|
|
|
}
|
|
|
|
eventHandler[name][url].push(callback);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
logging.warning("Unable to register event handler for unknown setting", name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-03 23:47:49 +01:00
|
|
|
settingDefinitions.forEach(function(settingDefinition){
|
|
|
|
var name = settingDefinition.name;
|
|
|
|
definitionsByName[name] = settingDefinition;
|
2018-06-21 00:03:17 +02:00
|
|
|
if (typeof settingDefinition.defaultValue === "function"){
|
|
|
|
settingDefinition.defaultValue = settingDefinition.defaultValue();
|
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
settings[name] = settingDefinition.defaultValue;
|
|
|
|
eventHandler[name] = {};
|
|
|
|
|
|
|
|
settingDefinition.on = function on(callback, url){
|
|
|
|
if (!settingDefinition.dynamic){
|
|
|
|
scope.on(name, callback, url);
|
|
|
|
}
|
|
|
|
if (settingDefinition.dependencies){
|
|
|
|
settingDefinition.dependencies.forEach(function(dependency){
|
|
|
|
scope.on(dependency, function(){
|
|
|
|
callback({name, newValue: settingDefinition.get()});
|
|
|
|
}, url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
settingDefinition.invalid = function invalid(newValue){
|
|
|
|
return isDefinitionInvalid(settingDefinition, newValue);
|
2017-11-07 00:36:44 +01:00
|
|
|
};
|
2017-12-03 23:47:49 +01:00
|
|
|
settingDefinition.get = createGetter(settingDefinition);
|
|
|
|
|
|
|
|
settingDefinition.set = createSetter(settingDefinition);
|
|
|
|
|
|
|
|
settingDefinition.reset = createResetter(settingDefinition);
|
2018-07-02 00:29:41 +02:00
|
|
|
|
2017-12-03 23:47:49 +01:00
|
|
|
if (settingDefinition.urlSpecific){
|
2018-09-16 01:22:40 +02:00
|
|
|
if (!settingContainers.urlContainer){
|
2017-12-03 23:47:49 +01:00
|
|
|
logging.error("Unable to use url specific settings without url-container");
|
|
|
|
}
|
|
|
|
else {
|
2018-09-16 01:22:40 +02:00
|
|
|
settingDefinition.urlContainer = settingContainers.urlContainer;
|
2017-12-03 23:47:49 +01:00
|
|
|
let entry = Object.create(settingDefinition);
|
|
|
|
entry.optional = true;
|
2018-09-16 01:22:40 +02:00
|
|
|
settingContainers.urlContainer.entries.push(entry);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-07 00:36:44 +01:00
|
|
|
Object.defineProperty(
|
|
|
|
scope,
|
|
|
|
name,
|
|
|
|
{
|
|
|
|
get: settingDefinition.get,
|
2017-11-07 19:51:49 +01:00
|
|
|
set: settingDefinition.set,
|
|
|
|
enumerable: true
|
2017-11-07 00:36:44 +01:00
|
|
|
}
|
2017-09-24 00:12:12 +02:00
|
|
|
);
|
2018-07-02 00:29:41 +02:00
|
|
|
|
2018-09-16 01:22:40 +02:00
|
|
|
settingContainers.check(settingDefinition);
|
2017-09-24 00:12:12 +02:00
|
|
|
});
|
|
|
|
|
2017-11-07 00:36:44 +01:00
|
|
|
scope.getDefinition = function(name){
|
2017-12-03 23:47:49 +01:00
|
|
|
var foundDefinition = definitionsByName[name];
|
|
|
|
if (foundDefinition){
|
|
|
|
return Object.create(foundDefinition);
|
2017-11-07 00:36:44 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
};
|
2018-07-02 00:29:41 +02:00
|
|
|
|
|
|
|
scope.getContainers = function(){
|
|
|
|
return {
|
2018-09-16 01:22:40 +02:00
|
|
|
url: Object.create(settingContainers.urlContainer),
|
|
|
|
hide: Object.create(settingContainers.hideContainer),
|
|
|
|
expand: Object.create(settingContainers.expandContainer)
|
2018-07-02 00:29:41 +02:00
|
|
|
};
|
|
|
|
};
|
2017-11-07 00:36:44 +01:00
|
|
|
|
2017-12-03 23:47:49 +01:00
|
|
|
scope.set = function(name, ...args){
|
|
|
|
var foundDefinition = definitionsByName[name];
|
|
|
|
if (foundDefinition){
|
|
|
|
return foundDefinition.set(...args);
|
|
|
|
}
|
|
|
|
else {
|
2018-08-22 22:16:49 +02:00
|
|
|
logging.error("Try to set unknown setting:", name);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
scope.get = function(name, ...args){
|
|
|
|
var foundDefinition = definitionsByName[name];
|
|
|
|
if (foundDefinition){
|
|
|
|
return foundDefinition.get(...args);
|
|
|
|
}
|
|
|
|
else {
|
2018-08-22 22:16:49 +02:00
|
|
|
logging.error("Try to get unknown setting:", name);
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-24 00:12:12 +02:00
|
|
|
scope.forEach = function forEachSetting(...args){
|
2017-12-03 23:47:49 +01:00
|
|
|
settingDefinitions.filter(function(settingDefinition){
|
|
|
|
return !settingDefinition.dynamic;
|
|
|
|
}).map(function(settingDefinition){
|
2017-09-24 00:12:12 +02:00
|
|
|
return Object.create(settingDefinition);
|
|
|
|
}).forEach(...args);
|
2017-11-07 00:36:44 +01:00
|
|
|
};
|
2017-12-03 23:47:49 +01:00
|
|
|
|
|
|
|
const resetSymbol = Symbol("reset");
|
2017-11-07 00:36:44 +01:00
|
|
|
function changeValue(name, newValue){
|
2017-12-03 23:47:49 +01:00
|
|
|
var settingDefinition = scope.getDefinition(name);
|
2017-12-19 23:04:03 +01:00
|
|
|
if (settingDefinition){
|
|
|
|
var oldValue = settings[name];
|
|
|
|
if (newValue === resetSymbol){
|
|
|
|
newValue = settingDefinition.defaultValue;
|
|
|
|
}
|
|
|
|
settings[name] = newValue;
|
|
|
|
((eventHandler[name] || {})[defaultSymbol] || []).forEach(function(callback){
|
|
|
|
callback({name, newValue, oldValue});
|
2017-12-03 23:47:49 +01:00
|
|
|
});
|
2017-12-19 23:04:03 +01:00
|
|
|
|
|
|
|
if (settingDefinition.urlSpecific){
|
2018-09-16 01:22:40 +02:00
|
|
|
settingContainers.urlContainer.get().forEach(function(entry){
|
2017-12-19 23:04:03 +01:00
|
|
|
if (!entry.hasOwnProperty(name)){
|
|
|
|
((eventHandler[name] || {})[entry.url] || []).forEach(function(callback){
|
|
|
|
callback({name, newValue, oldValue, url: entry.url});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
}
|
2017-09-24 00:12:12 +02:00
|
|
|
}
|
2017-11-07 00:36:44 +01:00
|
|
|
|
|
|
|
logging.verbose("registering storage onchange listener");
|
|
|
|
browser.storage.onChanged.addListener(function(changes, area){
|
|
|
|
if (area === "local"){
|
|
|
|
logging.notice("settings changed", changes);
|
2017-12-03 23:47:49 +01:00
|
|
|
var delayedChange = [];
|
2017-11-07 00:36:44 +01:00
|
|
|
Object.entries(changes).forEach(function(entry){
|
|
|
|
const [name, change] = entry;
|
2018-09-16 01:22:40 +02:00
|
|
|
if (settingContainers.urlContainer && name === settingContainers.urlContainer.name){
|
2017-12-03 23:47:49 +01:00
|
|
|
// changes in the url container have to trigger after the other changes
|
|
|
|
delayedChange.push(entry);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (change.hasOwnProperty("newValue")){
|
|
|
|
changeValue(name, change.newValue);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
changeValue(name, resetSymbol);
|
|
|
|
}
|
|
|
|
}
|
2017-11-07 00:36:44 +01:00
|
|
|
});
|
2017-12-03 23:47:49 +01:00
|
|
|
delayedChange.forEach(function(entry){
|
|
|
|
const [name, change] = entry;
|
|
|
|
if (change.hasOwnProperty("newValue")){
|
|
|
|
changeValue(name, change.newValue);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
changeValue(name, resetSymbol);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
eventHandler.any[""].forEach(function(callback){
|
2017-11-07 00:36:44 +01:00
|
|
|
callback();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-11-10 23:45:09 +01:00
|
|
|
|
2018-09-16 12:27:50 +02:00
|
|
|
settingContainers.initializeUrlContainer(eventHandler);
|
2017-12-03 23:47:49 +01:00
|
|
|
|
2017-11-07 00:36:44 +01:00
|
|
|
logging.verbose("loading settings");
|
2017-11-27 12:28:01 +01:00
|
|
|
let initialized = false;
|
2018-09-15 21:13:25 +02:00
|
|
|
scope.isInitialized = function(){
|
|
|
|
return initialized;
|
|
|
|
};
|
2017-11-27 12:28:01 +01:00
|
|
|
const initEvents = [];
|
|
|
|
scope.init = function(storage){
|
|
|
|
if (initialized){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
initialized = true;
|
2017-11-07 00:36:44 +01:00
|
|
|
logging.message("settings loaded");
|
2018-09-14 16:29:30 +02:00
|
|
|
if (require.exists("./settingsMigration")){
|
|
|
|
const settingsMigration = require("./settingsMigration");
|
2018-09-16 01:22:40 +02:00
|
|
|
settingsMigration.check(
|
|
|
|
storage,
|
|
|
|
{settings, logging, changeValue, urlContainer: settingContainers.urlContainer}
|
|
|
|
);
|
2017-11-10 23:45:09 +01:00
|
|
|
}
|
2017-12-03 23:47:49 +01:00
|
|
|
var delayedChange = [];
|
2017-11-07 00:36:44 +01:00
|
|
|
Object.entries(storage).forEach(function(entry){
|
2017-12-03 23:47:49 +01:00
|
|
|
const [name, value] = entry;
|
2018-09-16 01:22:40 +02:00
|
|
|
if (settingContainers.urlContainer && name === settingContainers.urlContainer.name){
|
2017-12-03 23:47:49 +01:00
|
|
|
// changes in the url container have to trigger after the other changes
|
|
|
|
delayedChange.push(entry);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
changeValue(name, value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
delayedChange.forEach(function(entry){
|
2017-11-07 00:36:44 +01:00
|
|
|
const [name, value] = entry;
|
|
|
|
changeValue(name, value);
|
|
|
|
});
|
|
|
|
changeValue("isStillDefault", false);
|
2017-11-27 12:28:01 +01:00
|
|
|
|
|
|
|
initEvents.forEach(function(callback){callback();});
|
|
|
|
return true;
|
|
|
|
};
|
2018-10-02 13:20:40 +02:00
|
|
|
if (window.scope.settingsData){
|
|
|
|
scope.init(window.scope.settingsData);
|
|
|
|
scope.loaded = Promise.resolve(false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
scope.loaded = browser.storage.local.get().then(scope.init);
|
|
|
|
}
|
2017-11-07 00:36:44 +01:00
|
|
|
scope.onloaded = function(callback){
|
|
|
|
if (scope.isStillDefault){
|
2017-11-27 12:28:01 +01:00
|
|
|
initEvents.push(callback);
|
2017-11-07 00:36:44 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
};
|
2017-12-04 00:26:26 +01:00
|
|
|
scope.forceLoad = function(){
|
|
|
|
while (settings.isStillDefault){
|
|
|
|
logging.message("Starting synchronous request to wait for settings.");
|
|
|
|
try {
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("GET", "https://[::]", false);
|
|
|
|
xhr.send();
|
|
|
|
xhr = null;
|
|
|
|
}
|
|
|
|
catch (e){
|
|
|
|
logging.verbose("Error in XHR:", e);
|
|
|
|
}
|
|
|
|
logging.message("settings still default?", settings.isStillDefault);
|
|
|
|
}
|
|
|
|
};
|
2018-07-17 13:07:50 +02:00
|
|
|
scope.startupReset = function(){
|
|
|
|
scope.forEach(function(definition){
|
|
|
|
if (definition.resetOnStartup){
|
|
|
|
definition.set(definition.defaultValue);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2017-11-07 00:36:44 +01:00
|
|
|
Object.seal(scope);
|
2018-09-15 21:13:25 +02:00
|
|
|
|
|
|
|
require.emit("./settings");
|
2017-09-24 00:12:12 +02:00
|
|
|
}());
|