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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463
  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 RandomUtil from "../util/RandomUtil";
  23. import UIErrors from './UIErrors';
  24. import { debounce } from "../util/helpers";
  25. var EventEmitter = require("events");
  26. UI.messageHandler = require("./util/MessageHandler");
  27. var messageHandler = UI.messageHandler;
  28. var JitsiPopover = require("./util/JitsiPopover");
  29. var Feedback = require("./feedback/Feedback");
  30. import FollowMe from "../FollowMe";
  31. var eventEmitter = new EventEmitter();
  32. UI.eventEmitter = eventEmitter;
  33. let etherpadManager;
  34. let sharedVideoManager;
  35. let followMeHandler;
  36. let deviceErrorDialog;
  37. const TrackErrors = JitsiMeetJS.errors.track;
  38. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  39. microphone: {},
  40. camera: {}
  41. };
  42. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  43. = "dialog.cameraUnsupportedResolutionError";
  44. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  45. = "dialog.cameraUnknownError";
  46. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  47. = "dialog.cameraPermissionDeniedError";
  48. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  49. = "dialog.cameraNotFoundError";
  50. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  51. = "dialog.cameraConstraintFailedError";
  52. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  53. = "dialog.cameraNotSendingData";
  54. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  55. = "dialog.micUnknownError";
  56. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  57. = "dialog.micPermissionDeniedError";
  58. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  59. = "dialog.micNotFoundError";
  60. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  61. = "dialog.micConstraintFailedError";
  62. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  63. = "dialog.micNotSendingData";
  64. /**
  65. * Prompt user for nickname.
  66. */
  67. function promptDisplayName() {
  68. let labelKey = 'dialog.enterDisplayName';
  69. let message = (
  70. `<div class="input-control">
  71. <label data-i18n="${labelKey}" class="input-control__label"></label>
  72. <input name="displayName" type="text"
  73. data-i18n="[placeholder]defaultNickname"
  74. class="input-control__input"
  75. autofocus>
  76. </div>`
  77. );
  78. // Don't use a translation string, because we're too early in the call and
  79. // the translation may not be initialised.
  80. let buttons = {Ok:true};
  81. let dialog = messageHandler.openDialog(
  82. 'dialog.displayNameRequired',
  83. message,
  84. true,
  85. buttons,
  86. function (e, v, m, f) {
  87. e.preventDefault();
  88. if (v) {
  89. let displayName = f.displayName;
  90. if (displayName) {
  91. UI.inputDisplayNameHandler(displayName);
  92. dialog.close();
  93. return;
  94. }
  95. }
  96. },
  97. function () {
  98. let form = $.prompt.getPrompt();
  99. let input = form.find("input[name='displayName']");
  100. input.focus();
  101. let button = form.find("button");
  102. button.attr("disabled", "disabled");
  103. input.keyup(function () {
  104. if (input.val()) {
  105. button.removeAttr("disabled");
  106. } else {
  107. button.attr("disabled", "disabled");
  108. }
  109. });
  110. }
  111. );
  112. }
  113. /**
  114. * Initialize chat.
  115. */
  116. function setupChat() {
  117. Chat.init(eventEmitter);
  118. $("#toggle_smileys").click(function() {
  119. Chat.toggleSmileys();
  120. });
  121. }
  122. /**
  123. * Initialize toolbars.
  124. */
  125. function setupToolbars() {
  126. Toolbar.init(eventEmitter);
  127. }
  128. /**
  129. * Toggles the application in and out of full screen mode
  130. * (a.k.a. presentation mode in Chrome).
  131. */
  132. UI.toggleFullScreen = function() {
  133. (UIUtil.isFullScreen())
  134. ? UIUtil.exitFullScreen()
  135. : UIUtil.enterFullScreen();
  136. };
  137. /**
  138. * Notify user that server has shut down.
  139. */
  140. UI.notifyGracefulShutdown = function () {
  141. messageHandler.openMessageDialog(
  142. 'dialog.serviceUnavailable',
  143. 'dialog.gracefulShutdown'
  144. );
  145. };
  146. /**
  147. * Notify user that reservation error happened.
  148. */
  149. UI.notifyReservationError = function (code, msg) {
  150. var message = APP.translation.generateTranslationHTML(
  151. "dialog.reservationErrorMsg", {code: code, msg: msg});
  152. messageHandler.openDialog(
  153. "dialog.reservationError", message, true, {}, () => false);
  154. };
  155. /**
  156. * Notify user that he has been kicked from the server.
  157. */
  158. UI.notifyKicked = function () {
  159. messageHandler.openMessageDialog(
  160. "dialog.sessTerminated",
  161. "dialog.kickMessage");
  162. };
  163. /**
  164. * Notify user that conference was destroyed.
  165. * @param reason {string} the reason text
  166. */
  167. UI.notifyConferenceDestroyed = function (reason) {
  168. //FIXME: use Session Terminated from translation, but
  169. // 'reason' text comes from XMPP packet and is not translated
  170. messageHandler.openDialog(
  171. "dialog.sessTerminated", reason, true, {}, () => false);
  172. };
  173. /**
  174. * Show chat error.
  175. * @param err the Error
  176. * @param msg
  177. */
  178. UI.showChatError = function (err, msg) {
  179. if (interfaceConfig.filmStripOnly) {
  180. return;
  181. }
  182. Chat.chatAddError(err, msg);
  183. };
  184. /**
  185. * Change nickname for the user.
  186. * @param {string} id user id
  187. * @param {string} displayName new nickname
  188. */
  189. UI.changeDisplayName = function (id, displayName) {
  190. UI.ContactList.onDisplayNameChange(id, displayName);
  191. VideoLayout.onDisplayNameChanged(id, displayName);
  192. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  193. Profile.changeDisplayName(displayName);
  194. Chat.setChatConversationMode(!!displayName);
  195. }
  196. };
  197. /**
  198. * Shows/hides the indication about local connection being interrupted.
  199. *
  200. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  201. * currently in the interrupted state or <tt>false</tt> if the connection
  202. * is fine.
  203. */
  204. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  205. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  206. };
  207. /**
  208. * Sets the "raised hand" status for a participant.
  209. */
  210. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  211. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  212. if (raisedHandStatus) {
  213. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  214. 'connected', 'notify.raisedHand');
  215. }
  216. };
  217. /**
  218. * Sets the local "raised hand" status.
  219. */
  220. UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
  221. VideoLayout.setRaisedHandStatus(
  222. APP.conference.getMyUserId(),
  223. raisedHandStatus);
  224. };
  225. /**
  226. * Initialize conference UI.
  227. */
  228. UI.initConference = function () {
  229. let id = APP.conference.getMyUserId();
  230. // Add myself to the contact list.
  231. UI.ContactList.addContact(id, true);
  232. // Update default button states before showing the toolbar
  233. // if local role changes buttons state will be again updated.
  234. UI.updateLocalRole(APP.conference.isModerator);
  235. UI.showToolbar();
  236. let displayName = config.displayJids ? id : Settings.getDisplayName();
  237. if (displayName) {
  238. UI.changeDisplayName('localVideoContainer', displayName);
  239. }
  240. // Make sure we configure our avatar id, before creating avatar for us
  241. let email = Settings.getEmail();
  242. if (email) {
  243. UI.setUserEmail(id, email);
  244. } else {
  245. UI.setUserAvatarID(id, Settings.getAvatarId());
  246. }
  247. Toolbar.checkAutoEnableDesktopSharing();
  248. if(!interfaceConfig.filmStripOnly) {
  249. Feedback.init(eventEmitter);
  250. }
  251. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  252. // other participants' UI. Consequently, it needs (1) read and write access
  253. // to the UI (depending on the moderator role of the local participant) and
  254. // (2) APP.conference as means of communication between the participants.
  255. followMeHandler = new FollowMe(APP.conference, UI);
  256. UIUtil.activateTooltips();
  257. };
  258. UI.mucJoined = function () {
  259. VideoLayout.mucJoined();
  260. };
  261. /***
  262. * Handler for toggling filmstrip
  263. */
  264. UI.handleToggleFilmStrip = () => {
  265. UI.toggleFilmStrip();
  266. };
  267. /**
  268. * Sets tooltip defaults.
  269. *
  270. * @private
  271. */
  272. function _setTooltipDefaults() {
  273. $.fn.tooltip.defaults = {
  274. opacity: 1, //defaults to 1
  275. offset: 1,
  276. delayIn: 0, //defaults to 500
  277. hoverable: true,
  278. hideOnClick: true,
  279. aria: true
  280. };
  281. }
  282. /**
  283. * Setup some UI event listeners.
  284. */
  285. function registerListeners() {
  286. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  287. if (etherpadManager) {
  288. etherpadManager.toggleEtherpad();
  289. }
  290. });
  291. UI.addListener(UIEvents.SHARED_VIDEO_CLICKED, function () {
  292. if (sharedVideoManager) {
  293. sharedVideoManager.toggleSharedVideo();
  294. }
  295. });
  296. UI.addListener(UIEvents.TOGGLE_FULLSCREEN, UI.toggleFullScreen);
  297. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  298. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  299. UI.toggleSidePanel("settings_container");
  300. });
  301. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  302. UI.addListener( UIEvents.TOGGLE_PROFILE, function() {
  303. if(APP.tokenData.isGuest)
  304. UI.toggleSidePanel("profile_container");
  305. });
  306. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.handleToggleFilmStrip);
  307. UI.addListener(UIEvents.FOLLOW_ME_ENABLED, function (isEnabled) {
  308. if (followMeHandler)
  309. followMeHandler.enableFollowMe(isEnabled);
  310. });
  311. }
  312. /**
  313. * Setup some DOM event listeners.
  314. */
  315. function bindEvents() {
  316. function onResize() {
  317. SideContainerToggler.resize();
  318. VideoLayout.resizeVideoArea();
  319. }
  320. // Resize and reposition videos in full screen mode.
  321. $(document).on(
  322. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  323. () => {
  324. eventEmitter.emit( UIEvents.FULLSCREEN_TOGGLED,
  325. UIUtil.isFullScreen());
  326. onResize();
  327. }
  328. );
  329. $(window).resize(onResize);
  330. }
  331. /**
  332. * Returns the shared document manager object.
  333. * @return {EtherpadManager} the shared document manager object
  334. */
  335. UI.getSharedVideoManager = function () {
  336. return sharedVideoManager;
  337. };
  338. /**
  339. * Starts the UI module and initializes all related components.
  340. *
  341. * @returns {boolean} true if the UI is ready and the conference should be
  342. * esablished, false - otherwise (for example in the case of welcome page)
  343. */
  344. UI.start = function () {
  345. document.title = interfaceConfig.APP_NAME;
  346. var setupWelcomePage = null;
  347. if(config.enableWelcomePage && window.location.pathname == "/" &&
  348. Settings.isWelcomePageEnabled()) {
  349. $("#videoconference_page").hide();
  350. if (!setupWelcomePage)
  351. setupWelcomePage = require("./welcome_page/WelcomePage");
  352. setupWelcomePage();
  353. // Return false to indicate that the UI hasn't been fully started and
  354. // conference ready. We're still waiting for input from the user.
  355. return false;
  356. }
  357. $("#welcome_page").hide();
  358. // Set the defaults for prompt dialogs.
  359. $.prompt.setDefaults({persistent: false});
  360. // Set the defaults for tooltips.
  361. _setTooltipDefaults();
  362. registerListeners();
  363. ToolbarToggler.init();
  364. SideContainerToggler.init(eventEmitter);
  365. FilmStrip.init(eventEmitter);
  366. VideoLayout.init(eventEmitter);
  367. if (!interfaceConfig.filmStripOnly) {
  368. VideoLayout.initLargeVideo();
  369. }
  370. VideoLayout.resizeVideoArea(true, true);
  371. bindEvents();
  372. sharedVideoManager = new SharedVideoManager(eventEmitter);
  373. if (!interfaceConfig.filmStripOnly) {
  374. let debouncedShowToolbar = debounce(() => {
  375. UI.showToolbar();
  376. }, 100, { leading: true, trailing: false });
  377. $("#videoconference_page").mousemove(debouncedShowToolbar);
  378. setupToolbars();
  379. setupChat();
  380. // Initialise the recording module.
  381. if (config.enableRecording)
  382. Recording.init(eventEmitter, config.recordingType);
  383. // Display notice message at the top of the toolbar
  384. if (config.noticeMessage) {
  385. $('#noticeText').text(config.noticeMessage);
  386. $('#notice').css({display: 'block'});
  387. }
  388. } else {
  389. $("#mainToolbarContainer").css("display", "none");
  390. FilmStrip.setupFilmStripOnly();
  391. messageHandler.enableNotifications(false);
  392. JitsiPopover.enabled = false;
  393. }
  394. document.title = interfaceConfig.APP_NAME;
  395. if(config.requireDisplayName) {
  396. if (!APP.settings.getDisplayName()) {
  397. promptDisplayName();
  398. }
  399. }
  400. if (!interfaceConfig.filmStripOnly) {
  401. toastr.options = {
  402. "closeButton": true,
  403. "debug": false,
  404. "positionClass": "notification-bottom-right",
  405. "onclick": null,
  406. "showDuration": "300",
  407. "hideDuration": "1000",
  408. "timeOut": "2000",
  409. "extendedTimeOut": "1000",
  410. "showEasing": "swing",
  411. "hideEasing": "linear",
  412. "showMethod": "fadeIn",
  413. "hideMethod": "fadeOut",
  414. "newestOnTop": false
  415. };
  416. SettingsMenu.init(eventEmitter);
  417. Profile.init(eventEmitter);
  418. }
  419. if(APP.tokenData.callee) {
  420. UI.showRingOverlay();
  421. }
  422. // Return true to indicate that the UI has been fully started and
  423. // conference ready.
  424. return true;
  425. };
  426. /**
  427. * Show local stream on UI.
  428. * @param {JitsiTrack} track stream to show
  429. */
  430. UI.addLocalStream = function (track) {
  431. switch (track.getType()) {
  432. case 'audio':
  433. VideoLayout.changeLocalAudio(track);
  434. break;
  435. case 'video':
  436. VideoLayout.changeLocalVideo(track);
  437. break;
  438. default:
  439. console.error("Unknown stream type: " + track.getType());
  440. break;
  441. }
  442. };
  443. /**
  444. * Show remote stream on UI.
  445. * @param {JitsiTrack} track stream to show
  446. */
  447. UI.addRemoteStream = function (track) {
  448. VideoLayout.onRemoteStreamAdded(track);
  449. };
  450. /**
  451. * Removed remote stream from UI.
  452. * @param {JitsiTrack} track stream to remove
  453. */
  454. UI.removeRemoteStream = function (track) {
  455. VideoLayout.onRemoteStreamRemoved(track);
  456. };
  457. /**
  458. * Update chat subject.
  459. * @param {string} subject new chat subject
  460. */
  461. UI.setSubject = function (subject) {
  462. Chat.setSubject(subject);
  463. };
  464. /**
  465. * Setup and show Etherpad.
  466. * @param {string} name etherpad id
  467. */
  468. UI.initEtherpad = function (name) {
  469. if (etherpadManager || !config.etherpad_base || !name) {
  470. return;
  471. }
  472. console.log('Etherpad is enabled');
  473. etherpadManager
  474. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  475. Toolbar.showEtherpadButton();
  476. };
  477. /**
  478. * Returns the shared document manager object.
  479. * @return {EtherpadManager} the shared document manager object
  480. */
  481. UI.getSharedDocumentManager = function () {
  482. return etherpadManager;
  483. };
  484. /**
  485. * Show user on UI.
  486. * @param {JitsiParticipant} user
  487. */
  488. UI.addUser = function (user) {
  489. var id = user.getId();
  490. var displayName = user.getDisplayName();
  491. UI.hideRingOverLay();
  492. UI.ContactList.addContact(id);
  493. messageHandler.notify(
  494. displayName,'notify.somebody', 'connected', 'notify.connected'
  495. );
  496. if (!config.startAudioMuted ||
  497. config.startAudioMuted > APP.conference.membersCount)
  498. UIUtil.playSoundNotification('userJoined');
  499. // Add Peer's container
  500. VideoLayout.addParticipantContainer(user);
  501. // Configure avatar
  502. UI.setUserEmail(id);
  503. // set initial display name
  504. if(displayName)
  505. UI.changeDisplayName(id, displayName);
  506. };
  507. /**
  508. * Remove user from UI.
  509. * @param {string} id user id
  510. * @param {string} displayName user nickname
  511. */
  512. UI.removeUser = function (id, displayName) {
  513. UI.ContactList.removeContact(id);
  514. messageHandler.notify(
  515. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  516. );
  517. if (!config.startAudioMuted
  518. || config.startAudioMuted > APP.conference.membersCount) {
  519. UIUtil.playSoundNotification('userLeft');
  520. }
  521. VideoLayout.removeParticipantContainer(id);
  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. // Reload the page after 10 - 30 seconds
  940. PageReloadOverlay.show(10 + RandomUtil.randomInt(0, 20));
  941. };
  942. /**
  943. * Updates auth info on the UI.
  944. * @param {boolean} isAuthEnabled if authentication is enabled
  945. * @param {string} [login] current login
  946. */
  947. UI.updateAuthInfo = function (isAuthEnabled, login) {
  948. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  949. let loggedIn = !!login;
  950. Toolbar.showAuthenticateButton(showAuth);
  951. if (showAuth) {
  952. Toolbar.setAuthenticatedIdentity(login);
  953. Toolbar.showLoginButton(!loggedIn);
  954. Toolbar.showLogoutButton(loggedIn);
  955. }
  956. };
  957. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  958. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  959. };
  960. /**
  961. * Notifies interested listeners that the raise hand property has changed.
  962. *
  963. * @param {boolean} isRaisedHand indicates the current state of the
  964. * "raised hand"
  965. */
  966. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  967. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  968. };
  969. /**
  970. * Update list of available physical devices.
  971. * @param {object[]} devices new list of available devices
  972. */
  973. UI.onAvailableDevicesChanged = function (devices) {
  974. SettingsMenu.changeDevicesList(devices);
  975. };
  976. /**
  977. * Sets microphone's <select> element to select microphone ID from settings.
  978. */
  979. UI.setSelectedMicFromSettings = function () {
  980. SettingsMenu.setSelectedMicFromSettings();
  981. };
  982. /**
  983. * Sets camera's <select> element to select camera ID from settings.
  984. */
  985. UI.setSelectedCameraFromSettings = function () {
  986. SettingsMenu.setSelectedCameraFromSettings();
  987. };
  988. /**
  989. * Sets audio outputs's <select> element to select audio output ID from
  990. * settings.
  991. */
  992. UI.setSelectedAudioOutputFromSettings = function () {
  993. SettingsMenu.setSelectedAudioOutputFromSettings();
  994. };
  995. /**
  996. * Returns the id of the current video shown on large.
  997. * Currently used by tests (torture).
  998. */
  999. UI.getLargeVideoID = function () {
  1000. return VideoLayout.getLargeVideoID();
  1001. };
  1002. /**
  1003. * Returns the current video shown on large.
  1004. * Currently used by tests (torture).
  1005. */
  1006. UI.getLargeVideo = function () {
  1007. return VideoLayout.getLargeVideo();
  1008. };
  1009. /**
  1010. * Shows dialog with a link to FF extension.
  1011. */
  1012. UI.showExtensionRequiredDialog = function (url) {
  1013. messageHandler.openMessageDialog(
  1014. "dialog.extensionRequired",
  1015. "dialog.firefoxExtensionPrompt",
  1016. {url: url});
  1017. };
  1018. /**
  1019. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1020. * 2 button dialog with buttons - cancel and go to web store.
  1021. * @param url {string} the url of the extension.
  1022. */
  1023. UI.showExtensionExternalInstallationDialog = function (url) {
  1024. let submitFunction = function(e,v){
  1025. if (v) {
  1026. e.preventDefault();
  1027. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1028. }
  1029. };
  1030. let closeFunction = function () {
  1031. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1032. };
  1033. messageHandler.openTwoButtonDialog({
  1034. titleKey: 'dialog.externalInstallationTitle',
  1035. msgKey: 'dialog.externalInstallationMsg',
  1036. leftButtonKey: 'dialog.goToStore',
  1037. submitFunction,
  1038. loadedFunction: $.noop,
  1039. closeFunction
  1040. });
  1041. };
  1042. /**
  1043. * Shows dialog with combined information about camera and microphone errors.
  1044. * @param {JitsiTrackError} micError
  1045. * @param {JitsiTrackError} cameraError
  1046. */
  1047. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1048. let dontShowAgain = {
  1049. id: "doNotShowWarningAgain",
  1050. localStorageKey: "doNotShowErrorAgain",
  1051. textKey: "dialog.doNotShowWarningAgain"
  1052. };
  1053. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1054. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1055. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1056. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1057. let showDoNotShowWarning = false;
  1058. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1059. isCameraJitsiTrackErrorAndHasName) {
  1060. showDoNotShowWarning = true;
  1061. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1062. showDoNotShowWarning = true;
  1063. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1064. showDoNotShowWarning = true;
  1065. }
  1066. if (micError) {
  1067. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1068. }
  1069. if (cameraError) {
  1070. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  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 message = '';
  1095. if (micError) {
  1096. message = `
  1097. ${message}
  1098. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1099. <h4 data-i18n='${micErrorMsg}'></h4>
  1100. ${additionalMicErrorMsg}`;
  1101. }
  1102. if (cameraError) {
  1103. message = `
  1104. ${message}
  1105. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1106. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1107. ${additionalCameraErrorMsg}`;
  1108. }
  1109. // To make sure we don't have multiple error dialogs open at the same time,
  1110. // we will just close the previous one if we are going to show a new one.
  1111. deviceErrorDialog && deviceErrorDialog.close();
  1112. deviceErrorDialog = messageHandler.openDialog(
  1113. getTitleKey(),
  1114. message,
  1115. false,
  1116. {Ok: true},
  1117. function () {},
  1118. null,
  1119. function () {
  1120. // Reset dialog reference to null to avoid memory leaks when
  1121. // user closed the dialog manually.
  1122. deviceErrorDialog = null;
  1123. },
  1124. showDoNotShowWarning ? dontShowAgain : undefined
  1125. );
  1126. function getTitleKey() {
  1127. let title = "dialog.error";
  1128. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1129. if (!cameraError
  1130. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1131. title = "dialog.permissionDenied";
  1132. }
  1133. } else if (cameraError
  1134. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1135. title = "dialog.permissionDenied";
  1136. }
  1137. return title;
  1138. }
  1139. };
  1140. /**
  1141. * Shows error dialog that informs the user that no data is received from the
  1142. * device.
  1143. */
  1144. UI.showTrackNotWorkingDialog = function (stream) {
  1145. messageHandler.openMessageDialog(
  1146. "dialog.error",
  1147. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1148. "dialog.cameraNotSendingData");
  1149. };
  1150. UI.updateDevicesAvailability = function (id, devices) {
  1151. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1152. };
  1153. /**
  1154. * Show shared video.
  1155. * @param {string} id the id of the sender of the command
  1156. * @param {string} url video url
  1157. * @param {string} attributes
  1158. */
  1159. UI.onSharedVideoStart = function (id, url, attributes) {
  1160. if (sharedVideoManager)
  1161. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1162. };
  1163. /**
  1164. * Update shared video.
  1165. * @param {string} id the id of the sender of the command
  1166. * @param {string} url video url
  1167. * @param {string} attributes
  1168. */
  1169. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1170. if (sharedVideoManager)
  1171. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1172. };
  1173. /**
  1174. * Stop showing shared video.
  1175. * @param {string} id the id of the sender of the command
  1176. * @param {string} attributes
  1177. */
  1178. UI.onSharedVideoStop = function (id, attributes) {
  1179. if (sharedVideoManager)
  1180. sharedVideoManager.onSharedVideoStop(id, attributes);
  1181. };
  1182. /**
  1183. * Enables / disables camera toolbar button.
  1184. *
  1185. * @param {boolean} enabled indicates if the camera button should be enabled
  1186. * or disabled
  1187. */
  1188. UI.setCameraButtonEnabled = function (enabled) {
  1189. Toolbar.setVideoIconEnabled(enabled);
  1190. };
  1191. /**
  1192. * Enables / disables microphone toolbar button.
  1193. *
  1194. * @param {boolean} enabled indicates if the microphone button should be
  1195. * enabled or disabled
  1196. */
  1197. UI.setMicrophoneButtonEnabled = function (enabled) {
  1198. Toolbar.setAudioIconEnabled(enabled);
  1199. };
  1200. UI.showRingOverlay = function () {
  1201. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1202. FilmStrip.toggleFilmStrip(false);
  1203. };
  1204. UI.hideRingOverLay = function () {
  1205. if (!RingOverlay.hide())
  1206. return;
  1207. FilmStrip.toggleFilmStrip(true);
  1208. };
  1209. /**
  1210. * Indicates if any the "top" overlays are currently visible. The check includes
  1211. * the call overlay, GUM permissions overlay and a page reload overlay.
  1212. *
  1213. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1214. */
  1215. UI.isOverlayVisible = function () {
  1216. return RingOverlay.isVisible()
  1217. || PageReloadOverlay.isVisible()
  1218. || GumPermissionsOverlay.isVisible();
  1219. };
  1220. /**
  1221. * Indicates if the ring overlay is currently visible.
  1222. *
  1223. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1224. */
  1225. UI.isRingOverlayVisible = function () {
  1226. return RingOverlay.isVisible();
  1227. };
  1228. /**
  1229. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1230. * @param {string} browser - name of browser for which to show the guidance
  1231. * overlay.
  1232. */
  1233. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1234. GumPermissionsOverlay.show(browser);
  1235. };
  1236. /**
  1237. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1238. */
  1239. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1240. GumPermissionsOverlay.hide();
  1241. };
  1242. /**
  1243. * Shows or hides the keyboard shortcuts panel, depending on the current state.'
  1244. */
  1245. UI.toggleKeyboardShortcutsPanel = function() {
  1246. if (!messageHandler.isDialogOpened()) {
  1247. let msg = $('#keyboard-shortcuts').html();
  1248. let buttons = { Close: true };
  1249. messageHandler.openDialog(
  1250. 'keyboardShortcuts.keyboardShortcuts', msg, true, buttons);
  1251. } else {
  1252. messageHandler.closeDialog();
  1253. }
  1254. };
  1255. /**
  1256. * Shows or hides the keyboard shortcuts panel.'
  1257. */
  1258. UI.showKeyboardShortcutsPanel = function(show) {
  1259. if (show) {
  1260. $('#keyboard-shortcuts').show();
  1261. } else {
  1262. $('#keyboard-shortcuts').hide();
  1263. }
  1264. };
  1265. module.exports = UI;