您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Util.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var ConfigUtil = {
  2. /**
  3. * Method overrides JSON properties in <tt>config</tt> and
  4. * <tt>interfaceConfig</tt> Objects with the values from <tt>newConfig</tt>
  5. * @param config the config object for which we'll be overriding properties
  6. * @param interfaceConfig the interfaceConfig object for which we'll be
  7. * overriding properties.
  8. * @param newConfig object containing configuration properties. Destination
  9. * object is selected based on root property name:
  10. * {
  11. * config: {
  12. * // config.js properties to be
  13. * },
  14. * interfaceConfig: {
  15. * // interfaceConfig.js properties here
  16. * }
  17. * }
  18. */
  19. overrideConfigJSON: function (config, interfaceConfig, newConfig) {
  20. var configRoot, key, value, confObj;
  21. for (configRoot in newConfig) {
  22. confObj = null;
  23. if (configRoot == "config") {
  24. confObj = config;
  25. } else if (configRoot == "interfaceConfig") {
  26. confObj = interfaceConfig;
  27. } else {
  28. continue;
  29. }
  30. for (key in newConfig[configRoot]) {
  31. value = newConfig[configRoot][key];
  32. if (confObj[key] && typeof confObj[key] !== typeof value) {
  33. console.log("Overriding a " + configRoot +
  34. " property with a property of different type.");
  35. }
  36. console.info("Overriding " + key + " with: " + value);
  37. confObj[key] = value;
  38. }
  39. }
  40. }
  41. };
  42. module.exports = ConfigUtil;