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

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