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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  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. // Do not include query parameters in the invite URL
  255. // "https:" + "//" + "example.com:8888" + "/SomeConference1245"
  256. var inviteURL = window.location.protocol + "//" +
  257. window.location.host + window.location.pathname;
  258. Toolbar.updateRoomUrl(inviteURL);
  259. // Clean up the URL displayed by the browser
  260. if (window.history && typeof window.history.replaceState === 'function') {
  261. window.history.replaceState({}, document.title, inviteURL);
  262. }
  263. // Add myself to the contact list.
  264. ContactList.addContact(id);
  265. //update default button states before showing the toolbar
  266. //if local role changes buttons state will be again updated
  267. UI.updateLocalRole(false);
  268. // Once we've joined the muc show the toolbar
  269. if (!RingOverlay.isDisplayed()) {
  270. ToolbarToggler.showToolbar();
  271. }
  272. let displayName = config.displayJids ? id : Settings.getDisplayName();
  273. if (displayName) {
  274. UI.changeDisplayName('localVideoContainer', displayName);
  275. }
  276. // Make sure we configure our avatar id, before creating avatar for us
  277. UI.setUserEmail(id, Settings.getEmail());
  278. Toolbar.checkAutoEnableDesktopSharing();
  279. if(!interfaceConfig.filmStripOnly) {
  280. Feedback.init(eventEmitter);
  281. }
  282. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  283. // other participants' UI. Consequently, it needs (1) read and write access
  284. // to the UI (depending on the moderator role of the local participant) and
  285. // (2) APP.conference as means of communication between the participants.
  286. followMeHandler = new FollowMe(APP.conference, UI);
  287. };
  288. UI.mucJoined = function () {
  289. VideoLayout.mucJoined();
  290. };
  291. /**
  292. * Setup some UI event listeners.
  293. */
  294. function registerListeners() {
  295. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  296. if (etherpadManager) {
  297. etherpadManager.toggleEtherpad();
  298. }
  299. });
  300. UI.addListener(UIEvents.SHARED_VIDEO_CLICKED, function () {
  301. if (sharedVideoManager) {
  302. sharedVideoManager.toggleSharedVideo();
  303. }
  304. });
  305. UI.addListener(UIEvents.FULLSCREEN_TOGGLE, toggleFullScreen);
  306. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  307. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  308. PanelToggler.toggleSettingsMenu();
  309. });
  310. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  311. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, function () {
  312. UI.toggleFilmStrip();
  313. VideoLayout.resizeVideoArea(PanelToggler.isVisible(), true, false);
  314. });
  315. UI.addListener(UIEvents.FOLLOW_ME_ENABLED, function (isEnabled) {
  316. if (followMeHandler)
  317. followMeHandler.enableFollowMe(isEnabled);
  318. });
  319. }
  320. /**
  321. * Setup some DOM event listeners.
  322. */
  323. function bindEvents() {
  324. function onResize() {
  325. PanelToggler.resizeChat();
  326. VideoLayout.resizeVideoArea(PanelToggler.isVisible());
  327. }
  328. // Resize and reposition videos in full screen mode.
  329. $(document).on(
  330. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  331. onResize
  332. );
  333. $(window).resize(onResize);
  334. }
  335. /**
  336. * Returns the shared document manager object.
  337. * @return {EtherpadManager} the shared document manager object
  338. */
  339. UI.getSharedVideoManager = function () {
  340. return sharedVideoManager;
  341. };
  342. /**
  343. * Starts the UI module and initializes all related components.
  344. *
  345. * @returns {boolean} true if the UI is ready and the conference should be
  346. * esablished, false - otherwise (for example in the case of welcome page)
  347. */
  348. UI.start = function () {
  349. document.title = interfaceConfig.APP_NAME;
  350. var setupWelcomePage = null;
  351. if(config.enableWelcomePage && window.location.pathname == "/" &&
  352. Settings.isWelcomePageEnabled()) {
  353. $("#videoconference_page").hide();
  354. if (!setupWelcomePage)
  355. setupWelcomePage = require("./welcome_page/WelcomePage");
  356. setupWelcomePage();
  357. // Return false to indicate that the UI hasn't been fully started and
  358. // conference ready. We're still waiting for input from the user.
  359. return false;
  360. }
  361. $("#welcome_page").hide();
  362. // Set the defaults for prompt dialogs.
  363. $.prompt.setDefaults({persistent: false});
  364. registerListeners();
  365. ToolbarToggler.init();
  366. BottomToolbar.init();
  367. FilmStrip.init(eventEmitter);
  368. VideoLayout.init(eventEmitter);
  369. if (!interfaceConfig.filmStripOnly) {
  370. VideoLayout.initLargeVideo(PanelToggler.isVisible());
  371. }
  372. VideoLayout.resizeVideoArea(PanelToggler.isVisible(), true, true);
  373. ContactList.init(eventEmitter);
  374. bindEvents();
  375. sharedVideoManager = new SharedVideoManager(eventEmitter);
  376. if (!interfaceConfig.filmStripOnly) {
  377. $("#videospace").mousemove(function () {
  378. return ToolbarToggler.showToolbar();
  379. });
  380. setupToolbars();
  381. setupChat();
  382. // Initialise the recording module.
  383. if (config.enableRecording)
  384. Recording.init(eventEmitter, config.recordingType);
  385. // Display notice message at the top of the toolbar
  386. if (config.noticeMessage) {
  387. $('#noticeText').text(config.noticeMessage);
  388. $('#notice').css({display: 'block'});
  389. }
  390. $("#downloadlog").click(function (event) {
  391. let logs = APP.conference.getLogs();
  392. let data = encodeURIComponent(JSON.stringify(logs, null, ' '));
  393. let elem = event.target.parentNode;
  394. elem.download = 'meetlog.json';
  395. elem.href = 'data:application/json;charset=utf-8,\n' + data;
  396. });
  397. } else {
  398. $("#header").css("display", "none");
  399. $("#downloadlog").css("display", "none");
  400. BottomToolbar.hide();
  401. FilmStrip.setupFilmStripOnly();
  402. messageHandler.enableNotifications(false);
  403. $('body').popover("disable");
  404. JitsiPopover.enabled = false;
  405. }
  406. document.title = interfaceConfig.APP_NAME;
  407. if(config.requireDisplayName) {
  408. if (!APP.settings.getDisplayName()) {
  409. promptDisplayName();
  410. }
  411. }
  412. if (!interfaceConfig.filmStripOnly) {
  413. toastr.options = {
  414. "closeButton": true,
  415. "debug": false,
  416. "positionClass": "notification-bottom-right",
  417. "onclick": null,
  418. "showDuration": "300",
  419. "hideDuration": "1000",
  420. "timeOut": "2000",
  421. "extendedTimeOut": "1000",
  422. "showEasing": "swing",
  423. "hideEasing": "linear",
  424. "showMethod": "fadeIn",
  425. "hideMethod": "fadeOut",
  426. "reposition": function () {
  427. if (PanelToggler.isVisible()) {
  428. $("#toast-container").addClass("notification-bottom-right-center");
  429. } else {
  430. $("#toast-container").removeClass("notification-bottom-right-center");
  431. }
  432. },
  433. "newestOnTop": false
  434. };
  435. SettingsMenu.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. function chatAddError(errorMessage, originalText) {
  476. return Chat.chatAddError(errorMessage, originalText);
  477. }
  478. /**
  479. * Update chat subject.
  480. * @param {string} subject new chat subject
  481. */
  482. UI.setSubject = function (subject) {
  483. Chat.setSubject(subject);
  484. };
  485. /**
  486. * Setup and show Etherpad.
  487. * @param {string} name etherpad id
  488. */
  489. UI.initEtherpad = function (name) {
  490. if (etherpadManager || !config.etherpad_base || !name) {
  491. return;
  492. }
  493. console.log('Etherpad is enabled');
  494. etherpadManager
  495. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  496. Toolbar.showEtherpadButton();
  497. };
  498. /**
  499. * Returns the shared document manager object.
  500. * @return {EtherpadManager} the shared document manager object
  501. */
  502. UI.getSharedDocumentManager = function () {
  503. return etherpadManager;
  504. };
  505. /**
  506. * Show user on UI.
  507. * @param {string} id user id
  508. * @param {string} displayName user nickname
  509. */
  510. UI.addUser = function (id, displayName) {
  511. UI.hideRingOverLay();
  512. ContactList.addContact(id);
  513. messageHandler.notify(
  514. displayName,'notify.somebody', 'connected', 'notify.connected'
  515. );
  516. if (!config.startAudioMuted ||
  517. config.startAudioMuted > APP.conference.membersCount)
  518. UIUtil.playSoundNotification('userJoined');
  519. // Add Peer's container
  520. VideoLayout.addParticipantContainer(id);
  521. // Configure avatar
  522. UI.setUserEmail(id);
  523. // set initial display name
  524. if(displayName)
  525. UI.changeDisplayName(id, displayName);
  526. };
  527. /**
  528. * Remove user from UI.
  529. * @param {string} id user id
  530. * @param {string} displayName user nickname
  531. */
  532. UI.removeUser = function (id, displayName) {
  533. ContactList.removeContact(id);
  534. messageHandler.notify(
  535. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  536. );
  537. if (!config.startAudioMuted
  538. || config.startAudioMuted > APP.conference.membersCount) {
  539. UIUtil.playSoundNotification('userLeft');
  540. }
  541. VideoLayout.removeParticipantContainer(id);
  542. };
  543. UI.updateUserStatus = function (id, status) {
  544. VideoLayout.setPresenceStatus(id, status);
  545. };
  546. /**
  547. * Update videotype for specified user.
  548. * @param {string} id user id
  549. * @param {string} newVideoType new videotype
  550. */
  551. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  552. VideoLayout.onVideoTypeChanged(id, newVideoType);
  553. };
  554. /**
  555. * Update local user role and show notification if user is moderator.
  556. * @param {boolean} isModerator if local user is moderator or not
  557. */
  558. UI.updateLocalRole = function (isModerator) {
  559. VideoLayout.showModeratorIndicator();
  560. Toolbar.showSipCallButton(isModerator);
  561. Toolbar.showSharedVideoButton(isModerator);
  562. Recording.showRecordingButton(isModerator);
  563. SettingsMenu.showStartMutedOptions(isModerator);
  564. SettingsMenu.showFollowMeOptions(isModerator);
  565. if (isModerator) {
  566. messageHandler.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. if (!user.isModerator()) {
  578. return;
  579. }
  580. var displayName = user.getDisplayName();
  581. if (displayName) {
  582. messageHandler.notify(
  583. displayName, 'notify.somebody',
  584. 'connected', 'notify.grantedTo', {
  585. to: UIUtil.escapeHtml(displayName)
  586. }
  587. );
  588. } else {
  589. messageHandler.notify(
  590. '', 'notify.somebody',
  591. 'connected', 'notify.grantedToUnknown', {}
  592. );
  593. }
  594. };
  595. /**
  596. * Toggles smileys in the chat.
  597. */
  598. UI.toggleSmileys = function () {
  599. Chat.toggleSmileys();
  600. };
  601. /**
  602. * Toggles film strip.
  603. */
  604. UI.toggleFilmStrip = function () {
  605. var self = FilmStrip;
  606. self.toggleFilmStrip.apply(self, arguments);
  607. };
  608. /**
  609. * Indicates if the film strip is currently visible or not.
  610. * @returns {true} if the film strip is currently visible, otherwise
  611. */
  612. UI.isFilmStripVisible = function () {
  613. return FilmStrip.isFilmStripVisible();
  614. };
  615. /**
  616. * Toggles chat panel.
  617. */
  618. UI.toggleChat = function () {
  619. PanelToggler.toggleChat();
  620. };
  621. /**
  622. * Toggles contact list panel.
  623. */
  624. UI.toggleContactList = function () {
  625. PanelToggler.toggleContactList();
  626. };
  627. /**
  628. * Handle new user display name.
  629. */
  630. UI.inputDisplayNameHandler = function (newDisplayName) {
  631. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  632. };
  633. /**
  634. * Return the type of the remote video.
  635. * @param jid the jid for the remote video
  636. * @returns the video type video or screen.
  637. */
  638. UI.getRemoteVideoType = function (jid) {
  639. return VideoLayout.getRemoteVideoType(jid);
  640. };
  641. UI.connectionIndicatorShowMore = function(id) {
  642. VideoLayout.showMore(id);
  643. };
  644. // FIXME check if someone user this
  645. UI.showLoginPopup = function(callback) {
  646. console.log('password is required');
  647. var message = '<h2 data-i18n="dialog.passwordRequired">';
  648. message += APP.translation.translateString(
  649. "dialog.passwordRequired");
  650. message += '</h2>' +
  651. '<input name="username" type="text" ' +
  652. 'placeholder="user@domain.net" autofocus>' +
  653. '<input name="password" ' +
  654. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  655. ' placeholder="user password">';
  656. messageHandler.openTwoButtonDialog(null, null, null, message,
  657. true,
  658. "dialog.Ok",
  659. function (e, v, m, f) {
  660. if (v) {
  661. if (f.username && f.password) {
  662. callback(f.username, f.password);
  663. }
  664. }
  665. },
  666. null, null, ':input:first'
  667. );
  668. };
  669. UI.askForNickname = function () {
  670. return window.prompt('Your nickname (optional)');
  671. };
  672. /**
  673. * Sets muted audio state for participant
  674. */
  675. UI.setAudioMuted = function (id, muted) {
  676. VideoLayout.onAudioMute(id, muted);
  677. if (APP.conference.isLocalId(id)) {
  678. Toolbar.markAudioIconAsMuted(muted);
  679. }
  680. };
  681. /**
  682. * Sets muted video state for participant
  683. */
  684. UI.setVideoMuted = function (id, muted) {
  685. VideoLayout.onVideoMute(id, muted);
  686. if (APP.conference.isLocalId(id)) {
  687. Toolbar.markVideoIconAsMuted(muted);
  688. }
  689. };
  690. /**
  691. * Adds a listener that would be notified on the given type of event.
  692. *
  693. * @param type the type of the event we're listening for
  694. * @param listener a function that would be called when notified
  695. */
  696. UI.addListener = function (type, listener) {
  697. eventEmitter.on(type, listener);
  698. };
  699. /**
  700. * Removes the given listener for the given type of event.
  701. *
  702. * @param type the type of the event we're listening for
  703. * @param listener the listener we want to remove
  704. */
  705. UI.removeListener = function (type, listener) {
  706. eventEmitter.removeListener(type, listener);
  707. };
  708. UI.clickOnVideo = function (videoNumber) {
  709. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  710. if (remoteVideos.length > videoNumber) {
  711. remoteVideos[videoNumber].click();
  712. }
  713. };
  714. //Used by torture
  715. UI.showToolbar = function () {
  716. return ToolbarToggler.showToolbar();
  717. };
  718. //Used by torture
  719. UI.dockToolbar = function (isDock) {
  720. ToolbarToggler.dockToolbar(isDock);
  721. };
  722. /**
  723. * Updates the avatar for participant.
  724. * @param {string} id user id
  725. * @param {stirng} avatarUrl the URL for the avatar
  726. */
  727. function changeAvatar(id, avatarUrl) {
  728. VideoLayout.changeUserAvatar(id, avatarUrl);
  729. ContactList.changeUserAvatar(id, avatarUrl);
  730. if (APP.conference.isLocalId(id)) {
  731. SettingsMenu.changeAvatar(avatarUrl);
  732. }
  733. }
  734. /**
  735. * Update user email.
  736. * @param {string} id user id
  737. * @param {stirng} email user email
  738. */
  739. UI.setUserEmail = function (id, email) {
  740. // update avatar
  741. Avatar.setUserEmail(id, email);
  742. changeAvatar(id, Avatar.getAvatarUrl(id));
  743. };
  744. /**
  745. * Update user avatar URL.
  746. * @param {string} id user id
  747. * @param {stirng} url user avatar url
  748. */
  749. UI.setUserAvatarUrl = function (id, url) {
  750. // update avatar
  751. Avatar.setUserAvatarUrl(id, url);
  752. changeAvatar(id, Avatar.getAvatarUrl(id));
  753. };
  754. /**
  755. * Notify user that connection failed.
  756. * @param {string} stropheErrorMsg raw Strophe error message
  757. */
  758. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  759. var title = APP.translation.generateTranslationHTML(
  760. "dialog.error");
  761. var message;
  762. if (stropheErrorMsg) {
  763. message = APP.translation.generateTranslationHTML(
  764. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  765. } else {
  766. message = APP.translation.generateTranslationHTML(
  767. "dialog.connectError");
  768. }
  769. messageHandler.openDialog(
  770. title, message, true, {}, function (e, v, m, f) { return false; }
  771. );
  772. };
  773. /**
  774. * Notify user that maximum users limit has been reached.
  775. */
  776. UI.notifyMaxUsersLimitReached = function () {
  777. var title = APP.translation.generateTranslationHTML(
  778. "dialog.error");
  779. var message = APP.translation.generateTranslationHTML(
  780. "dialog.maxUsersLimitReached");
  781. messageHandler.openDialog(
  782. title, message, true, {}, function (e, v, m, f) { return false; }
  783. );
  784. };
  785. /**
  786. * Notify user that he was automatically muted when joned the conference.
  787. */
  788. UI.notifyInitiallyMuted = function () {
  789. messageHandler.notify(
  790. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  791. );
  792. };
  793. /**
  794. * Mark user as dominant speaker.
  795. * @param {string} id user id
  796. */
  797. UI.markDominantSpeaker = function (id) {
  798. VideoLayout.onDominantSpeakerChanged(id);
  799. };
  800. UI.handleLastNEndpoints = function (ids, enteringIds) {
  801. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  802. };
  803. /**
  804. * Update audio level visualization for specified user.
  805. * @param {string} id user id
  806. * @param {number} lvl audio level
  807. */
  808. UI.setAudioLevel = function (id, lvl) {
  809. VideoLayout.setAudioLevel(id, lvl);
  810. };
  811. /**
  812. * Update state of desktop sharing buttons.
  813. */
  814. UI.updateDesktopSharingButtons = function () {
  815. Toolbar.updateDesktopSharingButtonState();
  816. };
  817. /**
  818. * Hide connection quality statistics from UI.
  819. */
  820. UI.hideStats = function () {
  821. VideoLayout.hideStats();
  822. };
  823. /**
  824. * Update local connection quality statistics.
  825. * @param {number} percent
  826. * @param {object} stats
  827. */
  828. UI.updateLocalStats = function (percent, stats) {
  829. VideoLayout.updateLocalConnectionStats(percent, stats);
  830. };
  831. /**
  832. * Update connection quality statistics for remote user.
  833. * @param {string} id user id
  834. * @param {number} percent
  835. * @param {object} stats
  836. */
  837. UI.updateRemoteStats = function (id, percent, stats) {
  838. VideoLayout.updateConnectionStats(id, percent, stats);
  839. };
  840. /**
  841. * Mark video as interrupted or not.
  842. * @param {boolean} interrupted if video is interrupted
  843. */
  844. UI.markVideoInterrupted = function (interrupted) {
  845. if (interrupted) {
  846. VideoLayout.onVideoInterrupted();
  847. } else {
  848. VideoLayout.onVideoRestored();
  849. }
  850. };
  851. /**
  852. * Mark room as locked or not.
  853. * @param {boolean} locked if room is locked.
  854. */
  855. UI.markRoomLocked = function (locked) {
  856. if (locked) {
  857. Toolbar.lockLockButton();
  858. } else {
  859. Toolbar.unlockLockButton();
  860. }
  861. };
  862. /**
  863. * Add chat message.
  864. * @param {string} from user id
  865. * @param {string} displayName user nickname
  866. * @param {string} message message text
  867. * @param {number} stamp timestamp when message was created
  868. */
  869. UI.addMessage = function (from, displayName, message, stamp) {
  870. Chat.updateChatConversation(from, displayName, message, stamp);
  871. };
  872. UI.updateDTMFSupport = function (isDTMFSupported) {
  873. //TODO: enable when the UI is ready
  874. //Toolbar.showDialPadButton(dtmfSupport);
  875. };
  876. /**
  877. * Invite participants to conference.
  878. * @param {string} roomUrl
  879. * @param {string} conferenceName
  880. * @param {string} key
  881. * @param {string} nick
  882. */
  883. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  884. let keyText = "";
  885. if (key) {
  886. keyText = APP.translation.translateString(
  887. "email.sharedKey", {sharedKey: key}
  888. );
  889. }
  890. let and = APP.translation.translateString("email.and");
  891. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  892. let subject = APP.translation.translateString(
  893. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  894. );
  895. let body = APP.translation.translateString(
  896. "email.body", {
  897. appName:interfaceConfig.APP_NAME,
  898. sharedKeyText: keyText,
  899. roomUrl,
  900. supportedBrowsers
  901. }
  902. );
  903. body = body.replace(/\n/g, "%0D%0A");
  904. if (nick) {
  905. body += "%0D%0A%0D%0A" + UIUtil.escapeHtml(nick);
  906. }
  907. if (interfaceConfig.INVITATION_POWERED_BY) {
  908. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  909. }
  910. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  911. };
  912. /**
  913. * Show user feedback dialog if its required or just show "thank you" dialog.
  914. * @returns {Promise} when dialog is closed.
  915. */
  916. UI.requestFeedback = function () {
  917. return new Promise(function (resolve, reject) {
  918. if (Feedback.isEnabled()) {
  919. // If the user has already entered feedback, we'll show the window and
  920. // immidiately start the conference dispose timeout.
  921. if (Feedback.feedbackScore > 0) {
  922. Feedback.openFeedbackWindow();
  923. resolve();
  924. } else { // Otherwise we'll wait for user's feedback.
  925. Feedback.openFeedbackWindow(resolve);
  926. }
  927. } else {
  928. // If the feedback functionality isn't enabled we show a thank you
  929. // dialog.
  930. messageHandler.openMessageDialog(
  931. null, null, null,
  932. APP.translation.translateString(
  933. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  934. )
  935. );
  936. resolve();
  937. }
  938. });
  939. };
  940. UI.updateRecordingState = function (state) {
  941. Recording.updateRecordingState(state);
  942. };
  943. UI.notifyTokenAuthFailed = function () {
  944. messageHandler.showError("dialog.error", "dialog.tokenAuthFailed");
  945. };
  946. UI.notifyInternalError = function () {
  947. messageHandler.showError("dialog.sorry", "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 loggedIn = !!login;
  984. Toolbar.showAuthenticateButton(isAuthEnabled);
  985. if (isAuthEnabled) {
  986. Toolbar.setAuthenticatedIdentity(login);
  987. Toolbar.showLoginButton(!loggedIn);
  988. Toolbar.showLogoutButton(loggedIn);
  989. }
  990. };
  991. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  992. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  993. };
  994. /**
  995. * Update list of available physical devices.
  996. * @param {object[]} devices new list of available devices
  997. */
  998. UI.onAvailableDevicesChanged = function (devices) {
  999. SettingsMenu.changeDevicesList(devices);
  1000. };
  1001. /**
  1002. * Sets microphone's <select> element to select microphone ID from settings.
  1003. */
  1004. UI.setSelectedMicFromSettings = function () {
  1005. SettingsMenu.setSelectedMicFromSettings();
  1006. };
  1007. /**
  1008. * Sets camera's <select> element to select camera ID from settings.
  1009. */
  1010. UI.setSelectedCameraFromSettings = function () {
  1011. SettingsMenu.setSelectedCameraFromSettings();
  1012. };
  1013. /**
  1014. * Sets audio outputs's <select> element to select audio output ID from
  1015. * settings.
  1016. */
  1017. UI.setSelectedAudioOutputFromSettings = function () {
  1018. SettingsMenu.setSelectedAudioOutputFromSettings();
  1019. };
  1020. /**
  1021. * Returns the id of the current video shown on large.
  1022. * Currently used by tests (torture).
  1023. */
  1024. UI.getLargeVideoID = function () {
  1025. return VideoLayout.getLargeVideoID();
  1026. };
  1027. /**
  1028. * Returns the current video shown on large.
  1029. * Currently used by tests (torture).
  1030. */
  1031. UI.getLargeVideo = function () {
  1032. return VideoLayout.getLargeVideo();
  1033. };
  1034. /**
  1035. * Shows dialog with a link to FF extension.
  1036. */
  1037. UI.showExtensionRequiredDialog = function (url) {
  1038. messageHandler.openMessageDialog(
  1039. "dialog.extensionRequired",
  1040. null,
  1041. null,
  1042. APP.translation.generateTranslationHTML(
  1043. "dialog.firefoxExtensionPrompt", {url: url}));
  1044. };
  1045. /**
  1046. * Shows dialog with combined information about camera and microphone errors.
  1047. * @param {JitsiTrackError} micError
  1048. * @param {JitsiTrackError} cameraError
  1049. */
  1050. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1051. let localStoragePropName = "doNotShowErrorAgain";
  1052. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1053. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1054. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1055. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1056. let showDoNotShowWarning = false;
  1057. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1058. isCameraJitsiTrackErrorAndHasName) {
  1059. showDoNotShowWarning = true;
  1060. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1061. showDoNotShowWarning = true;
  1062. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1063. showDoNotShowWarning = true;
  1064. }
  1065. if (micError) {
  1066. localStoragePropName += "-mic-" + micError.name;
  1067. }
  1068. if (cameraError) {
  1069. localStoragePropName += "-camera-" + cameraError.name;
  1070. }
  1071. if (showDoNotShowWarning) {
  1072. if (window.localStorage[localStoragePropName] === "true") {
  1073. return;
  1074. }
  1075. }
  1076. let title = getTitleKey();
  1077. let titleMsg = `<span data-i18n="${title}"></span>`;
  1078. let cameraJitsiTrackErrorMsg = cameraError
  1079. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1080. : undefined;
  1081. let micJitsiTrackErrorMsg = micError
  1082. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1083. : undefined;
  1084. let cameraErrorMsg = cameraError
  1085. ? cameraJitsiTrackErrorMsg ||
  1086. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1087. : "";
  1088. let micErrorMsg = micError
  1089. ? micJitsiTrackErrorMsg ||
  1090. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1091. : "";
  1092. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1093. cameraError.message
  1094. ? `<div>${cameraError.message}</div>`
  1095. : ``;
  1096. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1097. micError.message
  1098. ? `<div>${micError.message}</div>`
  1099. : ``;
  1100. let doNotShowWarningAgainSection = showDoNotShowWarning
  1101. ? `<label>
  1102. <input type='checkbox' id='doNotShowWarningAgain'>
  1103. <span data-i18n='dialog.doNotShowWarningAgain'></span>
  1104. </label>`
  1105. : ``;
  1106. let message = '';
  1107. if (micError) {
  1108. message = `
  1109. ${message}
  1110. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1111. <h4 data-i18n='${micErrorMsg}'></h4>
  1112. ${additionalMicErrorMsg}`;
  1113. }
  1114. if (cameraError) {
  1115. message = `
  1116. ${message}
  1117. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1118. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1119. ${additionalCameraErrorMsg}`;
  1120. }
  1121. message = `${message}${doNotShowWarningAgainSection}`;
  1122. // To make sure we don't have multiple error dialogs open at the same time,
  1123. // we will just close the previous one if we are going to show a new one.
  1124. deviceErrorDialog && deviceErrorDialog.close();
  1125. deviceErrorDialog = messageHandler.openDialog(
  1126. titleMsg,
  1127. message,
  1128. false,
  1129. {Ok: true},
  1130. function () {
  1131. let form = $.prompt.getPrompt();
  1132. if (form) {
  1133. let input = form.find("#doNotShowWarningAgain");
  1134. if (input.length) {
  1135. window.localStorage[localStoragePropName] =
  1136. input.prop("checked");
  1137. }
  1138. }
  1139. },
  1140. null,
  1141. function () {
  1142. // Reset dialog reference to null to avoid memory leaks when
  1143. // user closed the dialog manually.
  1144. deviceErrorDialog = null;
  1145. }
  1146. );
  1147. APP.translation.translateElement($(".jqibox"));
  1148. function getTitleKey() {
  1149. let title = "dialog.error";
  1150. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1151. if (cameraError && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1152. title = "dialog.permissionDenied";
  1153. } else if (!cameraError) {
  1154. title = "dialog.permissionDenied";
  1155. }
  1156. } else if (cameraError &&
  1157. cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1158. title = "dialog.permissionDenied";
  1159. }
  1160. return title;
  1161. }
  1162. };
  1163. UI.updateDevicesAvailability = function (id, devices) {
  1164. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1165. };
  1166. /**
  1167. * Show 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.onSharedVideoStart = function (id, url, attributes) {
  1173. if (sharedVideoManager)
  1174. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1175. };
  1176. /**
  1177. * Update shared video.
  1178. * @param {string} id the id of the sender of the command
  1179. * @param {string} url video url
  1180. * @param {string} attributes
  1181. */
  1182. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1183. if (sharedVideoManager)
  1184. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1185. };
  1186. /**
  1187. * Stop showing shared video.
  1188. * @param {string} id the id of the sender of the command
  1189. * @param {string} attributes
  1190. */
  1191. UI.onSharedVideoStop = function (id, attributes) {
  1192. if (sharedVideoManager)
  1193. sharedVideoManager.onSharedVideoStop(id, attributes);
  1194. };
  1195. /**
  1196. * Disables camera toolbar button.
  1197. */
  1198. UI.disableCameraButton = function () {
  1199. Toolbar.markVideoIconAsDisabled(true);
  1200. };
  1201. /**
  1202. * Enables camera toolbar button.
  1203. */
  1204. UI.enableCameraButton = function () {
  1205. Toolbar.markVideoIconAsDisabled(false);
  1206. };
  1207. /**
  1208. * Disables microphone toolbar button.
  1209. */
  1210. UI.disableMicrophoneButton = function () {
  1211. Toolbar.markAudioIconAsDisabled(true);
  1212. };
  1213. /**
  1214. * Enables microphone toolbar button.
  1215. */
  1216. UI.enableMicrophoneButton = function () {
  1217. Toolbar.markAudioIconAsDisabled(false);
  1218. };
  1219. let bottomToolbarEnabled = null;
  1220. UI.showRingOverLay = function () {
  1221. RingOverlay.show(APP.tokenData.callee);
  1222. FilmStrip.toggleFilmStrip(false);
  1223. };
  1224. UI.hideRingOverLay = function () {
  1225. if (!RingOverlay.hide())
  1226. return;
  1227. FilmStrip.toggleFilmStrip(true);
  1228. };
  1229. /**
  1230. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1231. * @param {string} browser - name of browser for which to show the guidance
  1232. * overlay.
  1233. */
  1234. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1235. GumPermissionsOverlay.show(browser);
  1236. };
  1237. /**
  1238. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1239. */
  1240. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1241. GumPermissionsOverlay.hide();
  1242. };
  1243. /**
  1244. * Shows or hides the keyboard shortcuts panel, depending on the current state.'
  1245. */
  1246. UI.toggleKeyboardShortcutsPanel = function() {
  1247. $('#keyboard-shortcuts').toggle();
  1248. };
  1249. /**
  1250. * Shows or hides the keyboard shortcuts panel.'
  1251. */
  1252. UI.showKeyboardShortcutsPanel = function(show) {
  1253. if (show) {
  1254. $('#keyboard-shortcuts').show();
  1255. } else {
  1256. $('#keyboard-shortcuts').hide();
  1257. }
  1258. };
  1259. module.exports = UI;