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

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