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

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