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.

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