Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

UI.js 42KB

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