您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
  2. var UI = {};
  3. import Chat from "./side_pannels/chat/Chat";
  4. import Toolbar from "./toolbars/Toolbar";
  5. import ToolbarToggler from "./toolbars/ToolbarToggler";
  6. import Avatar from "./avatar/Avatar";
  7. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  8. import UIUtil from "./util/UIUtil";
  9. import UIEvents from "../../service/UI/UIEvents";
  10. import EtherpadManager from './etherpad/Etherpad';
  11. import SharedVideoManager from './shared_video/SharedVideo';
  12. import Recording from "./recording/Recording";
  13. import GumPermissionsOverlay
  14. from './gum_overlay/UserMediaPermissionsGuidanceOverlay';
  15. import PageReloadOverlay from './reload_overlay/PageReloadOverlay';
  16. import VideoLayout from "./videolayout/VideoLayout";
  17. import FilmStrip from "./videolayout/FilmStrip";
  18. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  19. import Profile from "./side_pannels/profile/Profile";
  20. import Settings from "./../settings/Settings";
  21. import RingOverlay from "./ring_overlay/RingOverlay";
  22. import RandomUtil from "../util/RandomUtil";
  23. import UIErrors from './UIErrors';
  24. import { debounce } from "../util/helpers";
  25. var EventEmitter = require("events");
  26. UI.messageHandler = require("./util/MessageHandler");
  27. var messageHandler = UI.messageHandler;
  28. var JitsiPopover = require("./util/JitsiPopover");
  29. var Feedback = require("./feedback/Feedback");
  30. import FollowMe from "../FollowMe";
  31. var eventEmitter = new EventEmitter();
  32. UI.eventEmitter = eventEmitter;
  33. let etherpadManager;
  34. let sharedVideoManager;
  35. let followMeHandler;
  36. let deviceErrorDialog;
  37. const TrackErrors = JitsiMeetJS.errors.track;
  38. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  39. microphone: {},
  40. camera: {}
  41. };
  42. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  43. = "dialog.cameraUnsupportedResolutionError";
  44. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  45. = "dialog.cameraUnknownError";
  46. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  47. = "dialog.cameraPermissionDeniedError";
  48. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  49. = "dialog.cameraNotFoundError";
  50. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  51. = "dialog.cameraConstraintFailedError";
  52. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  53. = "dialog.cameraNotSendingData";
  54. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  55. = "dialog.micUnknownError";
  56. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  57. = "dialog.micPermissionDeniedError";
  58. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  59. = "dialog.micNotFoundError";
  60. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  61. = "dialog.micConstraintFailedError";
  62. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  63. = "dialog.micNotSendingData";
  64. /**
  65. * Prompt user for nickname.
  66. */
  67. function promptDisplayName() {
  68. let labelKey = 'dialog.enterDisplayName';
  69. let message = (
  70. `<div class="input-control">
  71. <label data-i18n="${labelKey}" class="input-control__label"></label>
  72. <input name="displayName" type="text"
  73. data-i18n="[placeholder]defaultNickname"
  74. class="input-control__input"
  75. autofocus>
  76. </div>`
  77. );
  78. // Don't use a translation string, because we're too early in the call and
  79. // the translation may not be initialised.
  80. let buttons = {Ok:true};
  81. let dialog = messageHandler.openDialog(
  82. 'dialog.displayNameRequired',
  83. message,
  84. true,
  85. buttons,
  86. function (e, v, m, f) {
  87. e.preventDefault();
  88. if (v) {
  89. let displayName = f.displayName;
  90. if (displayName) {
  91. UI.inputDisplayNameHandler(displayName);
  92. dialog.close();
  93. return;
  94. }
  95. }
  96. },
  97. function () {
  98. let form = $.prompt.getPrompt();
  99. let input = form.find("input[name='displayName']");
  100. input.focus();
  101. let button = form.find("button");
  102. button.attr("disabled", "disabled");
  103. input.keyup(function () {
  104. if (input.val()) {
  105. button.removeAttr("disabled");
  106. } else {
  107. button.attr("disabled", "disabled");
  108. }
  109. });
  110. }
  111. );
  112. }
  113. /**
  114. * Initialize chat.
  115. */
  116. function setupChat() {
  117. Chat.init(eventEmitter);
  118. $("#toggle_smileys").click(function() {
  119. Chat.toggleSmileys();
  120. });
  121. }
  122. /**
  123. * Initialize toolbars.
  124. */
  125. function setupToolbars() {
  126. Toolbar.init(eventEmitter);
  127. }
  128. /**
  129. * Toggles the application in and out of full screen mode
  130. * (a.k.a. presentation mode in Chrome).
  131. */
  132. UI.toggleFullScreen = function() {
  133. (UIUtil.isFullScreen())
  134. ? UIUtil.exitFullScreen()
  135. : UIUtil.enterFullScreen();
  136. };
  137. /**
  138. * Notify user that server has shut down.
  139. */
  140. UI.notifyGracefulShutdown = function () {
  141. messageHandler.openMessageDialog(
  142. 'dialog.serviceUnavailable',
  143. 'dialog.gracefulShutdown'
  144. );
  145. };
  146. /**
  147. * Notify user that reservation error happened.
  148. */
  149. UI.notifyReservationError = function (code, msg) {
  150. var message = APP.translation.generateTranslationHTML(
  151. "dialog.reservationErrorMsg", {code: code, msg: msg});
  152. messageHandler.openDialog(
  153. "dialog.reservationError", message, true, {}, () => false);
  154. };
  155. /**
  156. * Notify user that he has been kicked from the server.
  157. */
  158. UI.notifyKicked = function () {
  159. messageHandler.openMessageDialog(
  160. "dialog.sessTerminated",
  161. "dialog.kickMessage");
  162. };
  163. /**
  164. * Notify user that conference was destroyed.
  165. * @param reason {string} the reason text
  166. */
  167. UI.notifyConferenceDestroyed = function (reason) {
  168. //FIXME: use Session Terminated from translation, but
  169. // 'reason' text comes from XMPP packet and is not translated
  170. messageHandler.openDialog(
  171. "dialog.sessTerminated", reason, true, {}, () => false);
  172. };
  173. /**
  174. * Show chat error.
  175. * @param err the Error
  176. * @param msg
  177. */
  178. UI.showChatError = function (err, msg) {
  179. if (interfaceConfig.filmStripOnly) {
  180. return;
  181. }
  182. Chat.chatAddError(err, msg);
  183. };
  184. /**
  185. * Change nickname for the user.
  186. * @param {string} id user id
  187. * @param {string} displayName new nickname
  188. */
  189. UI.changeDisplayName = function (id, displayName) {
  190. UI.ContactList.onDisplayNameChange(id, displayName);
  191. VideoLayout.onDisplayNameChanged(id, displayName);
  192. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  193. Profile.changeDisplayName(displayName);
  194. Chat.setChatConversationMode(!!displayName);
  195. }
  196. };
  197. /**
  198. * Shows/hides the indication about local connection being interrupted.
  199. *
  200. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  201. * currently in the interrupted state or <tt>false</tt> if the connection
  202. * is fine.
  203. */
  204. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  205. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  206. };
  207. /**
  208. * Sets the "raised hand" status for a participant.
  209. */
  210. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  211. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  212. if (raisedHandStatus) {
  213. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  214. 'connected', 'notify.raisedHand');
  215. }
  216. };
  217. /**
  218. * Sets the local "raised hand" status.
  219. */
  220. UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
  221. VideoLayout.setRaisedHandStatus(
  222. APP.conference.getMyUserId(),
  223. raisedHandStatus);
  224. };
  225. /**
  226. * Initialize conference UI.
  227. */
  228. UI.initConference = function () {
  229. let id = APP.conference.getMyUserId();
  230. // Add myself to the contact list.
  231. UI.ContactList.addContact(id, true);
  232. // Update default button states before showing the toolbar
  233. // if local role changes buttons state will be again updated.
  234. UI.updateLocalRole(APP.conference.isModerator);
  235. UI.showToolbar();
  236. let displayName = config.displayJids ? id : Settings.getDisplayName();
  237. if (displayName) {
  238. UI.changeDisplayName('localVideoContainer', displayName);
  239. }
  240. // Make sure we configure our avatar id, before creating avatar for us
  241. let email = Settings.getEmail();
  242. if (email) {
  243. UI.setUserEmail(id, email);
  244. } else {
  245. UI.setUserAvatarID(id, Settings.getAvatarId());
  246. }
  247. Toolbar.checkAutoEnableDesktopSharing();
  248. if(!interfaceConfig.filmStripOnly) {
  249. Feedback.init(eventEmitter);
  250. }
  251. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  252. // other participants' UI. Consequently, it needs (1) read and write access
  253. // to the UI (depending on the moderator role of the local participant) and
  254. // (2) APP.conference as means of communication between the participants.
  255. followMeHandler = new FollowMe(APP.conference, UI);
  256. UIUtil.activateTooltips();
  257. };
  258. UI.mucJoined = function () {
  259. VideoLayout.mucJoined();
  260. };
  261. /***
  262. * Handler for toggling filmstrip
  263. */
  264. UI.handleToggleFilmStrip = () => {
  265. UI.toggleFilmStrip();
  266. };
  267. /**
  268. * Sets tooltip defaults.
  269. *
  270. * @private
  271. */
  272. function _setTooltipDefaults() {
  273. $.fn.tooltip.defaults = {
  274. opacity: 1, //defaults to 1
  275. offset: 1,
  276. delayIn: 0, //defaults to 500
  277. hoverable: true,
  278. hideOnClick: true,
  279. aria: true
  280. };
  281. }
  282. /**
  283. * Setup some UI event listeners.
  284. */
  285. function registerListeners() {
  286. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  287. if (etherpadManager) {
  288. etherpadManager.toggleEtherpad();
  289. }
  290. });
  291. UI.addListener(UIEvents.SHARED_VIDEO_CLICKED, function () {
  292. if (sharedVideoManager) {
  293. sharedVideoManager.toggleSharedVideo();
  294. }
  295. });
  296. UI.addListener(UIEvents.TOGGLE_FULLSCREEN, UI.toggleFullScreen);
  297. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  298. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  299. UI.toggleSidePanel("settings_container");
  300. });
  301. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  302. UI.addListener( UIEvents.TOGGLE_PROFILE, function() {
  303. if(APP.tokenData.isGuest)
  304. UI.toggleSidePanel("profile_container");
  305. });
  306. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.handleToggleFilmStrip);
  307. UI.addListener(UIEvents.FOLLOW_ME_ENABLED, function (isEnabled) {
  308. if (followMeHandler)
  309. followMeHandler.enableFollowMe(isEnabled);
  310. });
  311. }
  312. /**
  313. * Setup some DOM event listeners.
  314. */
  315. function bindEvents() {
  316. function onResize() {
  317. SideContainerToggler.resize();
  318. VideoLayout.resizeVideoArea();
  319. }
  320. // Resize and reposition videos in full screen mode.
  321. $(document).on(
  322. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  323. () => {
  324. eventEmitter.emit( UIEvents.FULLSCREEN_TOGGLED,
  325. UIUtil.isFullScreen());
  326. onResize();
  327. }
  328. );
  329. $(window).resize(onResize);
  330. }
  331. /**
  332. * Returns the shared document manager object.
  333. * @return {EtherpadManager} the shared document manager object
  334. */
  335. UI.getSharedVideoManager = function () {
  336. return sharedVideoManager;
  337. };
  338. /**
  339. * Starts the UI module and initializes all related components.
  340. *
  341. * @returns {boolean} true if the UI is ready and the conference should be
  342. * esablished, false - otherwise (for example in the case of welcome page)
  343. */
  344. UI.start = function () {
  345. document.title = interfaceConfig.APP_NAME;
  346. var setupWelcomePage = null;
  347. if(config.enableWelcomePage && window.location.pathname == "/" &&
  348. Settings.isWelcomePageEnabled()) {
  349. $("#videoconference_page").hide();
  350. if (!setupWelcomePage)
  351. setupWelcomePage = require("./welcome_page/WelcomePage");
  352. setupWelcomePage();
  353. // Return false to indicate that the UI hasn't been fully started and
  354. // conference ready. We're still waiting for input from the user.
  355. return false;
  356. }
  357. $("#welcome_page").hide();
  358. // Set the defaults for prompt dialogs.
  359. $.prompt.setDefaults({persistent: false});
  360. // Set the defaults for tooltips.
  361. _setTooltipDefaults();
  362. registerListeners();
  363. ToolbarToggler.init();
  364. SideContainerToggler.init(eventEmitter);
  365. FilmStrip.init(eventEmitter);
  366. VideoLayout.init(eventEmitter);
  367. if (!interfaceConfig.filmStripOnly) {
  368. VideoLayout.initLargeVideo();
  369. }
  370. VideoLayout.resizeVideoArea(true, true);
  371. bindEvents();
  372. sharedVideoManager = new SharedVideoManager(eventEmitter);
  373. if (!interfaceConfig.filmStripOnly) {
  374. let debouncedShowToolbar = debounce(() => {
  375. UI.showToolbar();
  376. }, 100, { leading: true, trailing: false });
  377. $("#videoconference_page").mousemove(debouncedShowToolbar);
  378. setupToolbars();
  379. setupChat();
  380. // Initialise the recording module.
  381. if (config.enableRecording)
  382. Recording.init(eventEmitter, config.recordingType);
  383. // Display notice message at the top of the toolbar
  384. if (config.noticeMessage) {
  385. $('#noticeText').text(config.noticeMessage);
  386. $('#notice').css({display: 'block'});
  387. }
  388. } else {
  389. $("#mainToolbarContainer").css("display", "none");
  390. FilmStrip.setupFilmStripOnly();
  391. messageHandler.enableNotifications(false);
  392. JitsiPopover.enabled = false;
  393. }
  394. document.title = interfaceConfig.APP_NAME;
  395. if(config.requireDisplayName) {
  396. if (!APP.settings.getDisplayName()) {
  397. promptDisplayName();
  398. }
  399. }
  400. if (!interfaceConfig.filmStripOnly) {
  401. toastr.options = {
  402. "closeButton": true,
  403. "debug": false,
  404. "positionClass": "notification-bottom-right",
  405. "onclick": null,
  406. "showDuration": "300",
  407. "hideDuration": "1000",
  408. "timeOut": "2000",
  409. "extendedTimeOut": "1000",
  410. "showEasing": "swing",
  411. "hideEasing": "linear",
  412. "showMethod": "fadeIn",
  413. "hideMethod": "fadeOut",
  414. "newestOnTop": false
  415. };
  416. SettingsMenu.init(eventEmitter);
  417. Profile.init(eventEmitter);
  418. }
  419. if(APP.tokenData.callee) {
  420. UI.showRingOverlay();
  421. }
  422. // Return true to indicate that the UI has been fully started and
  423. // conference ready.
  424. return true;
  425. };
  426. /**
  427. * Show local stream on UI.
  428. * @param {JitsiTrack} track stream to show
  429. */
  430. UI.addLocalStream = function (track) {
  431. switch (track.getType()) {
  432. case 'audio':
  433. VideoLayout.changeLocalAudio(track);
  434. break;
  435. case 'video':
  436. VideoLayout.changeLocalVideo(track);
  437. break;
  438. default:
  439. console.error("Unknown stream type: " + track.getType());
  440. break;
  441. }
  442. };
  443. /**
  444. * Show remote stream on UI.
  445. * @param {JitsiTrack} track stream to show
  446. */
  447. UI.addRemoteStream = function (track) {
  448. VideoLayout.onRemoteStreamAdded(track);
  449. };
  450. /**
  451. * Removed remote stream from UI.
  452. * @param {JitsiTrack} track stream to remove
  453. */
  454. UI.removeRemoteStream = function (track) {
  455. VideoLayout.onRemoteStreamRemoved(track);
  456. };
  457. /**
  458. * Update chat subject.
  459. * @param {string} subject new chat subject
  460. */
  461. UI.setSubject = function (subject) {
  462. Chat.setSubject(subject);
  463. };
  464. /**
  465. * Setup and show Etherpad.
  466. * @param {string} name etherpad id
  467. */
  468. UI.initEtherpad = function (name) {
  469. if (etherpadManager || !config.etherpad_base || !name) {
  470. return;
  471. }
  472. console.log('Etherpad is enabled');
  473. etherpadManager
  474. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  475. Toolbar.showEtherpadButton();
  476. };
  477. /**
  478. * Returns the shared document manager object.
  479. * @return {EtherpadManager} the shared document manager object
  480. */
  481. UI.getSharedDocumentManager = function () {
  482. return etherpadManager;
  483. };
  484. /**
  485. * Show user on UI.
  486. * @param {JitsiParticipant} user
  487. */
  488. UI.addUser = function (user) {
  489. var id = user.getId();
  490. var displayName = user.getDisplayName();
  491. UI.hideRingOverLay();
  492. UI.ContactList.addContact(id);
  493. messageHandler.notify(
  494. displayName,'notify.somebody', 'connected', 'notify.connected'
  495. );
  496. if (!config.startAudioMuted ||
  497. config.startAudioMuted > APP.conference.membersCount)
  498. UIUtil.playSoundNotification('userJoined');
  499. // Add Peer's container
  500. VideoLayout.addParticipantContainer(user);
  501. // Configure avatar
  502. UI.setUserEmail(id);
  503. // set initial display name
  504. if(displayName)
  505. UI.changeDisplayName(id, displayName);
  506. };
  507. /**
  508. * Remove user from UI.
  509. * @param {string} id user id
  510. * @param {string} displayName user nickname
  511. */
  512. UI.removeUser = function (id, displayName) {
  513. UI.ContactList.removeContact(id);
  514. messageHandler.notify(
  515. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  516. );
  517. if (!config.startAudioMuted
  518. || config.startAudioMuted > APP.conference.membersCount) {
  519. UIUtil.playSoundNotification('userLeft');
  520. }
  521. VideoLayout.removeParticipantContainer(id);
  522. };
  523. /**
  524. * Update videotype for specified user.
  525. * @param {string} id user id
  526. * @param {string} newVideoType new videotype
  527. */
  528. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  529. VideoLayout.onVideoTypeChanged(id, newVideoType);
  530. };
  531. /**
  532. * Update local user role and show notification if user is moderator.
  533. * @param {boolean} isModerator if local user is moderator or not
  534. */
  535. UI.updateLocalRole = function (isModerator) {
  536. VideoLayout.showModeratorIndicator();
  537. Toolbar.showSipCallButton(isModerator);
  538. Toolbar.showSharedVideoButton(isModerator);
  539. Recording.showRecordingButton(isModerator);
  540. SettingsMenu.showStartMutedOptions(isModerator);
  541. SettingsMenu.showFollowMeOptions(isModerator);
  542. if (isModerator) {
  543. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  544. messageHandler
  545. .notify(null, "notify.me", 'connected', "notify.moderator");
  546. Recording.checkAutoRecord();
  547. }
  548. };
  549. /**
  550. * Check the role for the user and reflect it in the UI, moderator ui indication
  551. * and notifies user who is the moderator
  552. * @param user to check for moderator
  553. */
  554. UI.updateUserRole = function (user) {
  555. VideoLayout.showModeratorIndicator();
  556. // We don't need to show moderator notifications when the focus (moderator)
  557. // indicator is disabled.
  558. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  559. return;
  560. }
  561. var displayName = user.getDisplayName();
  562. if (displayName) {
  563. messageHandler.notify(
  564. displayName, 'notify.somebody',
  565. 'connected', 'notify.grantedTo', {
  566. to: UIUtil.escapeHtml(displayName)
  567. }
  568. );
  569. } else {
  570. messageHandler.notify(
  571. '', 'notify.somebody',
  572. 'connected', 'notify.grantedToUnknown', {}
  573. );
  574. }
  575. };
  576. /**
  577. * Toggles smileys in the chat.
  578. */
  579. UI.toggleSmileys = function () {
  580. Chat.toggleSmileys();
  581. };
  582. /**
  583. * Toggles film strip.
  584. */
  585. UI.toggleFilmStrip = function () {
  586. var self = FilmStrip;
  587. self.toggleFilmStrip.apply(self, arguments);
  588. VideoLayout.resizeVideoArea(true, false);
  589. };
  590. /**
  591. * Indicates if the film strip is currently visible or not.
  592. * @returns {true} if the film strip is currently visible, otherwise
  593. */
  594. UI.isFilmStripVisible = function () {
  595. return FilmStrip.isFilmStripVisible();
  596. };
  597. /**
  598. * Toggles chat panel.
  599. */
  600. UI.toggleChat = function () {
  601. UI.toggleSidePanel("chat_container");
  602. };
  603. /**
  604. * Toggles contact list panel.
  605. */
  606. UI.toggleContactList = function () {
  607. UI.toggleSidePanel("contacts_container");
  608. };
  609. /**
  610. * Toggles the given side panel.
  611. *
  612. * @param {String} sidePanelId the identifier of the side panel to toggle
  613. */
  614. UI.toggleSidePanel = function (sidePanelId) {
  615. SideContainerToggler.toggle(sidePanelId);
  616. };
  617. /**
  618. * Handle new user display name.
  619. */
  620. UI.inputDisplayNameHandler = function (newDisplayName) {
  621. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  622. };
  623. /**
  624. * Return the type of the remote video.
  625. * @param jid the jid for the remote video
  626. * @returns the video type video or screen.
  627. */
  628. UI.getRemoteVideoType = function (jid) {
  629. return VideoLayout.getRemoteVideoType(jid);
  630. };
  631. UI.connectionIndicatorShowMore = function(id) {
  632. VideoLayout.showMore(id);
  633. return false;
  634. };
  635. // FIXME check if someone user this
  636. UI.showLoginPopup = function(callback) {
  637. console.log('password is required');
  638. let message = (
  639. `<input name="username" type="text"
  640. placeholder="user@domain.net" autofocus>
  641. <input name="password" type="password"
  642. data-i18n="[placeholder]dialog.userPassword"
  643. placeholder="user password">`
  644. );
  645. let submitFunction = (e, v, m, f) => {
  646. if (v) {
  647. if (f.username && f.password) {
  648. callback(f.username, f.password);
  649. }
  650. }
  651. };
  652. messageHandler.openTwoButtonDialog({
  653. titleKey : "dialog.passwordRequired",
  654. msgString: message,
  655. leftButtonKey: 'dialog.Ok',
  656. submitFunction,
  657. focus: ':input:first'
  658. });
  659. };
  660. UI.askForNickname = function () {
  661. return window.prompt('Your nickname (optional)');
  662. };
  663. /**
  664. * Sets muted audio state for participant
  665. */
  666. UI.setAudioMuted = function (id, muted) {
  667. VideoLayout.onAudioMute(id, muted);
  668. if (APP.conference.isLocalId(id)) {
  669. Toolbar.toggleAudioIcon(muted);
  670. }
  671. };
  672. /**
  673. * Sets muted video state for participant
  674. */
  675. UI.setVideoMuted = function (id, muted) {
  676. VideoLayout.onVideoMute(id, muted);
  677. if (APP.conference.isLocalId(id)) {
  678. Toolbar.toggleVideoIcon(muted);
  679. }
  680. };
  681. /**
  682. * Adds a listener that would be notified on the given type of event.
  683. *
  684. * @param type the type of the event we're listening for
  685. * @param listener a function that would be called when notified
  686. */
  687. UI.addListener = function (type, listener) {
  688. eventEmitter.on(type, listener);
  689. };
  690. /**
  691. * Removes the given listener for the given type of event.
  692. *
  693. * @param type the type of the event we're listening for
  694. * @param listener the listener we want to remove
  695. */
  696. UI.removeListener = function (type, listener) {
  697. eventEmitter.removeListener(type, listener);
  698. };
  699. /**
  700. * Emits the event of given type by specifying the parameters in options.
  701. *
  702. * @param type the type of the event we're emitting
  703. * @param options the parameters for the event
  704. */
  705. UI.emitEvent = function (type, options) {
  706. eventEmitter.emit(type, options);
  707. };
  708. UI.clickOnVideo = function (videoNumber) {
  709. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  710. if (remoteVideos.length > videoNumber) {
  711. remoteVideos[videoNumber].click();
  712. }
  713. };
  714. //Used by torture
  715. UI.showToolbar = function (timeout) {
  716. return ToolbarToggler.showToolbar(timeout);
  717. };
  718. //Used by torture
  719. UI.dockToolbar = function (isDock) {
  720. ToolbarToggler.dockToolbar(isDock);
  721. };
  722. /**
  723. * Updates the avatar for participant.
  724. * @param {string} id user id
  725. * @param {string} avatarUrl the URL for the avatar
  726. */
  727. function changeAvatar(id, avatarUrl) {
  728. VideoLayout.changeUserAvatar(id, avatarUrl);
  729. 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;