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.

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