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

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