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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457
  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 * as 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 { randomInt } 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(10 + randomInt(0, 20), isNetworkFailure, reason);
  953. };
  954. /**
  955. * Updates auth info on the UI.
  956. * @param {boolean} isAuthEnabled if authentication is enabled
  957. * @param {string} [login] current login
  958. */
  959. UI.updateAuthInfo = function (isAuthEnabled, login) {
  960. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  961. let loggedIn = !!login;
  962. Profile.showAuthenticationButtons(showAuth);
  963. if (showAuth) {
  964. Profile.setAuthenticatedIdentity(login);
  965. Profile.showLoginButton(!loggedIn);
  966. Profile.showLogoutButton(loggedIn);
  967. }
  968. };
  969. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  970. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  971. };
  972. /**
  973. * Notifies interested listeners that the raise hand property has changed.
  974. *
  975. * @param {boolean} isRaisedHand indicates the current state of the
  976. * "raised hand"
  977. */
  978. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  979. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  980. };
  981. /**
  982. * Update list of available physical devices.
  983. * @param {object[]} devices new list of available devices
  984. */
  985. UI.onAvailableDevicesChanged = function (devices) {
  986. SettingsMenu.changeDevicesList(devices);
  987. };
  988. /**
  989. * Sets microphone's <select> element to select microphone ID from settings.
  990. */
  991. UI.setSelectedMicFromSettings = function () {
  992. SettingsMenu.setSelectedMicFromSettings();
  993. };
  994. /**
  995. * Sets camera's <select> element to select camera ID from settings.
  996. */
  997. UI.setSelectedCameraFromSettings = function () {
  998. SettingsMenu.setSelectedCameraFromSettings();
  999. };
  1000. /**
  1001. * Sets audio outputs's <select> element to select audio output ID from
  1002. * settings.
  1003. */
  1004. UI.setSelectedAudioOutputFromSettings = function () {
  1005. SettingsMenu.setSelectedAudioOutputFromSettings();
  1006. };
  1007. /**
  1008. * Returns the id of the current video shown on large.
  1009. * Currently used by tests (torture).
  1010. */
  1011. UI.getLargeVideoID = function () {
  1012. return VideoLayout.getLargeVideoID();
  1013. };
  1014. /**
  1015. * Returns the current video shown on large.
  1016. * Currently used by tests (torture).
  1017. */
  1018. UI.getLargeVideo = function () {
  1019. return VideoLayout.getLargeVideo();
  1020. };
  1021. /**
  1022. * Shows dialog with a link to FF extension.
  1023. */
  1024. UI.showExtensionRequiredDialog = function (url) {
  1025. messageHandler.openMessageDialog(
  1026. "dialog.extensionRequired",
  1027. "[html]dialog.firefoxExtensionPrompt",
  1028. {url: url});
  1029. };
  1030. /**
  1031. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1032. * 2 button dialog with buttons - cancel and go to web store.
  1033. * @param url {string} the url of the extension.
  1034. */
  1035. UI.showExtensionExternalInstallationDialog = function (url) {
  1036. let submitFunction = function(e,v){
  1037. if (v) {
  1038. e.preventDefault();
  1039. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1040. }
  1041. };
  1042. let closeFunction = function () {
  1043. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1044. };
  1045. messageHandler.openTwoButtonDialog({
  1046. titleKey: 'dialog.externalInstallationTitle',
  1047. msgKey: 'dialog.externalInstallationMsg',
  1048. leftButtonKey: 'dialog.goToStore',
  1049. submitFunction,
  1050. loadedFunction: $.noop,
  1051. closeFunction
  1052. });
  1053. };
  1054. /**
  1055. * Shows dialog with combined information about camera and microphone errors.
  1056. * @param {JitsiTrackError} micError
  1057. * @param {JitsiTrackError} cameraError
  1058. */
  1059. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1060. let dontShowAgain = {
  1061. id: "doNotShowWarningAgain",
  1062. localStorageKey: "doNotShowErrorAgain",
  1063. textKey: "dialog.doNotShowWarningAgain"
  1064. };
  1065. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1066. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1067. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1068. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1069. let showDoNotShowWarning = false;
  1070. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1071. isCameraJitsiTrackErrorAndHasName) {
  1072. showDoNotShowWarning = true;
  1073. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1074. showDoNotShowWarning = true;
  1075. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1076. showDoNotShowWarning = true;
  1077. }
  1078. if (micError) {
  1079. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1080. }
  1081. if (cameraError) {
  1082. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1083. }
  1084. let cameraJitsiTrackErrorMsg = cameraError
  1085. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1086. : undefined;
  1087. let micJitsiTrackErrorMsg = micError
  1088. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1089. : undefined;
  1090. let cameraErrorMsg = cameraError
  1091. ? cameraJitsiTrackErrorMsg ||
  1092. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1093. : "";
  1094. let micErrorMsg = micError
  1095. ? micJitsiTrackErrorMsg ||
  1096. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1097. : "";
  1098. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1099. cameraError.message
  1100. ? `<div>${cameraError.message}</div>`
  1101. : ``;
  1102. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1103. micError.message
  1104. ? `<div>${micError.message}</div>`
  1105. : ``;
  1106. let message = '';
  1107. if (micError) {
  1108. message = `
  1109. ${message}
  1110. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1111. <h4 data-i18n='${micErrorMsg}'></h4>
  1112. ${additionalMicErrorMsg}`;
  1113. }
  1114. if (cameraError) {
  1115. message = `
  1116. ${message}
  1117. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1118. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1119. ${additionalCameraErrorMsg}`;
  1120. }
  1121. // To make sure we don't have multiple error dialogs open at the same time,
  1122. // we will just close the previous one if we are going to show a new one.
  1123. deviceErrorDialog && deviceErrorDialog.close();
  1124. deviceErrorDialog = messageHandler.openDialog(
  1125. getTitleKey(),
  1126. message,
  1127. false,
  1128. {Ok: true},
  1129. function () {},
  1130. null,
  1131. function () {
  1132. // Reset dialog reference to null to avoid memory leaks when
  1133. // user closed the dialog manually.
  1134. deviceErrorDialog = null;
  1135. },
  1136. showDoNotShowWarning ? dontShowAgain : undefined
  1137. );
  1138. function getTitleKey() {
  1139. let title = "dialog.error";
  1140. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1141. if (!cameraError
  1142. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1143. title = "dialog.permissionDenied";
  1144. }
  1145. } else if (cameraError
  1146. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1147. title = "dialog.permissionDenied";
  1148. }
  1149. return title;
  1150. }
  1151. };
  1152. /**
  1153. * Shows error dialog that informs the user that no data is received from the
  1154. * device.
  1155. */
  1156. UI.showTrackNotWorkingDialog = function (stream) {
  1157. messageHandler.openMessageDialog(
  1158. "dialog.error",
  1159. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1160. "dialog.cameraNotSendingData");
  1161. };
  1162. UI.updateDevicesAvailability = function (id, devices) {
  1163. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1164. };
  1165. /**
  1166. * Show shared video.
  1167. * @param {string} id the id of the sender of the command
  1168. * @param {string} url video url
  1169. * @param {string} attributes
  1170. */
  1171. UI.onSharedVideoStart = function (id, url, attributes) {
  1172. if (sharedVideoManager)
  1173. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1174. };
  1175. /**
  1176. * Update shared video.
  1177. * @param {string} id the id of the sender of the command
  1178. * @param {string} url video url
  1179. * @param {string} attributes
  1180. */
  1181. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1182. if (sharedVideoManager)
  1183. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1184. };
  1185. /**
  1186. * Stop showing shared video.
  1187. * @param {string} id the id of the sender of the command
  1188. * @param {string} attributes
  1189. */
  1190. UI.onSharedVideoStop = function (id, attributes) {
  1191. if (sharedVideoManager)
  1192. sharedVideoManager.onSharedVideoStop(id, attributes);
  1193. };
  1194. /**
  1195. * Enables / disables camera toolbar button.
  1196. *
  1197. * @param {boolean} enabled indicates if the camera button should be enabled
  1198. * or disabled
  1199. */
  1200. UI.setCameraButtonEnabled = function (enabled) {
  1201. Toolbar.setVideoIconEnabled(enabled);
  1202. };
  1203. /**
  1204. * Enables / disables microphone toolbar button.
  1205. *
  1206. * @param {boolean} enabled indicates if the microphone button should be
  1207. * enabled or disabled
  1208. */
  1209. UI.setMicrophoneButtonEnabled = function (enabled) {
  1210. Toolbar.setAudioIconEnabled(enabled);
  1211. };
  1212. UI.showRingOverlay = function () {
  1213. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1214. FilmStrip.toggleFilmStrip(false, false);
  1215. };
  1216. UI.hideRingOverLay = function () {
  1217. if (!RingOverlay.hide())
  1218. return;
  1219. FilmStrip.toggleFilmStrip(true, false);
  1220. };
  1221. /**
  1222. * Indicates if any the "top" overlays are currently visible. The check includes
  1223. * the call overlay, suspended overlay, GUM permissions overlay
  1224. * and a page reload overlay.
  1225. *
  1226. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1227. */
  1228. UI.isOverlayVisible = function () {
  1229. return RingOverlay.isVisible()
  1230. || SuspendedOverlay.isVisible()
  1231. || PageReloadOverlay.isVisible()
  1232. || GumPermissionsOverlay.isVisible();
  1233. };
  1234. /**
  1235. * Indicates if the ring overlay is currently visible.
  1236. *
  1237. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1238. */
  1239. UI.isRingOverlayVisible = function () {
  1240. return RingOverlay.isVisible();
  1241. };
  1242. /**
  1243. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1244. * @param {string} browser - name of browser for which to show the guidance
  1245. * overlay.
  1246. */
  1247. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1248. GumPermissionsOverlay.show(browser);
  1249. };
  1250. /**
  1251. * Shows suspended overlay with a button to rejoin conference.
  1252. */
  1253. UI.showSuspendedOverlay = function () {
  1254. SuspendedOverlay.show();
  1255. };
  1256. /**
  1257. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1258. */
  1259. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1260. GumPermissionsOverlay.hide();
  1261. };
  1262. module.exports = UI;