Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

UI.js 39KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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. $("body").addClass("filmstrip-only");
  380. UIUtil.setVisible('mainToolbarContainer', false);
  381. FilmStrip.setupFilmStripOnly();
  382. messageHandler.enableNotifications(false);
  383. JitsiPopover.enabled = false;
  384. }
  385. document.title = interfaceConfig.APP_NAME;
  386. if(config.requireDisplayName) {
  387. if (!APP.settings.getDisplayName()) {
  388. promptDisplayName();
  389. }
  390. }
  391. if (!interfaceConfig.filmStripOnly) {
  392. toastr.options = {
  393. "closeButton": true,
  394. "debug": false,
  395. "positionClass": "notification-bottom-right",
  396. "onclick": null,
  397. "showDuration": "300",
  398. "hideDuration": "1000",
  399. "timeOut": "2000",
  400. "extendedTimeOut": "1000",
  401. "showEasing": "swing",
  402. "hideEasing": "linear",
  403. "showMethod": "fadeIn",
  404. "hideMethod": "fadeOut",
  405. "newestOnTop": false,
  406. // this is the default toastr close button html, just adds tabIndex
  407. "closeHtml": '<button type="button" tabIndex="-1">&times;</button>'
  408. };
  409. }
  410. if(APP.tokenData.callee) {
  411. UI.showRingOverlay();
  412. }
  413. // Return true to indicate that the UI has been fully started and
  414. // conference ready.
  415. return true;
  416. };
  417. /**
  418. * Show local stream on UI.
  419. * @param {JitsiTrack} track stream to show
  420. */
  421. UI.addLocalStream = function (track) {
  422. switch (track.getType()) {
  423. case 'audio':
  424. VideoLayout.changeLocalAudio(track);
  425. break;
  426. case 'video':
  427. VideoLayout.changeLocalVideo(track);
  428. break;
  429. default:
  430. logger.error("Unknown stream type: " + track.getType());
  431. break;
  432. }
  433. };
  434. /**
  435. * Show remote stream on UI.
  436. * @param {JitsiTrack} track stream to show
  437. */
  438. UI.addRemoteStream = function (track) {
  439. VideoLayout.onRemoteStreamAdded(track);
  440. };
  441. /**
  442. * Removed remote stream from UI.
  443. * @param {JitsiTrack} track stream to remove
  444. */
  445. UI.removeRemoteStream = function (track) {
  446. VideoLayout.onRemoteStreamRemoved(track);
  447. };
  448. /**
  449. * Update chat subject.
  450. * @param {string} subject new chat subject
  451. */
  452. UI.setSubject = function (subject) {
  453. Chat.setSubject(subject);
  454. };
  455. /**
  456. * Setup and show Etherpad.
  457. * @param {string} name etherpad id
  458. */
  459. UI.initEtherpad = function (name) {
  460. if (etherpadManager || !config.etherpad_base || !name) {
  461. return;
  462. }
  463. logger.log('Etherpad is enabled');
  464. etherpadManager
  465. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  466. Toolbar.showEtherpadButton();
  467. };
  468. /**
  469. * Returns the shared document manager object.
  470. * @return {EtherpadManager} the shared document manager object
  471. */
  472. UI.getSharedDocumentManager = function () {
  473. return etherpadManager;
  474. };
  475. /**
  476. * Show user on UI.
  477. * @param {JitsiParticipant} user
  478. */
  479. UI.addUser = function (user) {
  480. var id = user.getId();
  481. var displayName = user.getDisplayName();
  482. UI.hideRingOverLay();
  483. if (UI.ContactList)
  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. if (UI.ContactList)
  506. UI.ContactList.removeContact(id);
  507. messageHandler.notify(
  508. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  509. );
  510. if (!config.startAudioMuted
  511. || config.startAudioMuted > APP.conference.membersCount) {
  512. UIUtil.playSoundNotification('userLeft');
  513. }
  514. VideoLayout.removeParticipantContainer(id);
  515. };
  516. /**
  517. * Update videotype for specified user.
  518. * @param {string} id user id
  519. * @param {string} newVideoType new videotype
  520. */
  521. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  522. VideoLayout.onVideoTypeChanged(id, newVideoType);
  523. };
  524. /**
  525. * Update local user role and show notification if user is moderator.
  526. * @param {boolean} isModerator if local user is moderator or not
  527. */
  528. UI.updateLocalRole = function (isModerator) {
  529. VideoLayout.showModeratorIndicator();
  530. Toolbar.showSipCallButton(isModerator);
  531. Toolbar.showSharedVideoButton(isModerator);
  532. Recording.showRecordingButton(isModerator);
  533. SettingsMenu.showStartMutedOptions(isModerator);
  534. SettingsMenu.showFollowMeOptions(isModerator);
  535. if (isModerator) {
  536. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  537. messageHandler
  538. .notify(null, "notify.me", 'connected', "notify.moderator");
  539. Recording.checkAutoRecord();
  540. }
  541. };
  542. /**
  543. * Check the role for the user and reflect it in the UI, moderator ui indication
  544. * and notifies user who is the moderator
  545. * @param user to check for moderator
  546. */
  547. UI.updateUserRole = function (user) {
  548. VideoLayout.showModeratorIndicator();
  549. // We don't need to show moderator notifications when the focus (moderator)
  550. // indicator is disabled.
  551. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  552. return;
  553. }
  554. var displayName = user.getDisplayName();
  555. if (displayName) {
  556. messageHandler.notify(
  557. displayName, 'notify.somebody',
  558. 'connected', 'notify.grantedTo', {
  559. to: UIUtil.escapeHtml(displayName)
  560. }
  561. );
  562. } else {
  563. messageHandler.notify(
  564. '', 'notify.somebody',
  565. 'connected', 'notify.grantedToUnknown', {}
  566. );
  567. }
  568. };
  569. /**
  570. * Toggles smileys in the chat.
  571. */
  572. UI.toggleSmileys = function () {
  573. Chat.toggleSmileys();
  574. };
  575. /**
  576. * Toggles film strip.
  577. */
  578. UI.toggleFilmStrip = function () {
  579. var self = FilmStrip;
  580. self.toggleFilmStrip.apply(self, arguments);
  581. VideoLayout.resizeVideoArea(true, false);
  582. };
  583. /**
  584. * Indicates if the film strip is currently visible or not.
  585. * @returns {true} if the film strip is currently visible, otherwise
  586. */
  587. UI.isFilmStripVisible = function () {
  588. return FilmStrip.isFilmStripVisible();
  589. };
  590. /**
  591. * Toggles chat panel.
  592. */
  593. UI.toggleChat = function () {
  594. UI.toggleSidePanel("chat_container");
  595. };
  596. /**
  597. * Toggles contact list panel.
  598. */
  599. UI.toggleContactList = function () {
  600. UI.toggleSidePanel("contacts_container");
  601. };
  602. /**
  603. * Toggles the given side panel.
  604. *
  605. * @param {String} sidePanelId the identifier of the side panel to toggle
  606. */
  607. UI.toggleSidePanel = function (sidePanelId) {
  608. SideContainerToggler.toggle(sidePanelId);
  609. };
  610. /**
  611. * Handle new user display name.
  612. */
  613. UI.inputDisplayNameHandler = function (newDisplayName) {
  614. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  615. };
  616. /**
  617. * Show custom popup/tooltip for a specified button.
  618. * @param popupSelectorID the selector id of the popup to show
  619. * @param show true or false/show or hide the popup
  620. * @param timeout the time to show the popup
  621. */
  622. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  623. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  624. popupSelectorID, show, timeout);
  625. };
  626. /**
  627. * Return the type of the remote video.
  628. * @param jid the jid for the remote video
  629. * @returns the video type video or screen.
  630. */
  631. UI.getRemoteVideoType = function (jid) {
  632. return VideoLayout.getRemoteVideoType(jid);
  633. };
  634. UI.connectionIndicatorShowMore = function(id) {
  635. VideoLayout.showMore(id);
  636. return false;
  637. };
  638. // FIXME check if someone user this
  639. UI.showLoginPopup = function(callback) {
  640. logger.log('password is required');
  641. let message = (
  642. `<input name="username" type="text"
  643. placeholder="user@domain.net"
  644. class="input-control" autofocus>
  645. <input name="password" type="password"
  646. data-i18n="[placeholder]dialog.userPassword"
  647. class="input-control"
  648. placeholder="user password">`
  649. );
  650. let submitFunction = (e, v, m, f) => {
  651. if (v) {
  652. if (f.username && f.password) {
  653. callback(f.username, f.password);
  654. }
  655. }
  656. };
  657. messageHandler.openTwoButtonDialog({
  658. titleKey : "dialog.passwordRequired",
  659. msgString: message,
  660. leftButtonKey: 'dialog.Ok',
  661. submitFunction,
  662. focus: ':input:first'
  663. });
  664. };
  665. UI.askForNickname = function () {
  666. return window.prompt('Your nickname (optional)');
  667. };
  668. /**
  669. * Sets muted audio state for participant
  670. */
  671. UI.setAudioMuted = function (id, muted) {
  672. VideoLayout.onAudioMute(id, muted);
  673. if (APP.conference.isLocalId(id)) {
  674. Toolbar.toggleAudioIcon(muted);
  675. }
  676. };
  677. /**
  678. * Sets muted video state for participant
  679. */
  680. UI.setVideoMuted = function (id, muted) {
  681. VideoLayout.onVideoMute(id, muted);
  682. if (APP.conference.isLocalId(id)) {
  683. Toolbar.toggleVideoIcon(muted);
  684. }
  685. };
  686. /**
  687. * Adds a listener that would be notified on the given type of event.
  688. *
  689. * @param type the type of the event we're listening for
  690. * @param listener a function that would be called when notified
  691. */
  692. UI.addListener = function (type, listener) {
  693. eventEmitter.on(type, listener);
  694. };
  695. /**
  696. * Removes the given listener for the given type of event.
  697. *
  698. * @param type the type of the event we're listening for
  699. * @param listener the listener we want to remove
  700. */
  701. UI.removeListener = function (type, listener) {
  702. eventEmitter.removeListener(type, listener);
  703. };
  704. /**
  705. * Emits the event of given type by specifying the parameters in options.
  706. *
  707. * @param type the type of the event we're emitting
  708. * @param options the parameters for the event
  709. */
  710. UI.emitEvent = function (type, options) {
  711. eventEmitter.emit(type, options);
  712. };
  713. UI.clickOnVideo = function (videoNumber) {
  714. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  715. let videosLength = videos.length;
  716. if(videosLength <= videoNumber) {
  717. return;
  718. }
  719. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  720. videos[videoIndex].click();
  721. };
  722. //Used by torture
  723. UI.showToolbar = function (timeout) {
  724. return ToolbarToggler.showToolbar(timeout);
  725. };
  726. //Used by torture
  727. UI.dockToolbar = function (isDock) {
  728. ToolbarToggler.dockToolbar(isDock);
  729. };
  730. /**
  731. * Updates the avatar for participant.
  732. * @param {string} id user id
  733. * @param {string} avatarUrl the URL for the avatar
  734. */
  735. function changeAvatar(id, avatarUrl) {
  736. VideoLayout.changeUserAvatar(id, avatarUrl);
  737. if (UI.ContactList)
  738. UI.ContactList.changeUserAvatar(id, avatarUrl);
  739. if (APP.conference.isLocalId(id)) {
  740. Profile.changeAvatar(avatarUrl);
  741. }
  742. }
  743. /**
  744. * Update user email.
  745. * @param {string} id user id
  746. * @param {string} email user email
  747. */
  748. UI.setUserEmail = function (id, email) {
  749. // update avatar
  750. Avatar.setUserEmail(id, email);
  751. changeAvatar(id, Avatar.getAvatarUrl(id));
  752. };
  753. /**
  754. * Update user avtar id.
  755. * @param {string} id user id
  756. * @param {string} avatarId user's avatar id
  757. */
  758. UI.setUserAvatarID = function (id, avatarId) {
  759. // update avatar
  760. Avatar.setUserAvatarID(id, avatarId);
  761. changeAvatar(id, Avatar.getAvatarUrl(id));
  762. };
  763. /**
  764. * Update user avatar URL.
  765. * @param {string} id user id
  766. * @param {string} url user avatar url
  767. */
  768. UI.setUserAvatarUrl = function (id, url) {
  769. // update avatar
  770. Avatar.setUserAvatarUrl(id, url);
  771. changeAvatar(id, Avatar.getAvatarUrl(id));
  772. };
  773. /**
  774. * Notify user that connection failed.
  775. * @param {string} stropheErrorMsg raw Strophe error message
  776. */
  777. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  778. var message;
  779. if (stropheErrorMsg) {
  780. message = APP.translation.generateTranslationHTML(
  781. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  782. } else {
  783. message = APP.translation.generateTranslationHTML(
  784. "dialog.connectError");
  785. }
  786. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  787. };
  788. /**
  789. * Notify user that maximum users limit has been reached.
  790. */
  791. UI.notifyMaxUsersLimitReached = function () {
  792. var message = APP.translation.generateTranslationHTML(
  793. "dialog.maxUsersLimitReached");
  794. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  795. };
  796. /**
  797. * Notify user that he was automatically muted when joned the conference.
  798. */
  799. UI.notifyInitiallyMuted = function () {
  800. messageHandler.notify(
  801. null,
  802. "notify.mutedTitle",
  803. "connected",
  804. "notify.muted",
  805. null,
  806. { timeOut: 120000 });
  807. };
  808. /**
  809. * Mark user as dominant speaker.
  810. * @param {string} id user id
  811. */
  812. UI.markDominantSpeaker = function (id) {
  813. VideoLayout.onDominantSpeakerChanged(id);
  814. };
  815. UI.handleLastNEndpoints = function (ids, enteringIds) {
  816. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  817. };
  818. /**
  819. * Will handle notification about participant's connectivity status change.
  820. *
  821. * @param {string} id the id of remote participant(MUC jid)
  822. * @param {boolean} isActive true if the connection is ok or false if the user
  823. * is having connectivity issues.
  824. */
  825. UI.participantConnectionStatusChanged = function (id, isActive) {
  826. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  827. };
  828. /**
  829. * Update audio level visualization for specified user.
  830. * @param {string} id user id
  831. * @param {number} lvl audio level
  832. */
  833. UI.setAudioLevel = function (id, lvl) {
  834. VideoLayout.setAudioLevel(id, lvl);
  835. };
  836. /**
  837. * Update state of desktop sharing buttons.
  838. */
  839. UI.updateDesktopSharingButtons = function () {
  840. Toolbar.updateDesktopSharingButtonState();
  841. };
  842. /**
  843. * Hide connection quality statistics from UI.
  844. */
  845. UI.hideStats = function () {
  846. VideoLayout.hideStats();
  847. };
  848. /**
  849. * Update local connection quality statistics.
  850. * @param {number} percent
  851. * @param {object} stats
  852. */
  853. UI.updateLocalStats = function (percent, stats) {
  854. VideoLayout.updateLocalConnectionStats(percent, stats);
  855. };
  856. /**
  857. * Update connection quality statistics for remote user.
  858. * @param {string} id user id
  859. * @param {number} percent
  860. * @param {object} stats
  861. */
  862. UI.updateRemoteStats = function (id, percent, stats) {
  863. VideoLayout.updateConnectionStats(id, percent, stats);
  864. };
  865. /**
  866. * Mark video as interrupted or not.
  867. * @param {boolean} interrupted if video is interrupted
  868. */
  869. UI.markVideoInterrupted = function (interrupted) {
  870. if (interrupted) {
  871. VideoLayout.onVideoInterrupted();
  872. } else {
  873. VideoLayout.onVideoRestored();
  874. }
  875. };
  876. /**
  877. * Add chat message.
  878. * @param {string} from user id
  879. * @param {string} displayName user nickname
  880. * @param {string} message message text
  881. * @param {number} stamp timestamp when message was created
  882. */
  883. UI.addMessage = function (from, displayName, message, stamp) {
  884. Chat.updateChatConversation(from, displayName, message, stamp);
  885. };
  886. // eslint-disable-next-line no-unused-vars
  887. UI.updateDTMFSupport = function (isDTMFSupported) {
  888. //TODO: enable when the UI is ready
  889. //Toolbar.showDialPadButton(isDTMFSupported);
  890. };
  891. /**
  892. * Show user feedback dialog if its required and enabled after pressing the
  893. * hangup button.
  894. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  895. * resolved with true if the dialog is disabled or the feedback was already
  896. * submitted. Rejected if another dialog is already displayed. This values are
  897. * used to display or not display the thank you dialog from
  898. * conference.maybeRedirectToWelcomePage method.
  899. */
  900. UI.requestFeedbackOnHangup = function () {
  901. if (Feedback.isVisible())
  902. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  903. // Feedback has been submitted already.
  904. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  905. return Promise.resolve({
  906. thankYouDialogVisible : true,
  907. feedbackSubmitted: true
  908. });
  909. }
  910. else
  911. return new Promise(function (resolve) {
  912. if (Feedback.isEnabled()) {
  913. Feedback.openFeedbackWindow(
  914. (options) => {
  915. options.thankYouDialogVisible = false;
  916. resolve(options);
  917. });
  918. } else {
  919. // If the feedback functionality isn't enabled we show a thank
  920. // you dialog. Signaling it (true), so the caller
  921. // of requestFeedback can act on it
  922. resolve(
  923. {thankYouDialogVisible : true, feedbackSubmitted: false});
  924. }
  925. });
  926. };
  927. UI.updateRecordingState = function (state) {
  928. Recording.updateRecordingState(state);
  929. };
  930. UI.notifyTokenAuthFailed = function () {
  931. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  932. "dialog.tokenAuthFailed");
  933. };
  934. UI.notifyInternalError = function () {
  935. messageHandler.showError( "dialog.internalErrorTitle",
  936. "dialog.internalError");
  937. };
  938. UI.notifyFocusDisconnected = function (focus, retrySec) {
  939. messageHandler.notify(
  940. null, "notify.focus",
  941. 'disconnected', "notify.focusFail",
  942. {component: focus, ms: retrySec}
  943. );
  944. };
  945. /**
  946. * Updates auth info on the UI.
  947. * @param {boolean} isAuthEnabled if authentication is enabled
  948. * @param {string} [login] current login
  949. */
  950. UI.updateAuthInfo = function (isAuthEnabled, login) {
  951. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  952. let loggedIn = !!login;
  953. Profile.showAuthenticationButtons(showAuth);
  954. if (showAuth) {
  955. Profile.setAuthenticatedIdentity(login);
  956. Profile.showLoginButton(!loggedIn);
  957. Profile.showLogoutButton(loggedIn);
  958. }
  959. };
  960. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  961. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  962. };
  963. /**
  964. * Notifies interested listeners that the raise hand property has changed.
  965. *
  966. * @param {boolean} isRaisedHand indicates the current state of the
  967. * "raised hand"
  968. */
  969. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  970. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  971. };
  972. /**
  973. * Update list of available physical devices.
  974. * @param {object[]} devices new list of available devices
  975. */
  976. UI.onAvailableDevicesChanged = function (devices) {
  977. SettingsMenu.changeDevicesList(devices);
  978. };
  979. /**
  980. * Sets microphone's <select> element to select microphone ID from settings.
  981. */
  982. UI.setSelectedMicFromSettings = function () {
  983. SettingsMenu.setSelectedMicFromSettings();
  984. };
  985. /**
  986. * Sets camera's <select> element to select camera ID from settings.
  987. */
  988. UI.setSelectedCameraFromSettings = function () {
  989. SettingsMenu.setSelectedCameraFromSettings();
  990. };
  991. /**
  992. * Sets audio outputs's <select> element to select audio output ID from
  993. * settings.
  994. */
  995. UI.setSelectedAudioOutputFromSettings = function () {
  996. SettingsMenu.setSelectedAudioOutputFromSettings();
  997. };
  998. /**
  999. * Returns the id of the current video shown on large.
  1000. * Currently used by tests (torture).
  1001. */
  1002. UI.getLargeVideoID = function () {
  1003. return VideoLayout.getLargeVideoID();
  1004. };
  1005. /**
  1006. * Returns the current video shown on large.
  1007. * Currently used by tests (torture).
  1008. */
  1009. UI.getLargeVideo = function () {
  1010. return VideoLayout.getLargeVideo();
  1011. };
  1012. /**
  1013. * Shows dialog with a link to FF extension.
  1014. */
  1015. UI.showExtensionRequiredDialog = function (url) {
  1016. messageHandler.openMessageDialog(
  1017. "dialog.extensionRequired",
  1018. "[html]dialog.firefoxExtensionPrompt",
  1019. {url: url});
  1020. };
  1021. /**
  1022. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1023. * 2 button dialog with buttons - cancel and go to web store.
  1024. * @param url {string} the url of the extension.
  1025. */
  1026. UI.showExtensionExternalInstallationDialog = function (url) {
  1027. let submitFunction = function(e,v){
  1028. if (v) {
  1029. e.preventDefault();
  1030. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1031. }
  1032. };
  1033. let closeFunction = function () {
  1034. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1035. };
  1036. messageHandler.openTwoButtonDialog({
  1037. titleKey: 'dialog.externalInstallationTitle',
  1038. msgKey: 'dialog.externalInstallationMsg',
  1039. leftButtonKey: 'dialog.goToStore',
  1040. submitFunction,
  1041. loadedFunction: $.noop,
  1042. closeFunction
  1043. });
  1044. };
  1045. /**
  1046. * Shows dialog with combined information about camera and microphone errors.
  1047. * @param {JitsiTrackError} micError
  1048. * @param {JitsiTrackError} cameraError
  1049. */
  1050. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1051. let dontShowAgain = {
  1052. id: "doNotShowWarningAgain",
  1053. localStorageKey: "doNotShowErrorAgain",
  1054. textKey: "dialog.doNotShowWarningAgain"
  1055. };
  1056. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1057. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1058. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1059. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1060. let showDoNotShowWarning = false;
  1061. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1062. isCameraJitsiTrackErrorAndHasName) {
  1063. showDoNotShowWarning = true;
  1064. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1065. showDoNotShowWarning = true;
  1066. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1067. showDoNotShowWarning = true;
  1068. }
  1069. if (micError) {
  1070. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1071. }
  1072. if (cameraError) {
  1073. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1074. }
  1075. let cameraJitsiTrackErrorMsg = cameraError
  1076. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1077. : undefined;
  1078. let micJitsiTrackErrorMsg = micError
  1079. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1080. : undefined;
  1081. let cameraErrorMsg = cameraError
  1082. ? cameraJitsiTrackErrorMsg ||
  1083. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1084. : "";
  1085. let micErrorMsg = micError
  1086. ? micJitsiTrackErrorMsg ||
  1087. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1088. : "";
  1089. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1090. cameraError.message
  1091. ? `<div>${cameraError.message}</div>`
  1092. : ``;
  1093. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1094. micError.message
  1095. ? `<div>${micError.message}</div>`
  1096. : ``;
  1097. let message = '';
  1098. if (micError) {
  1099. message = `
  1100. ${message}
  1101. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1102. <h4 data-i18n='${micErrorMsg}'></h4>
  1103. ${additionalMicErrorMsg}`;
  1104. }
  1105. if (cameraError) {
  1106. message = `
  1107. ${message}
  1108. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1109. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1110. ${additionalCameraErrorMsg}`;
  1111. }
  1112. // To make sure we don't have multiple error dialogs open at the same time,
  1113. // we will just close the previous one if we are going to show a new one.
  1114. deviceErrorDialog && deviceErrorDialog.close();
  1115. deviceErrorDialog = messageHandler.openDialog(
  1116. getTitleKey(),
  1117. message,
  1118. false,
  1119. {Ok: true},
  1120. function () {},
  1121. null,
  1122. function () {
  1123. // Reset dialog reference to null to avoid memory leaks when
  1124. // user closed the dialog manually.
  1125. deviceErrorDialog = null;
  1126. },
  1127. showDoNotShowWarning ? dontShowAgain : undefined
  1128. );
  1129. function getTitleKey() {
  1130. let title = "dialog.error";
  1131. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1132. if (!cameraError
  1133. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1134. title = "dialog.permissionDenied";
  1135. }
  1136. } else if (cameraError
  1137. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1138. title = "dialog.permissionDenied";
  1139. }
  1140. return title;
  1141. }
  1142. };
  1143. /**
  1144. * Shows error dialog that informs the user that no data is received from the
  1145. * device.
  1146. */
  1147. UI.showTrackNotWorkingDialog = function (stream) {
  1148. messageHandler.openMessageDialog(
  1149. "dialog.error",
  1150. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1151. "dialog.cameraNotSendingData");
  1152. };
  1153. UI.updateDevicesAvailability = function (id, devices) {
  1154. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1155. };
  1156. /**
  1157. * Show shared video.
  1158. * @param {string} id the id of the sender of the command
  1159. * @param {string} url video url
  1160. * @param {string} attributes
  1161. */
  1162. UI.onSharedVideoStart = function (id, url, attributes) {
  1163. if (sharedVideoManager)
  1164. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1165. };
  1166. /**
  1167. * Update shared video.
  1168. * @param {string} id the id of the sender of the command
  1169. * @param {string} url video url
  1170. * @param {string} attributes
  1171. */
  1172. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1173. if (sharedVideoManager)
  1174. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1175. };
  1176. /**
  1177. * Stop showing shared video.
  1178. * @param {string} id the id of the sender of the command
  1179. * @param {string} attributes
  1180. */
  1181. UI.onSharedVideoStop = function (id, attributes) {
  1182. if (sharedVideoManager)
  1183. sharedVideoManager.onSharedVideoStop(id, attributes);
  1184. };
  1185. /**
  1186. * Enables / disables camera toolbar button.
  1187. *
  1188. * @param {boolean} enabled indicates if the camera button should be enabled
  1189. * or disabled
  1190. */
  1191. UI.setCameraButtonEnabled = function (enabled) {
  1192. Toolbar.setVideoIconEnabled(enabled);
  1193. };
  1194. /**
  1195. * Enables / disables microphone toolbar button.
  1196. *
  1197. * @param {boolean} enabled indicates if the microphone button should be
  1198. * enabled or disabled
  1199. */
  1200. UI.setMicrophoneButtonEnabled = function (enabled) {
  1201. Toolbar.setAudioIconEnabled(enabled);
  1202. };
  1203. UI.showRingOverlay = function () {
  1204. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1205. FilmStrip.toggleFilmStrip(false, false);
  1206. };
  1207. UI.hideRingOverLay = function () {
  1208. if (!RingOverlay.hide())
  1209. return;
  1210. FilmStrip.toggleFilmStrip(true, false);
  1211. };
  1212. /**
  1213. * Indicates if any the "top" overlays are currently visible. The check includes
  1214. * the call overlay, suspended overlay, GUM permissions overlay
  1215. * and a page reload overlay.
  1216. *
  1217. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1218. */
  1219. UI.isOverlayVisible = function () {
  1220. return RingOverlay.isVisible() || this.overlayVisible;
  1221. };
  1222. /**
  1223. * Indicates if the ring overlay is currently visible.
  1224. *
  1225. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1226. */
  1227. UI.isRingOverlayVisible = function () {
  1228. return RingOverlay.isVisible();
  1229. };
  1230. /**
  1231. * Handles user's features changes.
  1232. */
  1233. UI.onUserFeaturesChanged = function (user) {
  1234. VideoLayout.onUserFeaturesChanged(user);
  1235. };
  1236. module.exports = UI;