Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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