Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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