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

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