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.

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