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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  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="input-control" 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. UIUtil.showElement('notice');
  383. }
  384. } else {
  385. UIUtil.hideElement('mainToolbarContainer');
  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"
  637. class="input-control" autofocus>
  638. <input name="password" type="password"
  639. data-i18n="[placeholder]dialog.userPassword"
  640. class="input-control"
  641. placeholder="user password">`
  642. );
  643. let submitFunction = (e, v, m, f) => {
  644. if (v) {
  645. if (f.username && f.password) {
  646. callback(f.username, f.password);
  647. }
  648. }
  649. };
  650. messageHandler.openTwoButtonDialog({
  651. titleKey : "dialog.passwordRequired",
  652. msgString: message,
  653. leftButtonKey: 'dialog.Ok',
  654. submitFunction,
  655. focus: ':input:first'
  656. });
  657. };
  658. UI.askForNickname = function () {
  659. return window.prompt('Your nickname (optional)');
  660. };
  661. /**
  662. * Sets muted audio state for participant
  663. */
  664. UI.setAudioMuted = function (id, muted) {
  665. VideoLayout.onAudioMute(id, muted);
  666. if (APP.conference.isLocalId(id)) {
  667. Toolbar.toggleAudioIcon(muted);
  668. }
  669. };
  670. /**
  671. * Sets muted video state for participant
  672. */
  673. UI.setVideoMuted = function (id, muted) {
  674. VideoLayout.onVideoMute(id, muted);
  675. if (APP.conference.isLocalId(id)) {
  676. Toolbar.toggleVideoIcon(muted);
  677. }
  678. };
  679. /**
  680. * Adds a listener that would be notified on the given type of event.
  681. *
  682. * @param type the type of the event we're listening for
  683. * @param listener a function that would be called when notified
  684. */
  685. UI.addListener = function (type, listener) {
  686. eventEmitter.on(type, listener);
  687. };
  688. /**
  689. * Removes the given listener for the given type of event.
  690. *
  691. * @param type the type of the event we're listening for
  692. * @param listener the listener we want to remove
  693. */
  694. UI.removeListener = function (type, listener) {
  695. eventEmitter.removeListener(type, listener);
  696. };
  697. /**
  698. * Emits the event of given type by specifying the parameters in options.
  699. *
  700. * @param type the type of the event we're emitting
  701. * @param options the parameters for the event
  702. */
  703. UI.emitEvent = function (type, options) {
  704. eventEmitter.emit(type, options);
  705. };
  706. UI.clickOnVideo = function (videoNumber) {
  707. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  708. let videosLength = videos.length;
  709. if(videosLength <= videoNumber) {
  710. return;
  711. }
  712. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  713. videos[videoIndex].click();
  714. };
  715. //Used by torture
  716. UI.showToolbar = function (timeout) {
  717. return ToolbarToggler.showToolbar(timeout);
  718. };
  719. //Used by torture
  720. UI.dockToolbar = function (isDock) {
  721. ToolbarToggler.dockToolbar(isDock);
  722. };
  723. /**
  724. * Updates the avatar for participant.
  725. * @param {string} id user id
  726. * @param {string} avatarUrl the URL for the avatar
  727. */
  728. function changeAvatar(id, avatarUrl) {
  729. VideoLayout.changeUserAvatar(id, avatarUrl);
  730. if (UI.ContactList)
  731. UI.ContactList.changeUserAvatar(id, avatarUrl);
  732. if (APP.conference.isLocalId(id)) {
  733. Profile.changeAvatar(avatarUrl);
  734. }
  735. }
  736. /**
  737. * Update user email.
  738. * @param {string} id user id
  739. * @param {string} email user email
  740. */
  741. UI.setUserEmail = function (id, email) {
  742. // update avatar
  743. Avatar.setUserEmail(id, email);
  744. changeAvatar(id, Avatar.getAvatarUrl(id));
  745. };
  746. /**
  747. * Update user avtar id.
  748. * @param {string} id user id
  749. * @param {string} avatarId user's avatar id
  750. */
  751. UI.setUserAvatarID = function (id, avatarId) {
  752. // update avatar
  753. Avatar.setUserAvatarID(id, avatarId);
  754. changeAvatar(id, Avatar.getAvatarUrl(id));
  755. };
  756. /**
  757. * Update user avatar URL.
  758. * @param {string} id user id
  759. * @param {string} url user avatar url
  760. */
  761. UI.setUserAvatarUrl = function (id, url) {
  762. // update avatar
  763. Avatar.setUserAvatarUrl(id, url);
  764. changeAvatar(id, Avatar.getAvatarUrl(id));
  765. };
  766. /**
  767. * Notify user that connection failed.
  768. * @param {string} stropheErrorMsg raw Strophe error message
  769. */
  770. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  771. var message;
  772. if (stropheErrorMsg) {
  773. message = APP.translation.generateTranslationHTML(
  774. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  775. } else {
  776. message = APP.translation.generateTranslationHTML(
  777. "dialog.connectError");
  778. }
  779. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  780. };
  781. /**
  782. * Notify user that maximum users limit has been reached.
  783. */
  784. UI.notifyMaxUsersLimitReached = function () {
  785. var message = APP.translation.generateTranslationHTML(
  786. "dialog.maxUsersLimitReached");
  787. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  788. };
  789. /**
  790. * Notify user that he was automatically muted when joned the conference.
  791. */
  792. UI.notifyInitiallyMuted = function () {
  793. messageHandler.notify(
  794. null,
  795. "notify.mutedTitle",
  796. "connected",
  797. "notify.muted",
  798. null,
  799. { timeOut: 120000 });
  800. };
  801. /**
  802. * Mark user as dominant speaker.
  803. * @param {string} id user id
  804. */
  805. UI.markDominantSpeaker = function (id) {
  806. VideoLayout.onDominantSpeakerChanged(id);
  807. };
  808. UI.handleLastNEndpoints = function (ids, enteringIds) {
  809. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  810. };
  811. /**
  812. * Will handle notification about participant's connectivity status change.
  813. *
  814. * @param {string} id the id of remote participant(MUC jid)
  815. * @param {boolean} isActive true if the connection is ok or false if the user
  816. * is having connectivity issues.
  817. */
  818. UI.participantConnectionStatusChanged = function (id, isActive) {
  819. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  820. };
  821. /**
  822. * Update audio level visualization for specified user.
  823. * @param {string} id user id
  824. * @param {number} lvl audio level
  825. */
  826. UI.setAudioLevel = function (id, lvl) {
  827. VideoLayout.setAudioLevel(id, lvl);
  828. };
  829. /**
  830. * Update state of desktop sharing buttons.
  831. */
  832. UI.updateDesktopSharingButtons = function () {
  833. Toolbar.updateDesktopSharingButtonState();
  834. };
  835. /**
  836. * Hide connection quality statistics from UI.
  837. */
  838. UI.hideStats = function () {
  839. VideoLayout.hideStats();
  840. };
  841. /**
  842. * Update local connection quality statistics.
  843. * @param {number} percent
  844. * @param {object} stats
  845. */
  846. UI.updateLocalStats = function (percent, stats) {
  847. VideoLayout.updateLocalConnectionStats(percent, stats);
  848. };
  849. /**
  850. * Update connection quality statistics for remote user.
  851. * @param {string} id user id
  852. * @param {number} percent
  853. * @param {object} stats
  854. */
  855. UI.updateRemoteStats = function (id, percent, stats) {
  856. VideoLayout.updateConnectionStats(id, percent, stats);
  857. };
  858. /**
  859. * Mark video as interrupted or not.
  860. * @param {boolean} interrupted if video is interrupted
  861. */
  862. UI.markVideoInterrupted = function (interrupted) {
  863. if (interrupted) {
  864. VideoLayout.onVideoInterrupted();
  865. } else {
  866. VideoLayout.onVideoRestored();
  867. }
  868. };
  869. /**
  870. * Add chat message.
  871. * @param {string} from user id
  872. * @param {string} displayName user nickname
  873. * @param {string} message message text
  874. * @param {number} stamp timestamp when message was created
  875. */
  876. UI.addMessage = function (from, displayName, message, stamp) {
  877. Chat.updateChatConversation(from, displayName, message, stamp);
  878. };
  879. // eslint-disable-next-line no-unused-vars
  880. UI.updateDTMFSupport = function (isDTMFSupported) {
  881. //TODO: enable when the UI is ready
  882. //Toolbar.showDialPadButton(isDTMFSupported);
  883. };
  884. /**
  885. * Show user feedback dialog if its required and enabled after pressing the
  886. * hangup button.
  887. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  888. * resolved with true if the dialog is disabled or the feedback was already
  889. * submitted. Rejected if another dialog is already displayed. This values are
  890. * used to display or not display the thank you dialog from
  891. * conference.maybeRedirectToWelcomePage method.
  892. */
  893. UI.requestFeedbackOnHangup = function () {
  894. if (Feedback.isVisible())
  895. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  896. // Feedback has been submitted already.
  897. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  898. return Promise.resolve({
  899. thankYouDialogVisible : true,
  900. feedbackSubmitted: true
  901. });
  902. }
  903. else
  904. return new Promise(function (resolve) {
  905. if (Feedback.isEnabled()) {
  906. Feedback.openFeedbackWindow(
  907. (options) => {
  908. options.thankYouDialogVisible = false;
  909. resolve(options);
  910. });
  911. } else {
  912. // If the feedback functionality isn't enabled we show a thank
  913. // you dialog. Signaling it (true), so the caller
  914. // of requestFeedback can act on it
  915. resolve(
  916. {thankYouDialogVisible : true, feedbackSubmitted: false});
  917. }
  918. });
  919. };
  920. UI.updateRecordingState = function (state) {
  921. Recording.updateRecordingState(state);
  922. };
  923. UI.notifyTokenAuthFailed = function () {
  924. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  925. "dialog.tokenAuthFailed");
  926. };
  927. UI.notifyInternalError = function () {
  928. messageHandler.showError( "dialog.internalErrorTitle",
  929. "dialog.internalError");
  930. };
  931. UI.notifyFocusDisconnected = function (focus, retrySec) {
  932. messageHandler.notify(
  933. null, "notify.focus",
  934. 'disconnected', "notify.focusFail",
  935. {component: focus, ms: retrySec}
  936. );
  937. };
  938. /**
  939. * Notify the user that the video conferencing service is badly broken and
  940. * the page should be reloaded.
  941. */
  942. UI.showPageReloadOverlay = function () {
  943. // Reload the page after 10 - 30 seconds
  944. PageReloadOverlay.show(10 + RandomUtil.randomInt(0, 20));
  945. };
  946. /**
  947. * Updates auth info on the UI.
  948. * @param {boolean} isAuthEnabled if authentication is enabled
  949. * @param {string} [login] current login
  950. */
  951. UI.updateAuthInfo = function (isAuthEnabled, login) {
  952. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  953. let loggedIn = !!login;
  954. Toolbar.showAuthenticateButton(showAuth);
  955. if (showAuth) {
  956. Toolbar.setAuthenticatedIdentity(login);
  957. Toolbar.showLoginButton(!loggedIn);
  958. Toolbar.showLogoutButton(loggedIn);
  959. }
  960. };
  961. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  962. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  963. };
  964. /**
  965. * Notifies interested listeners that the raise hand property has changed.
  966. *
  967. * @param {boolean} isRaisedHand indicates the current state of the
  968. * "raised hand"
  969. */
  970. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  971. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  972. };
  973. /**
  974. * Update list of available physical devices.
  975. * @param {object[]} devices new list of available devices
  976. */
  977. UI.onAvailableDevicesChanged = function (devices) {
  978. SettingsMenu.changeDevicesList(devices);
  979. };
  980. /**
  981. * Sets microphone's <select> element to select microphone ID from settings.
  982. */
  983. UI.setSelectedMicFromSettings = function () {
  984. SettingsMenu.setSelectedMicFromSettings();
  985. };
  986. /**
  987. * Sets camera's <select> element to select camera ID from settings.
  988. */
  989. UI.setSelectedCameraFromSettings = function () {
  990. SettingsMenu.setSelectedCameraFromSettings();
  991. };
  992. /**
  993. * Sets audio outputs's <select> element to select audio output ID from
  994. * settings.
  995. */
  996. UI.setSelectedAudioOutputFromSettings = function () {
  997. SettingsMenu.setSelectedAudioOutputFromSettings();
  998. };
  999. /**
  1000. * Returns the id of the current video shown on large.
  1001. * Currently used by tests (torture).
  1002. */
  1003. UI.getLargeVideoID = function () {
  1004. return VideoLayout.getLargeVideoID();
  1005. };
  1006. /**
  1007. * Returns the current video shown on large.
  1008. * Currently used by tests (torture).
  1009. */
  1010. UI.getLargeVideo = function () {
  1011. return VideoLayout.getLargeVideo();
  1012. };
  1013. /**
  1014. * Shows dialog with a link to FF extension.
  1015. */
  1016. UI.showExtensionRequiredDialog = function (url) {
  1017. messageHandler.openMessageDialog(
  1018. "dialog.extensionRequired",
  1019. "[html]dialog.firefoxExtensionPrompt",
  1020. {url: url});
  1021. };
  1022. /**
  1023. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1024. * 2 button dialog with buttons - cancel and go to web store.
  1025. * @param url {string} the url of the extension.
  1026. */
  1027. UI.showExtensionExternalInstallationDialog = function (url) {
  1028. let submitFunction = function(e,v){
  1029. if (v) {
  1030. e.preventDefault();
  1031. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1032. }
  1033. };
  1034. let closeFunction = function () {
  1035. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1036. };
  1037. messageHandler.openTwoButtonDialog({
  1038. titleKey: 'dialog.externalInstallationTitle',
  1039. msgKey: 'dialog.externalInstallationMsg',
  1040. leftButtonKey: 'dialog.goToStore',
  1041. submitFunction,
  1042. loadedFunction: $.noop,
  1043. closeFunction
  1044. });
  1045. };
  1046. /**
  1047. * Shows dialog with combined information about camera and microphone errors.
  1048. * @param {JitsiTrackError} micError
  1049. * @param {JitsiTrackError} cameraError
  1050. */
  1051. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1052. let dontShowAgain = {
  1053. id: "doNotShowWarningAgain",
  1054. localStorageKey: "doNotShowErrorAgain",
  1055. textKey: "dialog.doNotShowWarningAgain"
  1056. };
  1057. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1058. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1059. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1060. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1061. let showDoNotShowWarning = false;
  1062. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1063. isCameraJitsiTrackErrorAndHasName) {
  1064. showDoNotShowWarning = true;
  1065. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1066. showDoNotShowWarning = true;
  1067. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1068. showDoNotShowWarning = true;
  1069. }
  1070. if (micError) {
  1071. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1072. }
  1073. if (cameraError) {
  1074. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1075. }
  1076. let cameraJitsiTrackErrorMsg = cameraError
  1077. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1078. : undefined;
  1079. let micJitsiTrackErrorMsg = micError
  1080. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1081. : undefined;
  1082. let cameraErrorMsg = cameraError
  1083. ? cameraJitsiTrackErrorMsg ||
  1084. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1085. : "";
  1086. let micErrorMsg = micError
  1087. ? micJitsiTrackErrorMsg ||
  1088. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1089. : "";
  1090. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1091. cameraError.message
  1092. ? `<div>${cameraError.message}</div>`
  1093. : ``;
  1094. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1095. micError.message
  1096. ? `<div>${micError.message}</div>`
  1097. : ``;
  1098. let message = '';
  1099. if (micError) {
  1100. message = `
  1101. ${message}
  1102. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1103. <h4 data-i18n='${micErrorMsg}'></h4>
  1104. ${additionalMicErrorMsg}`;
  1105. }
  1106. if (cameraError) {
  1107. message = `
  1108. ${message}
  1109. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1110. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1111. ${additionalCameraErrorMsg}`;
  1112. }
  1113. // To make sure we don't have multiple error dialogs open at the same time,
  1114. // we will just close the previous one if we are going to show a new one.
  1115. deviceErrorDialog && deviceErrorDialog.close();
  1116. deviceErrorDialog = messageHandler.openDialog(
  1117. getTitleKey(),
  1118. message,
  1119. false,
  1120. {Ok: true},
  1121. function () {},
  1122. null,
  1123. function () {
  1124. // Reset dialog reference to null to avoid memory leaks when
  1125. // user closed the dialog manually.
  1126. deviceErrorDialog = null;
  1127. },
  1128. showDoNotShowWarning ? dontShowAgain : undefined
  1129. );
  1130. function getTitleKey() {
  1131. let title = "dialog.error";
  1132. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1133. if (!cameraError
  1134. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1135. title = "dialog.permissionDenied";
  1136. }
  1137. } else if (cameraError
  1138. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1139. title = "dialog.permissionDenied";
  1140. }
  1141. return title;
  1142. }
  1143. };
  1144. /**
  1145. * Shows error dialog that informs the user that no data is received from the
  1146. * device.
  1147. */
  1148. UI.showTrackNotWorkingDialog = function (stream) {
  1149. messageHandler.openMessageDialog(
  1150. "dialog.error",
  1151. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1152. "dialog.cameraNotSendingData");
  1153. };
  1154. UI.updateDevicesAvailability = function (id, devices) {
  1155. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1156. };
  1157. /**
  1158. * Show shared video.
  1159. * @param {string} id the id of the sender of the command
  1160. * @param {string} url video url
  1161. * @param {string} attributes
  1162. */
  1163. UI.onSharedVideoStart = function (id, url, attributes) {
  1164. if (sharedVideoManager)
  1165. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1166. };
  1167. /**
  1168. * Update shared video.
  1169. * @param {string} id the id of the sender of the command
  1170. * @param {string} url video url
  1171. * @param {string} attributes
  1172. */
  1173. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1174. if (sharedVideoManager)
  1175. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1176. };
  1177. /**
  1178. * Stop showing shared video.
  1179. * @param {string} id the id of the sender of the command
  1180. * @param {string} attributes
  1181. */
  1182. UI.onSharedVideoStop = function (id, attributes) {
  1183. if (sharedVideoManager)
  1184. sharedVideoManager.onSharedVideoStop(id, attributes);
  1185. };
  1186. /**
  1187. * Enables / disables camera toolbar button.
  1188. *
  1189. * @param {boolean} enabled indicates if the camera button should be enabled
  1190. * or disabled
  1191. */
  1192. UI.setCameraButtonEnabled = function (enabled) {
  1193. Toolbar.setVideoIconEnabled(enabled);
  1194. };
  1195. /**
  1196. * Enables / disables microphone toolbar button.
  1197. *
  1198. * @param {boolean} enabled indicates if the microphone button should be
  1199. * enabled or disabled
  1200. */
  1201. UI.setMicrophoneButtonEnabled = function (enabled) {
  1202. Toolbar.setAudioIconEnabled(enabled);
  1203. };
  1204. UI.showRingOverlay = function () {
  1205. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1206. FilmStrip.toggleFilmStrip(false);
  1207. };
  1208. UI.hideRingOverLay = function () {
  1209. if (!RingOverlay.hide())
  1210. return;
  1211. FilmStrip.toggleFilmStrip(true);
  1212. };
  1213. /**
  1214. * Indicates if any the "top" overlays are currently visible. The check includes
  1215. * the call overlay, suspended overlay, GUM permissions overlay
  1216. * and a page reload overlay.
  1217. *
  1218. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1219. */
  1220. UI.isOverlayVisible = function () {
  1221. return RingOverlay.isVisible()
  1222. || SuspendedOverlay.isVisible()
  1223. || PageReloadOverlay.isVisible()
  1224. || GumPermissionsOverlay.isVisible();
  1225. };
  1226. /**
  1227. * Indicates if the ring overlay is currently visible.
  1228. *
  1229. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1230. */
  1231. UI.isRingOverlayVisible = function () {
  1232. return RingOverlay.isVisible();
  1233. };
  1234. /**
  1235. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1236. * @param {string} browser - name of browser for which to show the guidance
  1237. * overlay.
  1238. */
  1239. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1240. GumPermissionsOverlay.show(browser);
  1241. };
  1242. /**
  1243. * Shows suspended overlay with a button to rejoin conference.
  1244. */
  1245. UI.showSuspendedOverlay = function () {
  1246. SuspendedOverlay.show();
  1247. };
  1248. /**
  1249. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1250. */
  1251. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1252. GumPermissionsOverlay.hide();
  1253. };
  1254. module.exports = UI;