您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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