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

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