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.

UI.js 40KB

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