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

UI.js 41KB

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