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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var UI = {};
  4. import Chat from "./side_pannels/chat/Chat";
  5. import SidePanels from "./side_pannels/SidePanels";
  6. import Avatar from "./avatar/Avatar";
  7. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  8. import JitsiPopover from "./util/JitsiPopover";
  9. import messageHandler from "./util/MessageHandler";
  10. import UIUtil from "./util/UIUtil";
  11. import UIEvents from "../../service/UI/UIEvents";
  12. import EtherpadManager from './etherpad/Etherpad';
  13. import SharedVideoManager from './shared_video/SharedVideo';
  14. import Recording from "./recording/Recording";
  15. import VideoLayout from "./videolayout/VideoLayout";
  16. import Filmstrip from "./videolayout/Filmstrip";
  17. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  18. import Profile from "./side_pannels/profile/Profile";
  19. import Settings from "./../settings/Settings";
  20. import { FEEDBACK_REQUEST_IN_PROGRESS } from './UIErrors';
  21. import { debounce } from "../util/helpers";
  22. import { updateDeviceList } from '../../react/features/base/devices';
  23. import { setAudioMuted, setVideoMuted } from '../../react/features/base/media';
  24. import {
  25. openDeviceSelectionDialog
  26. } from '../../react/features/device-selection';
  27. import {
  28. checkAutoEnableDesktopSharing,
  29. dockToolbox,
  30. setAudioIconEnabled,
  31. setToolbarButton,
  32. showDialPadButton,
  33. showEtherpadButton,
  34. showSharedVideoButton,
  35. showDialOutButton,
  36. showToolbox
  37. } from '../../react/features/toolbox';
  38. var EventEmitter = require("events");
  39. UI.messageHandler = messageHandler;
  40. import Feedback from "./feedback/Feedback";
  41. import FollowMe from "../FollowMe";
  42. var eventEmitter = new EventEmitter();
  43. UI.eventEmitter = eventEmitter;
  44. /**
  45. * Whether an overlay is visible or not.
  46. *
  47. * FIXME: This is temporary solution. Don't use this variable!
  48. * Should be removed when all the code is move to react.
  49. *
  50. * @type {boolean}
  51. * @public
  52. */
  53. UI.overlayVisible = false;
  54. let etherpadManager;
  55. let sharedVideoManager;
  56. let followMeHandler;
  57. let deviceErrorDialog;
  58. const TrackErrors = JitsiMeetJS.errors.track;
  59. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  60. microphone: {},
  61. camera: {}
  62. };
  63. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  64. = "dialog.cameraUnsupportedResolutionError";
  65. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  66. = "dialog.cameraUnknownError";
  67. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  68. = "dialog.cameraPermissionDeniedError";
  69. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  70. = "dialog.cameraNotFoundError";
  71. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  72. = "dialog.cameraConstraintFailedError";
  73. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  74. = "dialog.cameraNotSendingData";
  75. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  76. = "dialog.micUnknownError";
  77. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  78. = "dialog.micPermissionDeniedError";
  79. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  80. = "dialog.micNotFoundError";
  81. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  82. = "dialog.micConstraintFailedError";
  83. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  84. = "dialog.micNotSendingData";
  85. /**
  86. * Toggles the application in and out of full screen mode
  87. * (a.k.a. presentation mode in Chrome).
  88. */
  89. UI.toggleFullScreen = function() {
  90. (UIUtil.isFullScreen())
  91. ? UIUtil.exitFullScreen()
  92. : UIUtil.enterFullScreen();
  93. };
  94. /**
  95. * Notify user that server has shut down.
  96. */
  97. UI.notifyGracefulShutdown = function () {
  98. messageHandler.openMessageDialog(
  99. 'dialog.serviceUnavailable',
  100. 'dialog.gracefulShutdown'
  101. );
  102. };
  103. /**
  104. * Notify user that reservation error happened.
  105. */
  106. UI.notifyReservationError = function (code, msg) {
  107. var message = APP.translation.generateTranslationHTML(
  108. "dialog.reservationErrorMsg", {code: code, msg: msg});
  109. messageHandler.openDialog(
  110. "dialog.reservationError", message, true, {}, () => false);
  111. };
  112. /**
  113. * Notify user that he has been kicked from the server.
  114. */
  115. UI.notifyKicked = function () {
  116. messageHandler.openMessageDialog(
  117. "dialog.sessTerminated",
  118. "dialog.kickMessage");
  119. };
  120. /**
  121. * Notify user that conference was destroyed.
  122. * @param reason {string} the reason text
  123. */
  124. UI.notifyConferenceDestroyed = function (reason) {
  125. //FIXME: use Session Terminated from translation, but
  126. // 'reason' text comes from XMPP packet and is not translated
  127. messageHandler.openDialog(
  128. "dialog.sessTerminated", reason, true, {}, () => false);
  129. };
  130. /**
  131. * Show chat error.
  132. * @param err the Error
  133. * @param msg
  134. */
  135. UI.showChatError = function (err, msg) {
  136. if (interfaceConfig.filmStripOnly) {
  137. return;
  138. }
  139. Chat.chatAddError(err, msg);
  140. };
  141. /**
  142. * Change nickname for the user.
  143. * @param {string} id user id
  144. * @param {string} displayName new nickname
  145. */
  146. UI.changeDisplayName = function (id, displayName) {
  147. if (UI.ContactList)
  148. UI.ContactList.onDisplayNameChange(id, displayName);
  149. VideoLayout.onDisplayNameChanged(id, displayName);
  150. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  151. Profile.changeDisplayName(displayName);
  152. Chat.setChatConversationMode(!!displayName);
  153. }
  154. };
  155. /**
  156. * Shows/hides the indication about local connection being interrupted.
  157. *
  158. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  159. * currently in the interrupted state or <tt>false</tt> if the connection
  160. * is fine.
  161. */
  162. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  163. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  164. };
  165. /**
  166. * Sets the "raised hand" status for a participant.
  167. */
  168. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  169. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  170. if (raisedHandStatus) {
  171. messageHandler.participantNotification(participant.getDisplayName(),
  172. 'notify.somebody', 'connected', 'notify.raisedHand');
  173. }
  174. };
  175. /**
  176. * Sets the local "raised hand" status.
  177. */
  178. UI.setLocalRaisedHandStatus
  179. = raisedHandStatus =>
  180. VideoLayout.setRaisedHandStatus(
  181. APP.conference.getMyUserId(),
  182. raisedHandStatus);
  183. /**
  184. * Initialize conference UI.
  185. */
  186. UI.initConference = function () {
  187. let id = APP.conference.getMyUserId();
  188. // Add myself to the contact list.
  189. if (UI.ContactList)
  190. UI.ContactList.addContact(id, true);
  191. // Update default button states before showing the toolbar
  192. // if local role changes buttons state will be again updated.
  193. UI.updateLocalRole(APP.conference.isModerator);
  194. UI.showToolbar();
  195. let displayName = config.displayJids ? id : Settings.getDisplayName();
  196. if (displayName) {
  197. UI.changeDisplayName('localVideoContainer', displayName);
  198. }
  199. // Make sure we configure our avatar id, before creating avatar for us
  200. let email = Settings.getEmail();
  201. if (email) {
  202. UI.setUserEmail(id, email);
  203. } else {
  204. UI.setUserAvatarID(id, Settings.getAvatarId());
  205. }
  206. APP.store.dispatch(checkAutoEnableDesktopSharing());
  207. if(!interfaceConfig.filmStripOnly) {
  208. Feedback.init(eventEmitter);
  209. }
  210. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  211. // other participants' UI. Consequently, it needs (1) read and write access
  212. // to the UI (depending on the moderator role of the local participant) and
  213. // (2) APP.conference as means of communication between the participants.
  214. followMeHandler = new FollowMe(APP.conference, UI);
  215. UIUtil.activateTooltips();
  216. };
  217. UI.mucJoined = function () {
  218. VideoLayout.mucJoined();
  219. // Update local video now that a conference is joined a user ID should be
  220. // set.
  221. UI.changeDisplayName('localVideoContainer', APP.settings.getDisplayName());
  222. };
  223. /***
  224. * Handler for toggling filmstrip
  225. */
  226. UI.handleToggleFilmstrip = () => UI.toggleFilmstrip();
  227. /**
  228. * Sets tooltip defaults.
  229. *
  230. * @private
  231. */
  232. function _setTooltipDefaults() {
  233. $.fn.tooltip.defaults = {
  234. opacity: 1, //defaults to 1
  235. offset: 1,
  236. delayIn: 0, //defaults to 500
  237. hoverable: true,
  238. hideOnClick: true,
  239. aria: true
  240. };
  241. }
  242. /**
  243. * Returns the shared document manager object.
  244. * @return {EtherpadManager} the shared document manager object
  245. */
  246. UI.getSharedVideoManager = function () {
  247. return sharedVideoManager;
  248. };
  249. /**
  250. * Starts the UI module and initializes all related components.
  251. *
  252. * @returns {boolean} true if the UI is ready and the conference should be
  253. * established, false - otherwise (for example in the case of welcome page)
  254. */
  255. UI.start = function () {
  256. document.title = interfaceConfig.APP_NAME;
  257. // Set the defaults for prompt dialogs.
  258. $.prompt.setDefaults({persistent: false});
  259. // Set the defaults for tooltips.
  260. _setTooltipDefaults();
  261. SideContainerToggler.init(eventEmitter);
  262. Filmstrip.init(eventEmitter);
  263. // By default start with remote videos hidden and rely on other logic to
  264. // make them visible.
  265. UI.setRemoteThumbnailsVisibility(false);
  266. VideoLayout.init(eventEmitter);
  267. if (!interfaceConfig.filmStripOnly) {
  268. VideoLayout.initLargeVideo();
  269. }
  270. VideoLayout.resizeVideoArea(true, true);
  271. sharedVideoManager = new SharedVideoManager(eventEmitter);
  272. if (!interfaceConfig.filmStripOnly) {
  273. let debouncedShowToolbar
  274. = debounce(
  275. () => UI.showToolbar(),
  276. 100,
  277. { leading: true, trailing: false });
  278. $("#videoconference_page").mousemove(debouncedShowToolbar);
  279. // Initialise the recording module.
  280. if (config.enableRecording) {
  281. Recording.init(eventEmitter, config.recordingType);
  282. }
  283. // Initialize side panels
  284. SidePanels.init(eventEmitter);
  285. } else {
  286. $("body").addClass("filmstrip-only");
  287. UI.showToolbar();
  288. Filmstrip.setFilmstripOnly();
  289. messageHandler.enableNotifications(false);
  290. JitsiPopover.enabled = false;
  291. }
  292. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  293. $("body").addClass("vertical-filmstrip");
  294. }
  295. document.title = interfaceConfig.APP_NAME;
  296. if (!interfaceConfig.filmStripOnly) {
  297. toastr.options = {
  298. "closeButton": true,
  299. "debug": false,
  300. "positionClass": "notification-bottom-right",
  301. "onclick": null,
  302. "showDuration": "300",
  303. "hideDuration": "1000",
  304. "timeOut": "2000",
  305. "extendedTimeOut": "1000",
  306. "showEasing": "swing",
  307. "hideEasing": "linear",
  308. "showMethod": "fadeIn",
  309. "hideMethod": "fadeOut",
  310. "newestOnTop": false,
  311. // this is the default toastr close button html, just adds tabIndex
  312. "closeHtml": '<button type="button" tabIndex="-1">&times;</button>'
  313. };
  314. }
  315. };
  316. /**
  317. * Invokes cleanup of any deferred execution within relevant UI modules.
  318. *
  319. * @returns {void}
  320. */
  321. UI.stopDaemons = () => {
  322. VideoLayout.resetLargeVideo();
  323. };
  324. /**
  325. * Setup some UI event listeners.
  326. */
  327. UI.registerListeners
  328. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  329. /**
  330. * Unregister some UI event listeners.
  331. */
  332. UI.unregisterListeners
  333. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  334. /**
  335. * Setup some DOM event listeners.
  336. */
  337. UI.bindEvents = () => {
  338. function onResize() {
  339. SideContainerToggler.resize();
  340. VideoLayout.resizeVideoArea();
  341. }
  342. // Resize and reposition videos in full screen mode.
  343. $(document).on(
  344. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  345. () => {
  346. eventEmitter.emit(
  347. UIEvents.FULLSCREEN_TOGGLED,
  348. UIUtil.isFullScreen());
  349. onResize();
  350. });
  351. $(window).resize(onResize);
  352. };
  353. /**
  354. * Unbind some DOM event listeners.
  355. */
  356. UI.unbindEvents = () => {
  357. $(document).off(
  358. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  359. $(window).off('resize');
  360. };
  361. /**
  362. * Show local stream on UI.
  363. * @param {JitsiTrack} track stream to show
  364. */
  365. UI.addLocalStream = track => {
  366. switch (track.getType()) {
  367. case 'audio':
  368. VideoLayout.changeLocalAudio(track);
  369. break;
  370. case 'video':
  371. VideoLayout.changeLocalVideo(track);
  372. break;
  373. default:
  374. logger.error("Unknown stream type: " + track.getType());
  375. break;
  376. }
  377. };
  378. /**
  379. * Show remote stream on UI.
  380. * @param {JitsiTrack} track stream to show
  381. */
  382. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  383. /**
  384. * Removed remote stream from UI.
  385. * @param {JitsiTrack} track stream to remove
  386. */
  387. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  388. /**
  389. * Update chat subject.
  390. * @param {string} subject new chat subject
  391. */
  392. UI.setSubject = subject => Chat.setSubject(subject);
  393. /**
  394. * Setup and show Etherpad.
  395. * @param {string} name etherpad id
  396. */
  397. UI.initEtherpad = name => {
  398. if (etherpadManager || !config.etherpad_base || !name) {
  399. return;
  400. }
  401. logger.log('Etherpad is enabled');
  402. etherpadManager
  403. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  404. APP.store.dispatch(showEtherpadButton());
  405. };
  406. /**
  407. * Returns the shared document manager object.
  408. * @return {EtherpadManager} the shared document manager object
  409. */
  410. UI.getSharedDocumentManager = () => etherpadManager;
  411. /**
  412. * Show user on UI.
  413. * @param {JitsiParticipant} user
  414. */
  415. UI.addUser = function (user) {
  416. var id = user.getId();
  417. var displayName = user.getDisplayName();
  418. if (UI.ContactList)
  419. UI.ContactList.addContact(id);
  420. messageHandler.participantNotification(
  421. displayName,'notify.somebody', 'connected', 'notify.connected'
  422. );
  423. if (!config.startAudioMuted ||
  424. config.startAudioMuted > APP.conference.membersCount)
  425. UIUtil.playSoundNotification('userJoined');
  426. // Add Peer's container
  427. VideoLayout.addParticipantContainer(user);
  428. // Configure avatar
  429. UI.setUserEmail(id);
  430. // set initial display name
  431. if(displayName)
  432. UI.changeDisplayName(id, displayName);
  433. };
  434. /**
  435. * Remove user from UI.
  436. * @param {string} id user id
  437. * @param {string} displayName user nickname
  438. */
  439. UI.removeUser = function (id, displayName) {
  440. if (UI.ContactList)
  441. UI.ContactList.removeContact(id);
  442. messageHandler.participantNotification(
  443. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  444. );
  445. if (!config.startAudioMuted
  446. || config.startAudioMuted > APP.conference.membersCount) {
  447. UIUtil.playSoundNotification('userLeft');
  448. }
  449. VideoLayout.removeParticipantContainer(id);
  450. };
  451. /**
  452. * Update videotype for specified user.
  453. * @param {string} id user id
  454. * @param {string} newVideoType new videotype
  455. */
  456. UI.onPeerVideoTypeChanged
  457. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  458. /**
  459. * Update local user role and show notification if user is moderator.
  460. * @param {boolean} isModerator if local user is moderator or not
  461. */
  462. UI.updateLocalRole = isModerator => {
  463. VideoLayout.showModeratorIndicator();
  464. APP.store.dispatch(showDialOutButton(isModerator));
  465. APP.store.dispatch(showSharedVideoButton());
  466. Recording.showRecordingButton(isModerator);
  467. SettingsMenu.showStartMutedOptions(isModerator);
  468. SettingsMenu.showFollowMeOptions(isModerator);
  469. if (isModerator) {
  470. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  471. messageHandler.participantNotification(
  472. null, "notify.me", 'connected', "notify.moderator");
  473. Recording.checkAutoRecord();
  474. }
  475. };
  476. /**
  477. * Check the role for the user and reflect it in the UI, moderator ui indication
  478. * and notifies user who is the moderator
  479. * @param user to check for moderator
  480. */
  481. UI.updateUserRole = user => {
  482. VideoLayout.showModeratorIndicator();
  483. // We don't need to show moderator notifications when the focus (moderator)
  484. // indicator is disabled.
  485. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  486. return;
  487. }
  488. var displayName = user.getDisplayName();
  489. if (displayName) {
  490. messageHandler.participantNotification(
  491. displayName, 'notify.somebody',
  492. 'connected', 'notify.grantedTo', {
  493. to: UIUtil.escapeHtml(displayName)
  494. }
  495. );
  496. } else {
  497. messageHandler.participantNotification(
  498. '', 'notify.somebody',
  499. 'connected', 'notify.grantedToUnknown');
  500. }
  501. };
  502. /**
  503. * Updates the user status.
  504. *
  505. * @param {JitsiParticipant} user - The user which status we need to update.
  506. * @param {string} status - The new status.
  507. */
  508. UI.updateUserStatus = (user, status) => {
  509. let displayName = user.getDisplayName();
  510. messageHandler.participantNotification(
  511. displayName, '', 'connected', "dialOut.statusMessage",
  512. {
  513. status: UIUtil.escapeHtml(status)
  514. });
  515. };
  516. /**
  517. * Toggles smileys in the chat.
  518. */
  519. UI.toggleSmileys = () => Chat.toggleSmileys();
  520. /**
  521. * Toggles filmstrip.
  522. */
  523. UI.toggleFilmstrip = function () {
  524. var self = Filmstrip;
  525. self.toggleFilmstrip.apply(self, arguments);
  526. VideoLayout.resizeVideoArea(true, false);
  527. };
  528. /**
  529. * Indicates if the filmstrip is currently visible or not.
  530. * @returns {true} if the filmstrip is currently visible, otherwise
  531. */
  532. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  533. /**
  534. * Toggles chat panel.
  535. */
  536. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  537. /**
  538. * Toggles contact list panel.
  539. */
  540. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  541. /**
  542. * Toggles the given side panel.
  543. *
  544. * @param {String} sidePanelId the identifier of the side panel to toggle
  545. */
  546. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  547. /**
  548. * Handle new user display name.
  549. */
  550. UI.inputDisplayNameHandler = function (newDisplayName) {
  551. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  552. };
  553. /**
  554. * Show custom popup/tooltip for a specified button.
  555. * @param popupSelectorID the selector id of the popup to show
  556. * @param show true or false/show or hide the popup
  557. * @param timeout the time to show the popup
  558. */
  559. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  560. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  561. popupSelectorID, show, timeout);
  562. };
  563. /**
  564. * Return the type of the remote video.
  565. * @param jid the jid for the remote video
  566. * @returns the video type video or screen.
  567. */
  568. UI.getRemoteVideoType = function (jid) {
  569. return VideoLayout.getRemoteVideoType(jid);
  570. };
  571. // FIXME check if someone user this
  572. UI.showLoginPopup = function(callback) {
  573. logger.log('password is required');
  574. let message = (
  575. `<input name="username" type="text"
  576. placeholder="user@domain.net"
  577. class="input-control" autofocus>
  578. <input name="password" type="password"
  579. data-i18n="[placeholder]dialog.userPassword"
  580. class="input-control"
  581. placeholder="user password">`
  582. );
  583. let submitFunction = (e, v, m, f) => {
  584. if (v) {
  585. if (f.username && f.password) {
  586. callback(f.username, f.password);
  587. }
  588. }
  589. };
  590. messageHandler.openTwoButtonDialog({
  591. titleKey : "dialog.passwordRequired",
  592. msgString: message,
  593. leftButtonKey: 'dialog.Ok',
  594. submitFunction,
  595. focus: ':input:first'
  596. });
  597. };
  598. UI.askForNickname = function () {
  599. return window.prompt('Your nickname (optional)');
  600. };
  601. /**
  602. * Sets muted audio state for participant
  603. */
  604. UI.setAudioMuted = function (id, muted) {
  605. VideoLayout.onAudioMute(id, muted);
  606. if (APP.conference.isLocalId(id)) {
  607. APP.store.dispatch(setAudioMuted(muted));
  608. APP.store.dispatch(setToolbarButton('microphone', {
  609. toggled: muted
  610. }));
  611. }
  612. };
  613. /**
  614. * Sets muted video state for participant
  615. */
  616. UI.setVideoMuted = function (id, muted) {
  617. VideoLayout.onVideoMute(id, muted);
  618. if (APP.conference.isLocalId(id)) {
  619. APP.store.dispatch(setVideoMuted(muted));
  620. }
  621. };
  622. /**
  623. * Triggers an update of remote video and large video displays so they may pick
  624. * up any state changes that have occurred elsewhere.
  625. *
  626. * @returns {void}
  627. */
  628. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  629. /**
  630. * Adds a listener that would be notified on the given type of event.
  631. *
  632. * @param type the type of the event we're listening for
  633. * @param listener a function that would be called when notified
  634. */
  635. UI.addListener = function (type, listener) {
  636. eventEmitter.on(type, listener);
  637. };
  638. /**
  639. * Removes the given listener for the given type of event.
  640. *
  641. * @param type the type of the event we're listening for
  642. * @param listener the listener we want to remove
  643. */
  644. UI.removeListener = function (type, listener) {
  645. eventEmitter.removeListener(type, listener);
  646. };
  647. /**
  648. * Emits the event of given type by specifying the parameters in options.
  649. *
  650. * @param type the type of the event we're emitting
  651. * @param options the parameters for the event
  652. */
  653. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  654. UI.clickOnVideo = function (videoNumber) {
  655. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  656. let videosLength = videos.length;
  657. if(videosLength <= videoNumber) {
  658. return;
  659. }
  660. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  661. videos[videoIndex].click();
  662. };
  663. // Used by torture.
  664. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  665. // Used by torture.
  666. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  667. /**
  668. * Updates the avatar for participant.
  669. * @param {string} id user id
  670. * @param {string} avatarUrl the URL for the avatar
  671. */
  672. function changeAvatar(id, avatarUrl) {
  673. VideoLayout.changeUserAvatar(id, avatarUrl);
  674. if (UI.ContactList)
  675. UI.ContactList.changeUserAvatar(id, avatarUrl);
  676. if (APP.conference.isLocalId(id)) {
  677. Profile.changeAvatar(avatarUrl);
  678. }
  679. }
  680. /**
  681. * Update user email.
  682. * @param {string} id user id
  683. * @param {string} email user email
  684. */
  685. UI.setUserEmail = function (id, email) {
  686. // update avatar
  687. Avatar.setUserEmail(id, email);
  688. changeAvatar(id, Avatar.getAvatarUrl(id));
  689. if (APP.conference.isLocalId(id)) {
  690. Profile.changeEmail(email);
  691. }
  692. };
  693. /**
  694. * Update user avtar id.
  695. * @param {string} id user id
  696. * @param {string} avatarId user's avatar id
  697. */
  698. UI.setUserAvatarID = function (id, avatarId) {
  699. // update avatar
  700. Avatar.setUserAvatarID(id, avatarId);
  701. changeAvatar(id, Avatar.getAvatarUrl(id));
  702. };
  703. /**
  704. * Update user avatar URL.
  705. * @param {string} id user id
  706. * @param {string} url user avatar url
  707. */
  708. UI.setUserAvatarUrl = function (id, url) {
  709. // update avatar
  710. Avatar.setUserAvatarUrl(id, url);
  711. changeAvatar(id, Avatar.getAvatarUrl(id));
  712. };
  713. /**
  714. * Notify user that connection failed.
  715. * @param {string} stropheErrorMsg raw Strophe error message
  716. */
  717. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  718. var message;
  719. if (stropheErrorMsg) {
  720. message = APP.translation.generateTranslationHTML(
  721. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  722. } else {
  723. message = APP.translation.generateTranslationHTML(
  724. "dialog.connectError");
  725. }
  726. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  727. };
  728. /**
  729. * Notify user that maximum users limit has been reached.
  730. */
  731. UI.notifyMaxUsersLimitReached = function () {
  732. var message = APP.translation.generateTranslationHTML(
  733. "dialog.maxUsersLimitReached");
  734. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  735. };
  736. /**
  737. * Notify user that he was automatically muted when joned the conference.
  738. */
  739. UI.notifyInitiallyMuted = function () {
  740. messageHandler.participantNotification(
  741. null,
  742. "notify.mutedTitle",
  743. "connected",
  744. "notify.muted",
  745. null,
  746. { timeOut: 120000 });
  747. };
  748. /**
  749. * Mark user as dominant speaker.
  750. * @param {string} id user id
  751. */
  752. UI.markDominantSpeaker = function (id) {
  753. VideoLayout.onDominantSpeakerChanged(id);
  754. };
  755. UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
  756. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  757. };
  758. /**
  759. * Will handle notification about participant's connectivity status change.
  760. *
  761. * @param {string} id the id of remote participant(MUC jid)
  762. */
  763. UI.participantConnectionStatusChanged = function (id) {
  764. VideoLayout.onParticipantConnectionStatusChanged(id);
  765. };
  766. /**
  767. * Prompt user for nickname.
  768. */
  769. UI.promptDisplayName = () => {
  770. const labelKey = 'dialog.enterDisplayName';
  771. const message = (
  772. `<div class="form-control">
  773. <label data-i18n="${labelKey}" class="form-control__label"></label>
  774. <input name="displayName" type="text"
  775. data-i18n="[placeholder]defaultNickname"
  776. class="input-control" autofocus>
  777. </div>`
  778. );
  779. // Don't use a translation string, because we're too early in the call and
  780. // the translation may not be initialised.
  781. const buttons = { Ok: true };
  782. const dialog = messageHandler.openDialog(
  783. 'dialog.displayNameRequired',
  784. message,
  785. true,
  786. buttons,
  787. (e, v, m, f) => {
  788. e.preventDefault();
  789. if (v) {
  790. const displayName = f.displayName;
  791. if (displayName) {
  792. UI.inputDisplayNameHandler(displayName);
  793. dialog.close();
  794. return;
  795. }
  796. }
  797. },
  798. () => {
  799. const form = $.prompt.getPrompt();
  800. const input = form.find("input[name='displayName']");
  801. const button = form.find("button");
  802. input.focus();
  803. button.attr("disabled", "disabled");
  804. input.keyup(() => {
  805. if (input.val()) {
  806. button.removeAttr("disabled");
  807. } else {
  808. button.attr("disabled", "disabled");
  809. }
  810. });
  811. }
  812. );
  813. };
  814. /**
  815. * Update audio level visualization for specified user.
  816. * @param {string} id user id
  817. * @param {number} lvl audio level
  818. */
  819. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  820. /**
  821. * Update state of desktop sharing buttons.
  822. *
  823. * @returns {void}
  824. */
  825. UI.updateDesktopSharingButtons
  826. = () =>
  827. APP.store.dispatch(setToolbarButton('desktop', {
  828. toggled: APP.conference.isSharingScreen
  829. }));
  830. /**
  831. * Hide connection quality statistics from UI.
  832. */
  833. UI.hideStats = function () {
  834. VideoLayout.hideStats();
  835. };
  836. /**
  837. * Mark video as interrupted or not.
  838. * @param {boolean} interrupted if video is interrupted
  839. */
  840. UI.markVideoInterrupted = function (interrupted) {
  841. if (interrupted) {
  842. VideoLayout.onVideoInterrupted();
  843. } else {
  844. VideoLayout.onVideoRestored();
  845. }
  846. };
  847. /**
  848. * Add chat message.
  849. * @param {string} from user id
  850. * @param {string} displayName user nickname
  851. * @param {string} message message text
  852. * @param {number} stamp timestamp when message was created
  853. */
  854. UI.addMessage = function (from, displayName, message, stamp) {
  855. Chat.updateChatConversation(from, displayName, message, stamp);
  856. };
  857. UI.updateDTMFSupport
  858. = isDTMFSupported => APP.store.dispatch(showDialPadButton(isDTMFSupported));
  859. /**
  860. * Show user feedback dialog if its required and enabled after pressing the
  861. * hangup button.
  862. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  863. * resolved with true if the dialog is disabled or the feedback was already
  864. * submitted. Rejected if another dialog is already displayed. This values are
  865. * used to display or not display the thank you dialog from
  866. * conference.maybeRedirectToWelcomePage method.
  867. */
  868. UI.requestFeedbackOnHangup = function () {
  869. if (Feedback.isVisible())
  870. return Promise.reject(FEEDBACK_REQUEST_IN_PROGRESS);
  871. // Feedback has been submitted already.
  872. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  873. return Promise.resolve({
  874. thankYouDialogVisible : true,
  875. feedbackSubmitted: true
  876. });
  877. }
  878. else
  879. return new Promise(function (resolve) {
  880. if (Feedback.isEnabled()) {
  881. Feedback.openFeedbackWindow(
  882. (options) => {
  883. options.thankYouDialogVisible = false;
  884. resolve(options);
  885. });
  886. } else {
  887. // If the feedback functionality isn't enabled we show a thank
  888. // you dialog. Signaling it (true), so the caller
  889. // of requestFeedback can act on it
  890. resolve(
  891. {thankYouDialogVisible : true, feedbackSubmitted: false});
  892. }
  893. });
  894. };
  895. UI.updateRecordingState = function (state) {
  896. Recording.updateRecordingState(state);
  897. };
  898. UI.notifyTokenAuthFailed = function () {
  899. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  900. "dialog.tokenAuthFailed");
  901. };
  902. UI.notifyInternalError = function () {
  903. messageHandler.showError( "dialog.internalErrorTitle",
  904. "dialog.internalError");
  905. };
  906. UI.notifyFocusDisconnected = function (focus, retrySec) {
  907. messageHandler.participantNotification(
  908. null, "notify.focus",
  909. 'disconnected', "notify.focusFail",
  910. {component: focus, ms: retrySec}
  911. );
  912. };
  913. /**
  914. * Updates auth info on the UI.
  915. * @param {boolean} isAuthEnabled if authentication is enabled
  916. * @param {string} [login] current login
  917. */
  918. UI.updateAuthInfo = function (isAuthEnabled, login) {
  919. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  920. let loggedIn = !!login;
  921. Profile.showAuthenticationButtons(showAuth);
  922. if (showAuth) {
  923. Profile.setAuthenticatedIdentity(login);
  924. Profile.showLoginButton(!loggedIn);
  925. Profile.showLogoutButton(loggedIn);
  926. }
  927. };
  928. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  929. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  930. };
  931. /**
  932. * Notifies interested listeners that the raise hand property has changed.
  933. *
  934. * @param {boolean} isRaisedHand indicates the current state of the
  935. * "raised hand"
  936. */
  937. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  938. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  939. };
  940. /**
  941. * Update list of available physical devices.
  942. * @param {object[]} devices new list of available devices
  943. */
  944. UI.onAvailableDevicesChanged = function (devices) {
  945. APP.store.dispatch(updateDeviceList(devices));
  946. };
  947. /**
  948. * Returns the id of the current video shown on large.
  949. * Currently used by tests (torture).
  950. */
  951. UI.getLargeVideoID = function () {
  952. return VideoLayout.getLargeVideoID();
  953. };
  954. /**
  955. * Returns the current video shown on large.
  956. * Currently used by tests (torture).
  957. */
  958. UI.getLargeVideo = function () {
  959. return VideoLayout.getLargeVideo();
  960. };
  961. /**
  962. * Returns whether or not the passed in user id is currently pinned to the large
  963. * video.
  964. *
  965. * @param {string} userId - The id of the user to check is pinned or not.
  966. * @returns {boolean} True if the user is currently pinned to the large video.
  967. */
  968. UI.isPinned = userId => VideoLayout.getPinnedId() === userId;
  969. /**
  970. * Shows dialog with a link to FF extension.
  971. */
  972. UI.showExtensionRequiredDialog = function (url) {
  973. messageHandler.openMessageDialog(
  974. "dialog.extensionRequired",
  975. "[html]dialog.firefoxExtensionPrompt",
  976. {url: url});
  977. };
  978. /**
  979. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  980. * 2 button dialog with buttons - cancel and go to web store.
  981. * @param url {string} the url of the extension.
  982. */
  983. UI.showExtensionExternalInstallationDialog = function (url) {
  984. let openedWindow = null;
  985. let submitFunction = function(e,v){
  986. if (v) {
  987. e.preventDefault();
  988. if (openedWindow === null || openedWindow.closed) {
  989. openedWindow
  990. = window.open(
  991. url,
  992. "extension_store_window",
  993. "resizable,scrollbars=yes,status=1");
  994. } else {
  995. openedWindow.focus();
  996. }
  997. }
  998. };
  999. let closeFunction = function (e, v) {
  1000. if (openedWindow) {
  1001. // Ideally we would close the popup, but this does not seem to work
  1002. // on Chrome. Leaving it uncommented in case it could work
  1003. // in some version.
  1004. openedWindow.close();
  1005. openedWindow = null;
  1006. }
  1007. if (!v) {
  1008. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1009. }
  1010. };
  1011. messageHandler.openTwoButtonDialog({
  1012. titleKey: 'dialog.externalInstallationTitle',
  1013. msgKey: 'dialog.externalInstallationMsg',
  1014. leftButtonKey: 'dialog.goToStore',
  1015. submitFunction,
  1016. loadedFunction: $.noop,
  1017. closeFunction
  1018. });
  1019. };
  1020. /**
  1021. * Shows a dialog which asks user to install the extension. This one is
  1022. * displayed after installation is triggered from the script, but fails because
  1023. * it must be initiated by user gesture.
  1024. * @param callback {function} function to be executed after user clicks
  1025. * the install button - it should make another attempt to install the extension.
  1026. */
  1027. UI.showExtensionInlineInstallationDialog = function (callback) {
  1028. let submitFunction = function(e,v){
  1029. if (v) {
  1030. callback();
  1031. }
  1032. };
  1033. let closeFunction = function (e, v) {
  1034. if (!v) {
  1035. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1036. }
  1037. };
  1038. messageHandler.openTwoButtonDialog({
  1039. titleKey: 'dialog.externalInstallationTitle',
  1040. msgKey: 'dialog.inlineInstallationMsg',
  1041. leftButtonKey: 'dialog.inlineInstallExtension',
  1042. submitFunction,
  1043. loadedFunction: $.noop,
  1044. closeFunction
  1045. });
  1046. };
  1047. /**
  1048. * Shows dialog with combined information about camera and microphone errors.
  1049. * @param {JitsiTrackError} micError
  1050. * @param {JitsiTrackError} cameraError
  1051. */
  1052. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1053. let dontShowAgain = {
  1054. id: "doNotShowWarningAgain",
  1055. localStorageKey: "doNotShowErrorAgain",
  1056. textKey: "dialog.doNotShowWarningAgain"
  1057. };
  1058. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1059. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1060. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1061. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1062. let showDoNotShowWarning = false;
  1063. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1064. isCameraJitsiTrackErrorAndHasName) {
  1065. showDoNotShowWarning = true;
  1066. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1067. showDoNotShowWarning = true;
  1068. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1069. showDoNotShowWarning = true;
  1070. }
  1071. if (micError) {
  1072. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1073. }
  1074. if (cameraError) {
  1075. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1076. }
  1077. let cameraJitsiTrackErrorMsg = cameraError
  1078. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1079. : undefined;
  1080. let micJitsiTrackErrorMsg = micError
  1081. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1082. : undefined;
  1083. let cameraErrorMsg = cameraError
  1084. ? cameraJitsiTrackErrorMsg ||
  1085. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1086. : "";
  1087. let micErrorMsg = micError
  1088. ? micJitsiTrackErrorMsg ||
  1089. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1090. : "";
  1091. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1092. cameraError.message
  1093. ? `<div>${cameraError.message}</div>`
  1094. : ``;
  1095. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1096. micError.message
  1097. ? `<div>${micError.message}</div>`
  1098. : ``;
  1099. let message = '';
  1100. if (micError) {
  1101. message = `
  1102. ${message}
  1103. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1104. <h4 data-i18n='${micErrorMsg}'></h4>
  1105. ${additionalMicErrorMsg}`;
  1106. }
  1107. if (cameraError) {
  1108. message = `
  1109. ${message}
  1110. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1111. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1112. ${additionalCameraErrorMsg}`;
  1113. }
  1114. // To make sure we don't have multiple error dialogs open at the same time,
  1115. // we will just close the previous one if we are going to show a new one.
  1116. deviceErrorDialog && deviceErrorDialog.close();
  1117. deviceErrorDialog = messageHandler.openDialog(
  1118. getTitleKey(),
  1119. message,
  1120. false,
  1121. {Ok: true},
  1122. function () {},
  1123. null,
  1124. function () {
  1125. // Reset dialog reference to null to avoid memory leaks when
  1126. // user closed the dialog manually.
  1127. deviceErrorDialog = null;
  1128. },
  1129. showDoNotShowWarning ? dontShowAgain : undefined
  1130. );
  1131. function getTitleKey() {
  1132. let title = "dialog.error";
  1133. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1134. if (!cameraError
  1135. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1136. title = "dialog.permissionDenied";
  1137. }
  1138. } else if (cameraError
  1139. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1140. title = "dialog.permissionDenied";
  1141. }
  1142. return title;
  1143. }
  1144. };
  1145. /**
  1146. * Shows error dialog that informs the user that no data is received from the
  1147. * device.
  1148. */
  1149. UI.showTrackNotWorkingDialog = function (stream) {
  1150. messageHandler.openMessageDialog(
  1151. "dialog.error",
  1152. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1153. "dialog.cameraNotSendingData");
  1154. };
  1155. UI.updateDevicesAvailability = function (id, devices) {
  1156. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1157. };
  1158. /**
  1159. * Show shared video.
  1160. * @param {string} id the id of the sender of the command
  1161. * @param {string} url video url
  1162. * @param {string} attributes
  1163. */
  1164. UI.onSharedVideoStart = function (id, url, attributes) {
  1165. if (sharedVideoManager)
  1166. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1167. };
  1168. /**
  1169. * Update shared video.
  1170. * @param {string} id the id of the sender of the command
  1171. * @param {string} url video url
  1172. * @param {string} attributes
  1173. */
  1174. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1175. if (sharedVideoManager)
  1176. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1177. };
  1178. /**
  1179. * Stop showing shared video.
  1180. * @param {string} id the id of the sender of the command
  1181. * @param {string} attributes
  1182. */
  1183. UI.onSharedVideoStop = function (id, attributes) {
  1184. if (sharedVideoManager)
  1185. sharedVideoManager.onSharedVideoStop(id, attributes);
  1186. };
  1187. /**
  1188. * Enables / disables microphone toolbar button.
  1189. *
  1190. * @param {boolean} enabled indicates if the microphone button should be
  1191. * enabled or disabled
  1192. */
  1193. UI.setMicrophoneButtonEnabled
  1194. = enabled => APP.store.dispatch(setAudioIconEnabled(enabled));
  1195. /**
  1196. * Indicates if any the "top" overlays are currently visible. The check includes
  1197. * the call/ring overlay, the suspended overlay, the GUM permissions overlay,
  1198. * and the page-reload overlay.
  1199. *
  1200. * @returns {*|boolean} {true} if an overlay is visible; {false}, otherwise
  1201. */
  1202. UI.isOverlayVisible = function () {
  1203. return (
  1204. this.overlayVisible
  1205. || APP.store.getState()['features/jwt'].callOverlayVisible);
  1206. };
  1207. /**
  1208. * Handles user's features changes.
  1209. */
  1210. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1211. /**
  1212. * Returns the number of known remote videos.
  1213. *
  1214. * @returns {number} The number of remote videos.
  1215. */
  1216. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  1217. /**
  1218. * Makes remote thumbnail videos visible or not visible.
  1219. *
  1220. * @param {boolean} shouldHide - True if remote thumbnails should be hidden,
  1221. * false f they should be visible.
  1222. * @returns {void}
  1223. */
  1224. UI.setRemoteThumbnailsVisibility
  1225. = shouldHide => Filmstrip.setRemoteVideoVisibility(shouldHide);
  1226. const UIListeners = new Map([
  1227. [
  1228. UIEvents.ETHERPAD_CLICKED,
  1229. () => etherpadManager && etherpadManager.toggleEtherpad()
  1230. ], [
  1231. UIEvents.SHARED_VIDEO_CLICKED,
  1232. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1233. ], [
  1234. UIEvents.TOGGLE_FULLSCREEN,
  1235. UI.toggleFullScreen
  1236. ], [
  1237. UIEvents.TOGGLE_CHAT,
  1238. UI.toggleChat
  1239. ], [
  1240. UIEvents.TOGGLE_SETTINGS,
  1241. () => {
  1242. // Opening of device selection is special-cased as it is a dialog
  1243. // opened through a button in settings and not directly displayed in
  1244. // settings itself. As it is not useful to only have a settings menu
  1245. // with a button to open a dialog, open the dialog directly instead.
  1246. if (interfaceConfig.SETTINGS_SECTIONS.length === 1
  1247. && UIUtil.isSettingEnabled('devices')) {
  1248. APP.store.dispatch(openDeviceSelectionDialog());
  1249. } else {
  1250. UI.toggleSidePanel("settings_container");
  1251. }
  1252. }
  1253. ], [
  1254. UIEvents.TOGGLE_CONTACT_LIST,
  1255. UI.toggleContactList
  1256. ], [
  1257. UIEvents.TOGGLE_PROFILE,
  1258. () => {
  1259. const {
  1260. isGuest
  1261. } = APP.store.getState()['features/jwt'];
  1262. isGuest && UI.toggleSidePanel('profile_container');
  1263. }
  1264. ], [
  1265. UIEvents.TOGGLE_FILMSTRIP,
  1266. UI.handleToggleFilmstrip
  1267. ], [
  1268. UIEvents.FOLLOW_ME_ENABLED,
  1269. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1270. ]
  1271. ]);
  1272. // TODO: Export every function separately. For now there is no point of doing
  1273. // this because we are importing everything.
  1274. export default UI;