Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  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 message = (
  68. `<div class="input-control">
  69. <label data-i18n="${labelKey}" class="input-control__label"></label>
  70. <input name="displayName" type="text"
  71. data-i18n="[placeholder]defaultNickname"
  72. class="input-control__input"
  73. autofocus>
  74. </div>`
  75. );
  76. // Don't use a translation string, because we're too early in the call and
  77. // the translation may not be initialised.
  78. let buttons = {Ok:true};
  79. let dialog = messageHandler.openDialog(
  80. 'dialog.displayNameRequired',
  81. message,
  82. true,
  83. buttons,
  84. function (e, v, m, f) {
  85. e.preventDefault();
  86. if (v) {
  87. let displayName = f.displayName;
  88. if (displayName) {
  89. UI.inputDisplayNameHandler(displayName);
  90. dialog.close();
  91. return;
  92. }
  93. }
  94. },
  95. function () {
  96. let form = $.prompt.getPrompt();
  97. let input = form.find("input[name='displayName']");
  98. input.focus();
  99. let button = form.find("button");
  100. button.attr("disabled", "disabled");
  101. input.keyup(function () {
  102. if (input.val()) {
  103. button.removeAttr("disabled");
  104. } else {
  105. button.attr("disabled", "disabled");
  106. }
  107. });
  108. }
  109. );
  110. }
  111. /**
  112. * Initialize chat.
  113. */
  114. function setupChat() {
  115. Chat.init(eventEmitter);
  116. $("#toggle_smileys").click(function() {
  117. Chat.toggleSmileys();
  118. });
  119. }
  120. /**
  121. * Initialize toolbars.
  122. */
  123. function setupToolbars() {
  124. Toolbar.init(eventEmitter);
  125. }
  126. /**
  127. * Toggles the application in and out of full screen mode
  128. * (a.k.a. presentation mode in Chrome).
  129. */
  130. UI.toggleFullScreen = function() {
  131. (UIUtil.isFullScreen())
  132. ? UIUtil.exitFullScreen()
  133. : UIUtil.enterFullScreen();
  134. };
  135. /**
  136. * Notify user that server has shut down.
  137. */
  138. UI.notifyGracefulShutdown = function () {
  139. messageHandler.openMessageDialog(
  140. 'dialog.serviceUnavailable',
  141. 'dialog.gracefulShutdown'
  142. );
  143. };
  144. /**
  145. * Notify user that reservation error happened.
  146. */
  147. UI.notifyReservationError = function (code, msg) {
  148. var message = APP.translation.generateTranslationHTML(
  149. "dialog.reservationErrorMsg", {code: code, msg: msg});
  150. messageHandler.openDialog(
  151. "dialog.reservationError", message, true, {}, () => false);
  152. };
  153. /**
  154. * Notify user that he has been kicked from the server.
  155. */
  156. UI.notifyKicked = function () {
  157. messageHandler.openMessageDialog(
  158. "dialog.sessTerminated",
  159. "dialog.kickMessage");
  160. };
  161. /**
  162. * Notify user that conference was destroyed.
  163. * @param reason {string} the reason text
  164. */
  165. UI.notifyConferenceDestroyed = function (reason) {
  166. //FIXME: use Session Terminated from translation, but
  167. // 'reason' text comes from XMPP packet and is not translated
  168. messageHandler.openDialog(
  169. "dialog.sessTerminated", 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 message = (
  653. `<input name="username" type="text"
  654. placeholder="user@domain.net" autofocus>
  655. <input name="password" type="password"
  656. data-i18n="[placeholder]dialog.userPassword"
  657. placeholder="user password">`
  658. );
  659. let submitFunction = (e, v, m, f) => {
  660. if (v) {
  661. if (f.username && f.password) {
  662. callback(f.username, f.password);
  663. }
  664. }
  665. };
  666. messageHandler.openTwoButtonDialog({
  667. titleKey : "dialog.passwordRequired",
  668. msgString: message,
  669. leftButtonKey: 'dialog.Ok',
  670. submitFunction,
  671. focus: ':input:first'
  672. });
  673. };
  674. UI.askForNickname = function () {
  675. return window.prompt('Your nickname (optional)');
  676. };
  677. /**
  678. * Sets muted audio state for participant
  679. */
  680. UI.setAudioMuted = function (id, muted) {
  681. VideoLayout.onAudioMute(id, muted);
  682. if (APP.conference.isLocalId(id)) {
  683. Toolbar.toggleAudioIcon(muted);
  684. }
  685. };
  686. /**
  687. * Sets muted video state for participant
  688. */
  689. UI.setVideoMuted = function (id, muted) {
  690. VideoLayout.onVideoMute(id, muted);
  691. if (APP.conference.isLocalId(id)) {
  692. Toolbar.toggleVideoIcon(muted);
  693. }
  694. };
  695. /**
  696. * Adds a listener that would be notified on the given type of event.
  697. *
  698. * @param type the type of the event we're listening for
  699. * @param listener a function that would be called when notified
  700. */
  701. UI.addListener = function (type, listener) {
  702. eventEmitter.on(type, listener);
  703. };
  704. /**
  705. * Removes the given listener for the given type of event.
  706. *
  707. * @param type the type of the event we're listening for
  708. * @param listener the listener we want to remove
  709. */
  710. UI.removeListener = function (type, listener) {
  711. eventEmitter.removeListener(type, listener);
  712. };
  713. /**
  714. * Emits the event of given type by specifying the parameters in options.
  715. *
  716. * @param type the type of the event we're emitting
  717. * @param options the parameters for the event
  718. */
  719. UI.emitEvent = function (type, options) {
  720. eventEmitter.emit(type, options);
  721. };
  722. UI.clickOnVideo = function (videoNumber) {
  723. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  724. if (remoteVideos.length > videoNumber) {
  725. remoteVideos[videoNumber].click();
  726. }
  727. };
  728. //Used by torture
  729. UI.showToolbar = function (timeout) {
  730. return ToolbarToggler.showToolbar(timeout);
  731. };
  732. //Used by torture
  733. UI.dockToolbar = function (isDock) {
  734. ToolbarToggler.dockToolbar(isDock);
  735. };
  736. /**
  737. * Updates the avatar for participant.
  738. * @param {string} id user id
  739. * @param {string} avatarUrl the URL for the avatar
  740. */
  741. function changeAvatar(id, avatarUrl) {
  742. VideoLayout.changeUserAvatar(id, avatarUrl);
  743. UI.ContactList.changeUserAvatar(id, avatarUrl);
  744. if (APP.conference.isLocalId(id)) {
  745. Profile.changeAvatar(avatarUrl);
  746. }
  747. }
  748. /**
  749. * Update user email.
  750. * @param {string} id user id
  751. * @param {string} email user email
  752. */
  753. UI.setUserEmail = function (id, email) {
  754. // update avatar
  755. Avatar.setUserEmail(id, email);
  756. changeAvatar(id, Avatar.getAvatarUrl(id));
  757. };
  758. /**
  759. * Update user avtar id.
  760. * @param {string} id user id
  761. * @param {string} avatarId user's avatar id
  762. */
  763. UI.setUserAvatarID = function (id, avatarId) {
  764. // update avatar
  765. Avatar.setUserAvatarID(id, avatarId);
  766. changeAvatar(id, Avatar.getAvatarUrl(id));
  767. };
  768. /**
  769. * Update user avatar URL.
  770. * @param {string} id user id
  771. * @param {string} url user avatar url
  772. */
  773. UI.setUserAvatarUrl = function (id, url) {
  774. // update avatar
  775. Avatar.setUserAvatarUrl(id, url);
  776. changeAvatar(id, Avatar.getAvatarUrl(id));
  777. };
  778. /**
  779. * Notify user that connection failed.
  780. * @param {string} stropheErrorMsg raw Strophe error message
  781. */
  782. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  783. var message;
  784. if (stropheErrorMsg) {
  785. message = APP.translation.generateTranslationHTML(
  786. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  787. } else {
  788. message = APP.translation.generateTranslationHTML(
  789. "dialog.connectError");
  790. }
  791. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  792. };
  793. /**
  794. * Notify user that maximum users limit has been reached.
  795. */
  796. UI.notifyMaxUsersLimitReached = function () {
  797. var message = APP.translation.generateTranslationHTML(
  798. "dialog.maxUsersLimitReached");
  799. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  800. };
  801. /**
  802. * Notify user that he was automatically muted when joned the conference.
  803. */
  804. UI.notifyInitiallyMuted = function () {
  805. messageHandler.notify(
  806. null,
  807. "notify.mutedTitle",
  808. "connected",
  809. "notify.muted",
  810. null,
  811. { timeOut: 120000 });
  812. };
  813. /**
  814. * Mark user as dominant speaker.
  815. * @param {string} id user id
  816. */
  817. UI.markDominantSpeaker = function (id) {
  818. VideoLayout.onDominantSpeakerChanged(id);
  819. };
  820. UI.handleLastNEndpoints = function (ids, enteringIds) {
  821. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  822. };
  823. /**
  824. * Will handle notification about participant's connectivity status change.
  825. *
  826. * @param {string} id the id of remote participant(MUC jid)
  827. * @param {boolean} isActive true if the connection is ok or false if the user
  828. * is having connectivity issues.
  829. */
  830. UI.participantConnectionStatusChanged = function (id, isActive) {
  831. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  832. };
  833. /**
  834. * Update audio level visualization for specified user.
  835. * @param {string} id user id
  836. * @param {number} lvl audio level
  837. */
  838. UI.setAudioLevel = function (id, lvl) {
  839. VideoLayout.setAudioLevel(id, lvl);
  840. };
  841. /**
  842. * Update state of desktop sharing buttons.
  843. */
  844. UI.updateDesktopSharingButtons = function () {
  845. Toolbar.updateDesktopSharingButtonState();
  846. };
  847. /**
  848. * Hide connection quality statistics from UI.
  849. */
  850. UI.hideStats = function () {
  851. VideoLayout.hideStats();
  852. };
  853. /**
  854. * Update local connection quality statistics.
  855. * @param {number} percent
  856. * @param {object} stats
  857. */
  858. UI.updateLocalStats = function (percent, stats) {
  859. VideoLayout.updateLocalConnectionStats(percent, stats);
  860. };
  861. /**
  862. * Update connection quality statistics for remote user.
  863. * @param {string} id user id
  864. * @param {number} percent
  865. * @param {object} stats
  866. */
  867. UI.updateRemoteStats = function (id, percent, stats) {
  868. VideoLayout.updateConnectionStats(id, percent, stats);
  869. };
  870. /**
  871. * Mark video as interrupted or not.
  872. * @param {boolean} interrupted if video is interrupted
  873. */
  874. UI.markVideoInterrupted = function (interrupted) {
  875. if (interrupted) {
  876. VideoLayout.onVideoInterrupted();
  877. } else {
  878. VideoLayout.onVideoRestored();
  879. }
  880. };
  881. /**
  882. * Add chat message.
  883. * @param {string} from user id
  884. * @param {string} displayName user nickname
  885. * @param {string} message message text
  886. * @param {number} stamp timestamp when message was created
  887. */
  888. UI.addMessage = function (from, displayName, message, stamp) {
  889. Chat.updateChatConversation(from, displayName, message, stamp);
  890. };
  891. // eslint-disable-next-line no-unused-vars
  892. UI.updateDTMFSupport = function (isDTMFSupported) {
  893. //TODO: enable when the UI is ready
  894. //Toolbar.showDialPadButton(dtmfSupport);
  895. };
  896. /**
  897. * Show user feedback dialog if its required or just show "thank you" dialog.
  898. * @returns {Promise} when dialog is closed.
  899. */
  900. UI.requestFeedback = function () {
  901. if (Feedback.isVisible())
  902. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  903. // Feedback has been submitted already.
  904. else if (Feedback.isEnabled() && Feedback.isSubmitted())
  905. return Promise.resolve();
  906. else
  907. return new Promise(function (resolve) {
  908. if (Feedback.isEnabled()) {
  909. // If the user has already entered feedback, we'll show the
  910. // window and immidiately start the conference dispose timeout.
  911. if (Feedback.getFeedbackScore() > 0) {
  912. Feedback.openFeedbackWindow();
  913. resolve();
  914. } else { // Otherwise we'll wait for user's feedback.
  915. Feedback.openFeedbackWindow(resolve);
  916. }
  917. } else {
  918. // If the feedback functionality isn't enabled we show a thank
  919. // you dialog. Signaling it (true), so the caller
  920. // of requestFeedback can act on it
  921. resolve(true);
  922. }
  923. });
  924. };
  925. UI.updateRecordingState = function (state) {
  926. Recording.updateRecordingState(state);
  927. };
  928. UI.notifyTokenAuthFailed = function () {
  929. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  930. "dialog.tokenAuthFailed");
  931. };
  932. UI.notifyInternalError = function () {
  933. messageHandler.showError( "dialog.internalErrorTitle",
  934. "dialog.internalError");
  935. };
  936. UI.notifyFocusDisconnected = function (focus, retrySec) {
  937. messageHandler.notify(
  938. null, "notify.focus",
  939. 'disconnected', "notify.focusFail",
  940. {component: focus, ms: retrySec}
  941. );
  942. };
  943. /**
  944. * Notify user that focus left the conference so page should be reloaded.
  945. */
  946. UI.notifyFocusLeft = function () {
  947. let msg = APP.translation.generateTranslationHTML(
  948. 'dialog.jicofoUnavailable'
  949. );
  950. messageHandler.openDialog(
  951. 'dialog.serviceUnavailable',
  952. msg,
  953. true, // persistent
  954. [{title: 'retry'}],
  955. function () {
  956. reload();
  957. return false;
  958. }
  959. );
  960. };
  961. /**
  962. * Updates auth info on the UI.
  963. * @param {boolean} isAuthEnabled if authentication is enabled
  964. * @param {string} [login] current login
  965. */
  966. UI.updateAuthInfo = function (isAuthEnabled, login) {
  967. let loggedIn = !!login;
  968. Toolbar.showAuthenticateButton(isAuthEnabled);
  969. if (isAuthEnabled) {
  970. Toolbar.setAuthenticatedIdentity(login);
  971. Toolbar.showLoginButton(!loggedIn);
  972. Toolbar.showLogoutButton(loggedIn);
  973. }
  974. };
  975. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  976. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  977. };
  978. /**
  979. * Notifies interested listeners that the raise hand property has changed.
  980. *
  981. * @param {boolean} isRaisedHand indicates the current state of the
  982. * "raised hand"
  983. */
  984. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  985. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  986. };
  987. /**
  988. * Update list of available physical devices.
  989. * @param {object[]} devices new list of available devices
  990. */
  991. UI.onAvailableDevicesChanged = function (devices) {
  992. SettingsMenu.changeDevicesList(devices);
  993. };
  994. /**
  995. * Sets microphone's <select> element to select microphone ID from settings.
  996. */
  997. UI.setSelectedMicFromSettings = function () {
  998. SettingsMenu.setSelectedMicFromSettings();
  999. };
  1000. /**
  1001. * Sets camera's <select> element to select camera ID from settings.
  1002. */
  1003. UI.setSelectedCameraFromSettings = function () {
  1004. SettingsMenu.setSelectedCameraFromSettings();
  1005. };
  1006. /**
  1007. * Sets audio outputs's <select> element to select audio output ID from
  1008. * settings.
  1009. */
  1010. UI.setSelectedAudioOutputFromSettings = function () {
  1011. SettingsMenu.setSelectedAudioOutputFromSettings();
  1012. };
  1013. /**
  1014. * Returns the id of the current video shown on large.
  1015. * Currently used by tests (torture).
  1016. */
  1017. UI.getLargeVideoID = function () {
  1018. return VideoLayout.getLargeVideoID();
  1019. };
  1020. /**
  1021. * Returns the current video shown on large.
  1022. * Currently used by tests (torture).
  1023. */
  1024. UI.getLargeVideo = function () {
  1025. return VideoLayout.getLargeVideo();
  1026. };
  1027. /**
  1028. * Shows dialog with a link to FF extension.
  1029. */
  1030. UI.showExtensionRequiredDialog = function (url) {
  1031. messageHandler.openMessageDialog(
  1032. "dialog.extensionRequired",
  1033. null,
  1034. APP.translation.generateTranslationHTML(
  1035. "dialog.firefoxExtensionPrompt", {url: url}));
  1036. };
  1037. /**
  1038. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1039. * 2 button dialog with buttons - cancel and go to web store.
  1040. * @param url {string} the url of the extension.
  1041. */
  1042. UI.showExtensionExternalInstallationDialog = function (url) {
  1043. let submitFunction = function(e,v){
  1044. if (v) {
  1045. e.preventDefault();
  1046. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1047. }
  1048. };
  1049. let closeFunction = function () {
  1050. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1051. };
  1052. messageHandler.openTwoButtonDialog({
  1053. titleKey: 'dialog.externalInstallationTitle',
  1054. msgKey: 'dialog.externalInstallationMsg',
  1055. msgString: '',
  1056. leftButtonKey: 'dialog.goToStore',
  1057. submitFunction,
  1058. loadedFunction: $.noop,
  1059. closeFunction
  1060. });
  1061. };
  1062. /**
  1063. * Shows dialog with combined information about camera and microphone errors.
  1064. * @param {JitsiTrackError} micError
  1065. * @param {JitsiTrackError} cameraError
  1066. */
  1067. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1068. let localStoragePropName = "doNotShowErrorAgain";
  1069. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1070. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1071. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1072. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1073. let showDoNotShowWarning = false;
  1074. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1075. isCameraJitsiTrackErrorAndHasName) {
  1076. showDoNotShowWarning = true;
  1077. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1078. showDoNotShowWarning = true;
  1079. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1080. showDoNotShowWarning = true;
  1081. }
  1082. if (micError) {
  1083. localStoragePropName += "-mic-" + micError.name;
  1084. }
  1085. if (cameraError) {
  1086. localStoragePropName += "-camera-" + cameraError.name;
  1087. }
  1088. if (showDoNotShowWarning) {
  1089. if (window.localStorage[localStoragePropName] === "true") {
  1090. return;
  1091. }
  1092. }
  1093. let cameraJitsiTrackErrorMsg = cameraError
  1094. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1095. : undefined;
  1096. let micJitsiTrackErrorMsg = micError
  1097. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1098. : undefined;
  1099. let cameraErrorMsg = cameraError
  1100. ? cameraJitsiTrackErrorMsg ||
  1101. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1102. : "";
  1103. let micErrorMsg = micError
  1104. ? micJitsiTrackErrorMsg ||
  1105. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1106. : "";
  1107. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1108. cameraError.message
  1109. ? `<div>${cameraError.message}</div>`
  1110. : ``;
  1111. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1112. micError.message
  1113. ? `<div>${micError.message}</div>`
  1114. : ``;
  1115. let doNotShowWarningAgainSection = showDoNotShowWarning
  1116. ? `<label>
  1117. <input type='checkbox' id='doNotShowWarningAgain'>
  1118. <span data-i18n='dialog.doNotShowWarningAgain'></span>
  1119. </label>`
  1120. : ``;
  1121. let message = '';
  1122. if (micError) {
  1123. message = `
  1124. ${message}
  1125. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1126. <h4 data-i18n='${micErrorMsg}'></h4>
  1127. ${additionalMicErrorMsg}`;
  1128. }
  1129. if (cameraError) {
  1130. message = `
  1131. ${message}
  1132. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1133. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1134. ${additionalCameraErrorMsg}`;
  1135. }
  1136. message = `${message}${doNotShowWarningAgainSection}`;
  1137. // To make sure we don't have multiple error dialogs open at the same time,
  1138. // we will just close the previous one if we are going to show a new one.
  1139. deviceErrorDialog && deviceErrorDialog.close();
  1140. deviceErrorDialog = messageHandler.openDialog(
  1141. getTitleKey(),
  1142. message,
  1143. false,
  1144. {Ok: true},
  1145. function () {
  1146. let form = $.prompt.getPrompt();
  1147. if (form) {
  1148. let input = form.find("#doNotShowWarningAgain");
  1149. if (input.length) {
  1150. window.localStorage[localStoragePropName] =
  1151. input.prop("checked");
  1152. }
  1153. }
  1154. },
  1155. null,
  1156. function () {
  1157. // Reset dialog reference to null to avoid memory leaks when
  1158. // user closed the dialog manually.
  1159. deviceErrorDialog = null;
  1160. }
  1161. );
  1162. function getTitleKey() {
  1163. let title = "dialog.error";
  1164. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1165. if (!cameraError
  1166. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1167. title = "dialog.permissionDenied";
  1168. }
  1169. } else if (cameraError
  1170. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1171. title = "dialog.permissionDenied";
  1172. }
  1173. return title;
  1174. }
  1175. };
  1176. /**
  1177. * Shows error dialog that informs the user that no data is received from the
  1178. * device.
  1179. */
  1180. UI.showTrackNotWorkingDialog = function (stream) {
  1181. messageHandler.openMessageDialog(
  1182. "dialog.error",
  1183. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1184. "dialog.cameraNotSendingData",
  1185. null);
  1186. };
  1187. UI.updateDevicesAvailability = function (id, devices) {
  1188. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1189. };
  1190. /**
  1191. * Show shared video.
  1192. * @param {string} id the id of the sender of the command
  1193. * @param {string} url video url
  1194. * @param {string} attributes
  1195. */
  1196. UI.onSharedVideoStart = function (id, url, attributes) {
  1197. if (sharedVideoManager)
  1198. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1199. };
  1200. /**
  1201. * Update shared video.
  1202. * @param {string} id the id of the sender of the command
  1203. * @param {string} url video url
  1204. * @param {string} attributes
  1205. */
  1206. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1207. if (sharedVideoManager)
  1208. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1209. };
  1210. /**
  1211. * Stop showing shared video.
  1212. * @param {string} id the id of the sender of the command
  1213. * @param {string} attributes
  1214. */
  1215. UI.onSharedVideoStop = function (id, attributes) {
  1216. if (sharedVideoManager)
  1217. sharedVideoManager.onSharedVideoStop(id, attributes);
  1218. };
  1219. /**
  1220. * Enables / disables camera toolbar button.
  1221. *
  1222. * @param {boolean} enabled indicates if the camera button should be enabled
  1223. * or disabled
  1224. */
  1225. UI.setCameraButtonEnabled = function (enabled) {
  1226. Toolbar.setVideoIconEnabled(enabled);
  1227. };
  1228. /**
  1229. * Enables / disables microphone toolbar button.
  1230. *
  1231. * @param {boolean} enabled indicates if the microphone button should be
  1232. * enabled or disabled
  1233. */
  1234. UI.setMicrophoneButtonEnabled = function (enabled) {
  1235. Toolbar.setAudioIconEnabled(enabled);
  1236. };
  1237. UI.showRingOverlay = function () {
  1238. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1239. FilmStrip.toggleFilmStrip(false);
  1240. };
  1241. UI.hideRingOverLay = function () {
  1242. if (!RingOverlay.hide())
  1243. return;
  1244. FilmStrip.toggleFilmStrip(true);
  1245. };
  1246. /**
  1247. * Indicates if the ring overlay is currently visible.
  1248. *
  1249. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1250. */
  1251. UI.isRingOverlayVisible = function () {
  1252. return RingOverlay.isVisible();
  1253. };
  1254. /**
  1255. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1256. * @param {string} browser - name of browser for which to show the guidance
  1257. * overlay.
  1258. */
  1259. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1260. GumPermissionsOverlay.show(browser);
  1261. };
  1262. /**
  1263. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1264. */
  1265. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1266. GumPermissionsOverlay.hide();
  1267. };
  1268. /**
  1269. * Shows or hides the keyboard shortcuts panel, depending on the current state.'
  1270. */
  1271. UI.toggleKeyboardShortcutsPanel = function() {
  1272. if (!messageHandler.isDialogOpened()) {
  1273. let msg = $('#keyboard-shortcuts').html();
  1274. let buttons = { Close: true };
  1275. messageHandler.openDialog(
  1276. 'keyboardShortcuts.keyboardShortcuts', msg, true, buttons);
  1277. } else {
  1278. messageHandler.closeDialog();
  1279. }
  1280. };
  1281. /**
  1282. * Shows or hides the keyboard shortcuts panel.'
  1283. */
  1284. UI.showKeyboardShortcutsPanel = function(show) {
  1285. if (show) {
  1286. $('#keyboard-shortcuts').show();
  1287. } else {
  1288. $('#keyboard-shortcuts').hide();
  1289. }
  1290. };
  1291. module.exports = UI;