Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

UI.js 40KB

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