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.

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