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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /* global $, JitsiMeetJS, config, interfaceConfig */
  2. /* application specific logic */
  3. import "babel-polyfill";
  4. import "jquery";
  5. import "jquery-ui";
  6. import "strophe";
  7. import "strophe-disco";
  8. import "strophe-caps";
  9. import "tooltip";
  10. import "popover";
  11. import "jQuery-Impromptu";
  12. import "autosize";
  13. window.toastr = require("toastr");
  14. import URLProcessor from "./modules/config/URLProcessor";
  15. import RoomnameGenerator from './modules/util/RoomnameGenerator';
  16. import CQEvents from './service/connectionquality/CQEvents';
  17. import UIEvents from './service/UI/UIEvents';
  18. import {openConnection} from './modules/connection';
  19. import AuthHandler from './modules/AuthHandler';
  20. import createRoomLocker from './modules/RoomLocker';
  21. const DesktopSharingEventTypes =
  22. require("./service/desktopsharing/DesktopSharingEventTypes");
  23. const ConnectionEvents = JitsiMeetJS.events.connection;
  24. const ConnectionErrors = JitsiMeetJS.errors.connection;
  25. const ConferenceEvents = JitsiMeetJS.events.conference;
  26. const ConferenceErrors = JitsiMeetJS.errors.conference;
  27. const TrackEvents = JitsiMeetJS.events.track;
  28. const TrackErrors = JitsiMeetJS.errors.track;
  29. let localVideo, localAudio;
  30. const Commands = {
  31. CONNECTION_QUALITY: "connectionQuality",
  32. EMAIL: "email",
  33. VIDEO_TYPE: "videoType"
  34. ETHERPAD: "etherpad",
  35. PREZI: "prezi",
  36. STOP_PREZI: "stop-prezi"
  37. };
  38. function buildRoomName () {
  39. let path = window.location.pathname;
  40. let roomName;
  41. // determinde the room node from the url
  42. // TODO: just the roomnode or the whole bare jid?
  43. if (config.getroomnode && typeof config.getroomnode === 'function') {
  44. // custom function might be responsible for doing the pushstate
  45. roomName = config.getroomnode(path);
  46. } else {
  47. /* fall back to default strategy
  48. * this is making assumptions about how the URL->room mapping happens.
  49. * It currently assumes deployment at root, with a rewrite like the
  50. * following one (for nginx):
  51. location ~ ^/([a-zA-Z0-9]+)$ {
  52. rewrite ^/(.*)$ / break;
  53. }
  54. */
  55. if (path.length > 1) {
  56. roomName = path.substr(1).toLowerCase();
  57. } else {
  58. let word = RoomnameGenerator.generateRoomWithoutSeparator();
  59. roomName = word.toLowerCase();
  60. window.history.pushState(
  61. 'VideoChat', `Room: ${word}`, window.location.pathname + word
  62. );
  63. }
  64. }
  65. return roomName;
  66. }
  67. const APP = {
  68. init () {
  69. let roomName = buildRoomName();
  70. this.conference = {
  71. roomName,
  72. localId: undefined,
  73. isModerator: false,
  74. membersCount: 0,
  75. audioMuted: false,
  76. videoMuted: false,
  77. isLocalId (id) {
  78. return this.localId === id;
  79. },
  80. muteAudio (mute) {
  81. APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
  82. },
  83. toggleAudioMuted () {
  84. this.muteAudio(!this.audioMuted);
  85. },
  86. muteVideo (mute) {
  87. APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
  88. },
  89. toggleVideoMuted () {
  90. this.muteVideo(!this.videoMuted);
  91. }
  92. };
  93. this.UI = require("./modules/UI/UI");
  94. this.API = require("./modules/API/API");
  95. this.connectionquality =
  96. require("./modules/connectionquality/connectionquality");
  97. this.statistics = require("./modules/statistics/statistics");
  98. this.desktopsharing =
  99. require("./modules/desktopsharing/desktopsharing");
  100. this.keyboardshortcut =
  101. require("./modules/keyboardshortcut/keyboardshortcut");
  102. this.translation = require("./modules/translation/translation");
  103. this.settings = require("./modules/settings/Settings");
  104. this.configFetch = require("./modules/config/HttpConfigFetch");
  105. }
  106. };
  107. function initConference(localTracks, connection) {
  108. let room = connection.initJitsiConference(APP.conference.roomName, {
  109. openSctp: config.openSctp,
  110. disableAudioLevels: config.disableAudioLevels
  111. });
  112. const addTrack = (track) => {
  113. room.addTrack(track);
  114. if(track.getType() === "audio")
  115. return;
  116. room.removeCommand(Commands.VIDEO_TYPE);
  117. room.sendCommand(Commands.VIDEO_TYPE, {
  118. value: track.videoType,
  119. attributes: {
  120. xmlns: 'http://jitsi.org/jitmeet/video'
  121. }
  122. });
  123. };
  124. APP.conference.localId = room.myUserId();
  125. Object.defineProperty(APP.conference, "membersCount", {
  126. get: function () {
  127. return room.getParticipants().length; // FIXME maybe +1?
  128. }
  129. });
  130. APP.conference.listMembers = function () {
  131. return room.getParticipants();
  132. };
  133. APP.conference.listMembersIds = function () {
  134. return room.getParticipants().map(p => p.getId());
  135. };
  136. /**
  137. * Creates video track (desktop or camera).
  138. * @param type "camera" or "video"
  139. * @param endedHandler onended function
  140. * @returns Promise
  141. */
  142. APP.conference.createVideoTrack = (type, endedHandler) => {
  143. return JitsiMeetJS.createLocalTracks({
  144. devices: [type], resolution: config.resolution
  145. }).then((tracks) => {
  146. tracks[0].on(TrackEvents.TRACK_STOPPED, endedHandler);
  147. return tracks;
  148. });
  149. };
  150. APP.conference.changeLocalVideo = (track, callback) => {
  151. const localCallback = (newTrack) => {
  152. if (newTrack.isLocal() && newTrack === localVideo) {
  153. if(localVideo.isMuted() &&
  154. localVideo.videoType !== track.videoType) {
  155. localVideo.mute();
  156. }
  157. callback();
  158. room.off(ConferenceEvents.TRACK_ADDED, localCallback);
  159. }
  160. };
  161. room.on(ConferenceEvents.TRACK_ADDED, localCallback);
  162. localVideo.stop();
  163. localVideo = track;
  164. addTrack(track);
  165. APP.UI.addLocalStream(track);
  166. };
  167. APP.conference.sipGatewayEnabled = () => {
  168. return room.isSIPCallingSupported();
  169. };
  170. function getDisplayName(id) {
  171. if (APP.conference.isLocalId(id)) {
  172. return APP.settings.getDisplayName();
  173. }
  174. var participant = room.getParticipantById(id);
  175. if (participant && participant.getDisplayName()) {
  176. return participant.getDisplayName();
  177. }
  178. }
  179. // add local streams when joined to the conference
  180. room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
  181. localTracks.forEach(function (track) {
  182. if(track.getType() === "audio") {
  183. localAudio = track;
  184. }
  185. else if (track.getType() === "video") {
  186. localVideo = track;
  187. }
  188. addTrack(track);
  189. APP.UI.addLocalStream(track);
  190. });
  191. APP.UI.updateAuthInfo(room.isAuthEnabled(), room.getAuthLogin());
  192. });
  193. room.on(ConferenceEvents.USER_JOINED, function (id, user) {
  194. console.error('USER %s connnected', id, user);
  195. // FIXME email???
  196. APP.UI.addUser(id, user.getDisplayName());
  197. });
  198. room.on(ConferenceEvents.USER_LEFT, function (id, user) {
  199. console.error('USER %s LEFT', id, user);
  200. APP.UI.removeUser(id, user.getDisplayName());
  201. APP.UI.stopPrezi(id);
  202. });
  203. room.on(ConferenceEvents.USER_ROLE_CHANGED, function (id, role) {
  204. if (APP.conference.isLocalId(id)) {
  205. console.info(`My role changed, new role: ${role}`);
  206. APP.conference.isModerator = room.isModerator();
  207. APP.UI.updateLocalRole(room.isModerator());
  208. } else {
  209. var user = room.getParticipantById(id);
  210. if (user) {
  211. APP.UI.updateUserRole(user);
  212. }
  213. }
  214. });
  215. let roomLocker = createRoomLocker(room);
  216. APP.UI.addListener(UIEvents.ROOM_LOCK_CLICKED, function () {
  217. if (room.isModerator()) {
  218. let promise = roomLocker.isLocked
  219. ? roomLocker.askToUnlock()
  220. : roomLocker.askToLock();
  221. promise.then(function () {
  222. APP.UI.markRoomLocked(roomLocker.isLocked);
  223. });
  224. } else {
  225. roomLocker.notifyModeratorRequired();
  226. }
  227. });
  228. room.on(ConferenceEvents.TRACK_ADDED, function (track) {
  229. if (track.isLocal()) { // skip local tracks
  230. return;
  231. }
  232. console.error(
  233. 'REMOTE %s TRACK', track.getType(), track.getParticipantId()
  234. );
  235. APP.UI.addRemoteStream(track);
  236. });
  237. room.on(ConferenceEvents.TRACK_REMOVED, function (track) {
  238. if (track.isLocal()) { // skip local tracks
  239. return;
  240. }
  241. console.error(
  242. 'REMOTE %s TRACK REMOVED', track.getType(), track.getParticipantId()
  243. );
  244. // FIXME handle
  245. });
  246. room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
  247. // FIXME handle mute
  248. });
  249. room.on(ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, function (id, lvl) {
  250. APP.UI.setAudioLevel(id, lvl);
  251. });
  252. APP.UI.addListener(UIEvents.AUDIO_MUTED, function (muted) {
  253. // FIXME mute or unmute
  254. APP.UI.setAudioMuted(muted);
  255. APP.conference.audioMuted = muted;
  256. });
  257. APP.UI.addListener(UIEvents.VIDEO_MUTED, function (muted) {
  258. // FIXME mute or unmute
  259. APP.UI.setVideoMuted(muted);
  260. APP.conference.videoMuted = muted;
  261. });
  262. room.on(ConferenceEvents.IN_LAST_N_CHANGED, function (inLastN) {
  263. if (config.muteLocalVideoIfNotInLastN) {
  264. // TODO mute or unmute if required
  265. // mark video on UI
  266. // APP.UI.markVideoMuted(true/false);
  267. }
  268. });
  269. room.on(ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, function (ids) {
  270. APP.UI.handleLastNEndpoints(ids);
  271. });
  272. room.on(ConferenceEvents.ACTIVE_SPEAKER_CHANGED, function (id) {
  273. APP.UI.markDominantSpiker(id);
  274. });
  275. if (!interfaceConfig.filmStripOnly) {
  276. room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
  277. APP.UI.markVideoInterrupted(true);
  278. });
  279. room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
  280. APP.UI.markVideoInterrupted(false);
  281. });
  282. APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
  283. room.sendTextMessage(message);
  284. });
  285. room.on(ConferenceEvents.MESSAGE_RECEIVED, function (id, text, ts) {
  286. APP.UI.addMessage(id, getDisplayName(id), text, ts);
  287. });
  288. }
  289. APP.connectionquality.addListener(
  290. CQEvents.LOCALSTATS_UPDATED,
  291. function (percent, stats) {
  292. APP.UI.updateLocalStats(percent, stats);
  293. // send local stats to other users
  294. room.sendCommand(Commands.CONNECTION_QUALITY, {
  295. value: APP.connectionquality.convertToMUCStats(stats),
  296. attributes: {
  297. id: room.myUserId()
  298. }
  299. });
  300. }
  301. );
  302. APP.connectionquality.addListener(CQEvents.STOP, function () {
  303. APP.UI.hideStats();
  304. room.removeCommand(Commands.CONNECTION_QUALITY);
  305. });
  306. // listen to remote stats
  307. room.addCommandListener(
  308. Commands.CONNECTION_QUALITY,
  309. function ({value, attributes}) {
  310. APP.connectionquality.updateRemoteStats(attributes.id, value);
  311. }
  312. );
  313. APP.connectionquality.addListener(
  314. CQEvents.REMOTESTATS_UPDATED,
  315. function (id, percent, stats) {
  316. APP.UI.updateRemoteStats(id, percent, stats);
  317. }
  318. );
  319. room.addCommandListener(Commands.ETHERPAD, function ({value}) {
  320. APP.UI.initEtherpad(value);
  321. });
  322. room.addCommandListener(Commands.PREZI, function ({value, attributes}) {
  323. APP.UI.showPrezi(attributes.id, value, attributes.slide);
  324. });
  325. room.addCommandListener(Commands.STOP_PREZI, function ({attributes}) {
  326. APP.UI.stopPrezi(attributes.id);
  327. });
  328. APP.UI.addListener(UIEvents.SHARE_PREZI, function (url, slide) {
  329. console.log('Sharing Prezi %s slide %s', url, slide);
  330. room.removeCommand(Commands.PREZI);
  331. room.sendCommand(Commands.PREZI, {
  332. value: url,
  333. attributes: {
  334. id: room.myUserId(),
  335. slide
  336. }
  337. });
  338. });
  339. APP.UI.addListener(UIEvents.STOP_SHARING_PREZI, function () {
  340. room.removeCommand(Commands.PREZI);
  341. room.sendCommandOnce(Commands.STOP_PREZI, {
  342. attributes: {
  343. id: room.myUserId()
  344. }
  345. });
  346. });
  347. room.addCommandListener(Commands.VIDEO_TYPE, (data, from) => {
  348. APP.UI.onPeerVideoTypeChanged(from, data.value);
  349. });
  350. // share email with other users
  351. function sendEmail(email) {
  352. room.sendCommand(Commands.EMAIL, {
  353. value: email,
  354. attributes: {
  355. id: room.myUserId()
  356. }
  357. });
  358. }
  359. var email = APP.settings.getEmail();
  360. email && sendEmail(email);
  361. APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
  362. APP.settings.setEmail(email);
  363. APP.UI.setUserAvatar(room.myUserId(), email);
  364. sendEmail(email);
  365. });
  366. room.addCommandListener(Commands.EMAIL, function (data) {
  367. APP.UI.setUserAvatar(data.attributes.id, data.value);
  368. });
  369. let nick = APP.settings.getDisplayName();
  370. if (config.useNicks && !nick) {
  371. nick = APP.UI.askForNickname();
  372. APP.settings.setDisplayName(nick);
  373. }
  374. if (nick) {
  375. room.setDisplayName(nick);
  376. }
  377. room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
  378. APP.UI.changeDisplayName(id, displayName);
  379. });
  380. APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
  381. APP.settings.setDisplayName(nickname);
  382. room.setDisplayName(nickname);
  383. APP.UI.changeDisplayName(APP.conference.localId, nickname);
  384. });
  385. APP.UI.addListener(
  386. UIEvents.START_MUTED_CHANGED,
  387. function (startAudioMuted, startVideoMuted) {
  388. // FIXME start muted
  389. }
  390. );
  391. APP.UI.addListener(UIEvents.USER_INVITED, function (roomUrl) {
  392. APP.UI.inviteParticipants(
  393. roomUrl,
  394. APP.conference.roomName,
  395. roomLocker.password,
  396. APP.settings.getDisplayName()
  397. );
  398. });
  399. // call hangup
  400. APP.UI.addListener(UIEvents.HANGUP, function () {
  401. APP.UI.requestFeedback().then(function () {
  402. connection.disconnect();
  403. if (config.enableWelcomePage) {
  404. setTimeout(function() {
  405. window.localStorage.welcomePageDisabled = false;
  406. window.location.pathname = "/";
  407. }, 3000);
  408. }
  409. });
  410. });
  411. // logout
  412. APP.UI.addListener(UIEvents.LOGOUT, function () {
  413. // FIXME handle logout
  414. // APP.xmpp.logout(function (url) {
  415. // if (url) {
  416. // window.location.href = url;
  417. // } else {
  418. // hangup();
  419. // }
  420. // });
  421. });
  422. APP.UI.addListener(UIEvents.SIP_DIAL, function (sipNumber) {
  423. room.dial(sipNumber);
  424. });
  425. // Starts or stops the recording for the conference.
  426. APP.UI.addListener(UIEvents.RECORDING_TOGGLE, function (predefinedToken) {
  427. // FIXME recording
  428. // APP.xmpp.toggleRecording(function (callback) {
  429. // if (predefinedToken) {
  430. // callback(predefinedToken);
  431. // return;
  432. // }
  433. // APP.UI.requestRecordingToken().then(callback);
  434. // }, APP.UI.updateRecordingState);
  435. });
  436. APP.UI.addListener(UIEvents.TOPIC_CHANGED, function (topic) {
  437. // FIXME handle topic change
  438. // APP.xmpp.setSubject(topic);
  439. // on SUBJECT_CHANGED UI.setSubject(topic);
  440. });
  441. APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
  442. room.kickParticipant(id);
  443. });
  444. room.on(ConferenceEvents.KICKED, function () {
  445. APP.UI.notifyKicked();
  446. // FIXME close
  447. });
  448. APP.UI.addListener(UIEvents.AUTH_CLICKED, function () {
  449. AuthHandler.authenticate(room);
  450. });
  451. APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, function (id) {
  452. room.selectParticipant(id);
  453. });
  454. room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
  455. APP.UI.updateDTMFSupport(isDTMFSupported);
  456. });
  457. $(window).bind('beforeunload', function () {
  458. room.leave();
  459. });
  460. return new Promise(function (resolve, reject) {
  461. room.on(ConferenceEvents.CONFERENCE_JOINED, handleConferenceJoined);
  462. room.on(ConferenceEvents.CONFERENCE_FAILED, onConferenceFailed);
  463. let password;
  464. let reconnectTimeout;
  465. function unsubscribe() {
  466. room.off(
  467. ConferenceEvents.CONFERENCE_JOINED, handleConferenceJoined
  468. );
  469. room.off(
  470. ConferenceEvents.CONFERENCE_FAILED, onConferenceFailed
  471. );
  472. if (reconnectTimeout) {
  473. clearTimeout(reconnectTimeout);
  474. }
  475. AuthHandler.closeAuth();
  476. }
  477. function handleConferenceJoined() {
  478. unsubscribe();
  479. resolve();
  480. }
  481. function handleConferenceFailed(err) {
  482. unsubscribe();
  483. reject(err);
  484. }
  485. function onConferenceFailed(err, msg = '') {
  486. console.error('CONFERENCE FAILED:', err, msg);
  487. switch (err) {
  488. // room is locked by the password
  489. case ConferenceErrors.PASSWORD_REQUIRED:
  490. APP.UI.markRoomLocked(true);
  491. roomLocker.requirePassword().then(function () {
  492. room.join(roomLocker.password);
  493. });
  494. break;
  495. case ConferenceErrors.CONNECTION_ERROR:
  496. APP.UI.notifyConnectionFailed(msg);
  497. break;
  498. // not enough rights to create conference
  499. case ConferenceErrors.AUTHENTICATION_REQUIRED:
  500. // schedule reconnect to check if someone else created the room
  501. reconnectTimeout = setTimeout(function () {
  502. room.join(password);
  503. }, 5000);
  504. // notify user that auth is required
  505. AuthHandler.requireAuth(APP.conference.roomName);
  506. break;
  507. default:
  508. handleConferenceFailed(err);
  509. }
  510. }
  511. room.join(password);
  512. });
  513. }
  514. function createLocalTracks () {
  515. return JitsiMeetJS.createLocalTracks({
  516. devices: ['audio', 'video']
  517. }).catch(function (err) {
  518. console.error('failed to create local tracks', err);
  519. return [];
  520. });
  521. }
  522. function connect() {
  523. return openConnection({retry: true}).catch(function (err) {
  524. if (err === ConnectionErrors.PASSWORD_REQUIRED) {
  525. APP.UI.notifyTokenAuthFailed();
  526. } else {
  527. APP.UI.notifyConnectionFailed(err);
  528. }
  529. throw err;
  530. });
  531. }
  532. function init() {
  533. APP.UI.start();
  534. JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
  535. JitsiMeetJS.init(config).then(function () {
  536. return Promise.all([createLocalTracks(), connect()]);
  537. }).then(function ([tracks, connection]) {
  538. console.log('initialized with %s local tracks', tracks.length);
  539. return initConference(tracks, connection);
  540. }).then(function () {
  541. APP.UI.initConference();
  542. APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
  543. APP.translation.setLanguage(language);
  544. APP.settings.setLanguage(language);
  545. });
  546. APP.desktopsharing.addListener(
  547. DesktopSharingEventTypes.NEW_STREAM_CREATED,
  548. (stream, callback) => {
  549. APP.conference.changeLocalVideo(stream,
  550. callback);
  551. });
  552. APP.desktopsharing.init(JitsiMeetJS.isDesktopSharingEnabled());
  553. APP.statistics.start();
  554. APP.connectionquality.init();
  555. APP.keyboardshortcut.init();
  556. }).catch(function (err) {
  557. console.error(err);
  558. });
  559. }
  560. /**
  561. * If we have an HTTP endpoint for getting config.json configured we're going to
  562. * read it and override properties from config.js and interfaceConfig.js.
  563. * If there is no endpoint we'll just continue with initialization.
  564. * Keep in mind that if the endpoint has been configured and we fail to obtain
  565. * the config for any reason then the conference won't start and error message
  566. * will be displayed to the user.
  567. */
  568. function obtainConfigAndInit() {
  569. let roomName = APP.conference.roomName;
  570. if (config.configLocation) {
  571. APP.configFetch.obtainConfig(
  572. config.configLocation, roomName,
  573. // Get config result callback
  574. function(success, error) {
  575. if (success) {
  576. console.log("(TIME) configuration fetched:\t",
  577. window.performance.now());
  578. init();
  579. } else {
  580. // Show obtain config error,
  581. // pass the error object for report
  582. APP.UI.messageHandler.openReportDialog(
  583. null, "dialog.connectError", error);
  584. }
  585. });
  586. } else {
  587. require("./modules/config/BoshAddressChoice").chooseAddress(
  588. config, roomName);
  589. init();
  590. }
  591. }
  592. $(document).ready(function () {
  593. console.log("(TIME) document ready:\t", window.performance.now());
  594. URLProcessor.setConfigParametersFromUrl();
  595. APP.init();
  596. APP.translation.init();
  597. if (APP.API.isEnabled()) {
  598. APP.API.init();
  599. }
  600. obtainConfigAndInit();
  601. });
  602. $(window).bind('beforeunload', function () {
  603. if (APP.API.isEnabled()) {
  604. APP.API.dispose();
  605. }
  606. });
  607. module.exports = APP;