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

Util.js 1.7KB

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