You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UI.js 41KB

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