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