2015-08-21 12:33:05 +00:00
|
|
|
/* global $ */
|
|
|
|
var ConfigUtil = {
|
|
|
|
/**
|
|
|
|
* Method overrides JSON properties in <tt>config</tt> and
|
|
|
|
* <tt>interfaceConfig</tt> Objects with the values from <tt>newConfig</tt>
|
|
|
|
* @param config the config object for which we'll be overriding properties
|
|
|
|
* @param interfaceConfig the interfaceConfig object for which we'll be
|
|
|
|
* overriding properties.
|
|
|
|
* @param newConfig object containing configuration properties. Destination
|
|
|
|
* object is selected based on root property name:
|
|
|
|
* {
|
|
|
|
* config: {
|
|
|
|
* // config.js properties to be
|
|
|
|
* },
|
|
|
|
* interfaceConfig: {
|
|
|
|
* // interfaceConfig.js properties here
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
overrideConfigJSON: function (config, interfaceConfig, newConfig) {
|
2015-10-12 22:46:58 +00:00
|
|
|
var configRoot, key, value, confObj;
|
|
|
|
for (configRoot in newConfig) {
|
|
|
|
confObj = null;
|
2015-08-21 12:33:05 +00:00
|
|
|
if (configRoot == "config") {
|
|
|
|
confObj = config;
|
|
|
|
} else if (configRoot == "interfaceConfig") {
|
|
|
|
confObj = interfaceConfig;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-10-12 22:46:58 +00:00
|
|
|
for (key in newConfig[configRoot]) {
|
|
|
|
value = newConfig[configRoot][key];
|
|
|
|
if (confObj[key] && typeof confObj[key] !== typeof value) {
|
|
|
|
console.log("Overriding a " + configRoot +
|
|
|
|
" property with a property of different type.");
|
2015-08-21 12:33:05 +00:00
|
|
|
}
|
|
|
|
console.info("Overriding " + key + " with: " + value);
|
|
|
|
confObj[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ConfigUtil;
|