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 21KB

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