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

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