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

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