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.

UI.js 41KB

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