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

URLProcessor.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* global $, $iq, config, interfaceConfig */
  2. var configUtils = require('./Util');
  3. var params = {};
  4. function getConfigParamsFromUrl() {
  5. if (!location.hash)
  6. return {};
  7. var hash = location.hash.substr(1);
  8. var result = {};
  9. hash.split("&").forEach(function (part) {
  10. var item = part.split("=");
  11. result[item[0]] = JSON.parse(
  12. decodeURIComponent(item[1]).replace(/\\&/, "&"));
  13. });
  14. return result;
  15. }
  16. params = getConfigParamsFromUrl();
  17. var URLProcessor = {
  18. setConfigParametersFromUrl: function () {
  19. // Convert 'params' to JSON object
  20. // We have:
  21. // {
  22. // "config.disableAudioLevels": false,
  23. // "config.channelLastN": -1,
  24. // "interfaceConfig.APP_NAME": "Jitsi Meet"
  25. // }
  26. // We want to have:
  27. // {
  28. // "config": {
  29. // "disableAudioLevels": false,
  30. // "channelLastN": -1
  31. // },
  32. // interfaceConfig: {
  33. // APP_NAME: "Jitsi Meet"
  34. // }
  35. // }
  36. var configJSON = {
  37. config: {},
  38. interfaceConfig: {}
  39. };
  40. for (var key in params) {
  41. if (typeof key !== "string") {
  42. console.warn("Invalid config key: ", key);
  43. continue;
  44. }
  45. var confObj = null, confKey;
  46. if (key.indexOf("config.") === 0) {
  47. confObj = configJSON.config;
  48. confKey = key.substr("config.".length);
  49. } else if (key.indexOf("interfaceConfig.") === 0) {
  50. confObj = configJSON.interfaceConfig;
  51. confKey = key.substr("interfaceConfig.".length);
  52. }
  53. if (!confObj)
  54. continue;
  55. confObj[confKey] = params[key];
  56. }
  57. configUtils.overrideConfigJSON(config, interfaceConfig, configJSON);
  58. }
  59. };
  60. module.exports = URLProcessor;