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.

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