Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UI.js 43KB

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