You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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