You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* jshint -W117 */
  2. /* application specific logic */
  3. require("jquery");
  4. require("jquery-ui");
  5. require("strophe");
  6. require("strophe-disco");
  7. require("strophe-caps");
  8. require("tooltip");
  9. require("popover");
  10. window.toastr = require("toastr");
  11. require("jQuery-Impromptu");
  12. require("autosize");
  13. var APP =
  14. {
  15. init: function () {
  16. this.UI = require("./modules/UI/UI");
  17. this.API = require("./modules/API/API");
  18. this.connectionquality =
  19. require("./modules/connectionquality/connectionquality");
  20. this.statistics = require("./modules/statistics/statistics");
  21. this.RTC = require("./modules/RTC/RTC");
  22. this.desktopsharing =
  23. require("./modules/desktopsharing/desktopsharing");
  24. this.xmpp = require("./modules/xmpp/xmpp");
  25. this.keyboardshortcut =
  26. require("./modules/keyboardshortcut/keyboardshortcut");
  27. this.translation = require("./modules/translation/translation");
  28. this.settings = require("./modules/settings/Settings");
  29. //this.DTMF = require("./modules/DTMF/DTMF");
  30. this.members = require("./modules/members/MemberList");
  31. this.configFetch = require("./modules/config/HttpConfigFetch");
  32. }
  33. };
  34. function init() {
  35. APP.desktopsharing.init();
  36. APP.RTC.start();
  37. APP.xmpp.start();
  38. APP.statistics.start();
  39. APP.connectionquality.init();
  40. APP.keyboardshortcut.init();
  41. APP.members.start();
  42. }
  43. /**
  44. * If we have an HTTP endpoint for getting config.json configured we're going to
  45. * read it and override properties from config.js and interfaceConfig.js.
  46. * If there is no endpoint we'll just continue with initialization.
  47. * Keep in mind that if the endpoint has been configured and we fail to obtain
  48. * the config for any reason then the conference won't start and error message
  49. * will be displayed to the user.
  50. */
  51. function obtainConfigAndInit() {
  52. var roomName = APP.UI.getRoomNode();
  53. if (config.configLocation) {
  54. APP.configFetch.obtainConfig(
  55. config.configLocation, roomName,
  56. // Get config result callback
  57. function(success, error) {
  58. if (success) {
  59. console.log("(TIME) configuration fetched:\t",
  60. window.performance.now());
  61. init();
  62. } else {
  63. // Show obtain config error,
  64. // pass the error object for report
  65. APP.UI.messageHandler.openReportDialog(
  66. null, "dialog.connectError", error);
  67. }
  68. });
  69. } else {
  70. require("./modules/config/BoshAddressChoice").chooseAddress(
  71. config, roomName);
  72. init();
  73. }
  74. }
  75. $(document).ready(function () {
  76. console.log("(TIME) document ready:\t", window.performance.now());
  77. var URLProcessor = require("./modules/config/URLProcessor");
  78. URLProcessor.setConfigParametersFromUrl();
  79. APP.init();
  80. APP.translation.init();
  81. if(APP.API.isEnabled())
  82. APP.API.init();
  83. APP.UI.start(obtainConfigAndInit);
  84. });
  85. $(window).bind('beforeunload', function () {
  86. if(APP.API.isEnabled())
  87. APP.API.dispose();
  88. });
  89. module.exports = APP;