您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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