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

UI.js 42KB

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