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 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. /* global APP, $, 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 PreziManager from './prezi/Prezi';
  15. import EtherpadManager from './etherpad/Etherpad';
  16. import VideoLayout from "./videolayout/VideoLayout";
  17. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  18. import Settings from "./../settings/Settings";
  19. var EventEmitter = require("events");
  20. UI.messageHandler = require("./util/MessageHandler");
  21. var messageHandler = UI.messageHandler;
  22. var JitsiPopover = require("./util/JitsiPopover");
  23. var Feedback = require("./Feedback");
  24. var eventEmitter = new EventEmitter();
  25. UI.eventEmitter = eventEmitter;
  26. let preziManager;
  27. let etherpadManager;
  28. function promptDisplayName() {
  29. let nickRequiredMsg = APP.translation.translateString("dialog.displayNameRequired");
  30. let defaultNickMsg = APP.translation.translateString(
  31. "defaultNickname", {name: "Jane Pink"}
  32. );
  33. let message = `
  34. <h2 data-i18n="dialog.displayNameRequired">${nickRequiredMsg}</h2>
  35. <input name="displayName" type="text"
  36. data-i18n="[placeholder]defaultNickname"
  37. placeholder="${defaultNickMsg}" autofocus>`;
  38. let buttonTxt = APP.translation.generateTranslationHTML("dialog.Ok");
  39. let buttons = [{title: buttonTxt, value: "ok"}];
  40. messageHandler.openDialog(
  41. null, message,
  42. true,
  43. buttons,
  44. function (e, v, m, f) {
  45. if (v == "ok") {
  46. let displayName = f.displayName;
  47. if (displayName) {
  48. UI.inputDisplayNameHandler(displayName);
  49. return true;
  50. }
  51. }
  52. e.preventDefault();
  53. },
  54. function () {
  55. let form = $.prompt.getPrompt();
  56. let input = form.find("input[name='displayName']");
  57. input.focus();
  58. let button = form.find("button");
  59. button.attr("disabled", "disabled");
  60. input.keyup(function () {
  61. if (input.val()) {
  62. button.removeAttr("disabled");
  63. } else {
  64. button.attr("disabled", "disabled");
  65. }
  66. });
  67. }
  68. );
  69. }
  70. function setupChat() {
  71. Chat.init(eventEmitter);
  72. $("#toggle_smileys").click(function() {
  73. Chat.toggleSmileys();
  74. });
  75. }
  76. function setupToolbars() {
  77. Toolbar.init(eventEmitter);
  78. Toolbar.setupButtonsFromConfig();
  79. BottomToolbar.setupListeners(eventEmitter);
  80. }
  81. /**
  82. * Toggles the application in and out of full screen mode
  83. * (a.k.a. presentation mode in Chrome).
  84. */
  85. function toggleFullScreen () {
  86. let fsElement = document.documentElement;
  87. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  88. //Enter Full Screen
  89. if (fsElement.mozRequestFullScreen) {
  90. fsElement.mozRequestFullScreen();
  91. } else {
  92. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  93. }
  94. } else {
  95. //Exit Full Screen
  96. if (document.mozCancelFullScreen) {
  97. document.mozCancelFullScreen();
  98. } else {
  99. document.webkitCancelFullScreen();
  100. }
  101. }
  102. }
  103. UI.notifyGracefulShudown = function () {
  104. messageHandler.openMessageDialog(
  105. 'dialog.serviceUnavailable',
  106. 'dialog.gracefulShutdown'
  107. );
  108. };
  109. UI.notifyReservationError = function (code, msg) {
  110. var title = APP.translation.generateTranslationHTML(
  111. "dialog.reservationError");
  112. var message = APP.translation.generateTranslationHTML(
  113. "dialog.reservationErrorMsg", {code: code, msg: msg});
  114. messageHandler.openDialog(
  115. title,
  116. message,
  117. true, {},
  118. function (event, value, message, formVals) {
  119. return false;
  120. }
  121. );
  122. };
  123. UI.notifyKicked = function () {
  124. messageHandler.openMessageDialog("dialog.sessTerminated", "dialog.kickMessage");
  125. };
  126. UI.notifyBridgeDown = function () {
  127. messageHandler.showError("dialog.error", "dialog.bridgeUnavailable");
  128. };
  129. UI.changeDisplayName = function (id, displayName) {
  130. ContactList.onDisplayNameChange(id, displayName);
  131. SettingsMenu.onDisplayNameChange(id, displayName);
  132. VideoLayout.onDisplayNameChanged(id, displayName);
  133. if (APP.conference.isLocalId(id)) {
  134. Chat.setChatConversationMode(!!displayName);
  135. }
  136. };
  137. UI.initConference = function () {
  138. var id = APP.conference.localId;
  139. Toolbar.updateRoomUrl(window.location.href);
  140. var meHTML = APP.translation.generateTranslationHTML("me");
  141. var settings = Settings.getSettings();
  142. $("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
  143. // Add myself to the contact list.
  144. ContactList.addContact(id);
  145. // Once we've joined the muc show the toolbar
  146. ToolbarToggler.showToolbar();
  147. var displayName = config.displayJids ? id : settings.displayName;
  148. if (displayName) {
  149. UI.changeDisplayName('localVideoContainer', displayName);
  150. }
  151. // Make sure we configure our avatar id, before creating avatar for us
  152. UI.setUserAvatar(id, settings.email);
  153. Toolbar.checkAutoEnableDesktopSharing();
  154. };
  155. UI.mucJoined = function () {
  156. VideoLayout.mucJoined();
  157. };
  158. function registerListeners() {
  159. UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
  160. UI.setUserAvatar(APP.conference.localId, email);
  161. });
  162. UI.addListener(UIEvents.PREZI_CLICKED, function () {
  163. preziManager.handlePreziButtonClicked();
  164. });
  165. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  166. if (etherpadManager) {
  167. etherpadManager.toggleEtherpad();
  168. }
  169. });
  170. UI.addListener(UIEvents.FULLSCREEN_TOGGLE, toggleFullScreen);
  171. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  172. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  173. PanelToggler.toggleSettingsMenu();
  174. });
  175. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  176. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.toggleFilmStrip);
  177. }
  178. function bindEvents() {
  179. function onResize() {
  180. PanelToggler.resizeChat();
  181. VideoLayout.resizeLargeVideoContainer(PanelToggler.isVisible());
  182. }
  183. // Resize and reposition videos in full screen mode.
  184. $(document).on(
  185. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  186. onResize
  187. );
  188. $(window).resize(onResize);
  189. }
  190. /**
  191. * Starts the UI module and initializes all related components.
  192. *
  193. * @returns {boolean} true if the UI is ready and the conference should be
  194. * esablished, false - otherwise (for example in the case of welcome page)
  195. */
  196. UI.start = function () {
  197. document.title = interfaceConfig.APP_NAME;
  198. var setupWelcomePage = null;
  199. if(config.enableWelcomePage && window.location.pathname == "/" &&
  200. (!window.localStorage.welcomePageDisabled ||
  201. window.localStorage.welcomePageDisabled == "false")) {
  202. $("#videoconference_page").hide();
  203. if (!setupWelcomePage)
  204. setupWelcomePage = require("./welcome_page/WelcomePage");
  205. setupWelcomePage();
  206. // Return false to indicate that the UI hasn't been fully started and
  207. // conference ready. We're still waiting for input from the user.
  208. return false;
  209. }
  210. $("#welcome_page").hide();
  211. // Set the defaults for prompt dialogs.
  212. $.prompt.setDefaults({persistent: false});
  213. registerListeners();
  214. BottomToolbar.init();
  215. VideoLayout.init(eventEmitter);
  216. if (!interfaceConfig.filmStripOnly) {
  217. VideoLayout.initLargeVideo(PanelToggler.isVisible());
  218. }
  219. VideoLayout.resizeLargeVideoContainer(PanelToggler.isVisible());
  220. ContactList.init(eventEmitter);
  221. bindEvents();
  222. preziManager = new PreziManager(eventEmitter);
  223. if (!interfaceConfig.filmStripOnly) {
  224. $("#videospace").mousemove(function () {
  225. return ToolbarToggler.showToolbar();
  226. });
  227. setupToolbars();
  228. setupChat();
  229. // Display notice message at the top of the toolbar
  230. if (config.noticeMessage) {
  231. $('#noticeText').text(config.noticeMessage);
  232. $('#notice').css({display: 'block'});
  233. }
  234. $("#downloadlog").click(function (event) {
  235. let logs = APP.conference.getLogs();
  236. let data = encodeURIComponent(JSON.stringify(logs, null, ' '));
  237. let elem = event.target.parentNode;
  238. elem.download = 'meetlog.json';
  239. elem.href = 'data:application/json;charset=utf-8,\n' + data;
  240. });
  241. Feedback.init();
  242. } else {
  243. $("#header").css("display", "none");
  244. $("#bottomToolbar").css("display", "none");
  245. $("#downloadlog").css("display", "none");
  246. BottomToolbar.setupFilmStripOnly();
  247. messageHandler.disableNotifications();
  248. $('body').popover("disable");
  249. JitsiPopover.enabled = false;
  250. }
  251. document.title = interfaceConfig.APP_NAME;
  252. if(config.requireDisplayName) {
  253. if (!APP.settings.getDisplayName()) {
  254. promptDisplayName();
  255. }
  256. }
  257. if (!interfaceConfig.filmStripOnly) {
  258. toastr.options = {
  259. "closeButton": true,
  260. "debug": false,
  261. "positionClass": "notification-bottom-right",
  262. "onclick": null,
  263. "showDuration": "300",
  264. "hideDuration": "1000",
  265. "timeOut": "2000",
  266. "extendedTimeOut": "1000",
  267. "showEasing": "swing",
  268. "hideEasing": "linear",
  269. "showMethod": "fadeIn",
  270. "hideMethod": "fadeOut",
  271. "reposition": function () {
  272. if (PanelToggler.isVisible()) {
  273. $("#toast-container").addClass("notification-bottom-right-center");
  274. } else {
  275. $("#toast-container").removeClass("notification-bottom-right-center");
  276. }
  277. },
  278. "newestOnTop": false
  279. };
  280. SettingsMenu.init(eventEmitter);
  281. }
  282. // Return true to indicate that the UI has been fully started and
  283. // conference ready.
  284. return true;
  285. };
  286. UI.addLocalStream = function (track) {
  287. switch (track.getType()) {
  288. case 'audio':
  289. VideoLayout.changeLocalAudio(track);
  290. break;
  291. case 'video':
  292. VideoLayout.changeLocalVideo(track);
  293. break;
  294. default:
  295. console.error("Unknown stream type: " + track.getType());
  296. break;
  297. }
  298. };
  299. UI.addRemoteStream = function (stream) {
  300. VideoLayout.onRemoteStreamAdded(stream);
  301. };
  302. function chatAddError(errorMessage, originalText) {
  303. return Chat.chatAddError(errorMessage, originalText);
  304. }
  305. UI.setSubject = function (subject) {
  306. Chat.setSubject(subject);
  307. };
  308. UI.initEtherpad = function (name) {
  309. if (etherpadManager || !config.etherpad_base || !name) {
  310. return;
  311. }
  312. console.log('Etherpad is enabled');
  313. etherpadManager = new EtherpadManager(config.etherpad_base, name);
  314. Toolbar.showEtherpadButton();
  315. };
  316. UI.addUser = function (id, displayName) {
  317. ContactList.addContact(id);
  318. messageHandler.notify(
  319. displayName,'notify.somebody', 'connected', 'notify.connected'
  320. );
  321. if (!config.startAudioMuted ||
  322. config.startAudioMuted > APP.conference.membersCount)
  323. UIUtil.playSoundNotification('userJoined');
  324. // Configure avatar
  325. UI.setUserAvatar(id);
  326. // Add Peer's container
  327. VideoLayout.addParticipantContainer(id);
  328. };
  329. UI.removeUser = function (id, displayName) {
  330. ContactList.removeContact(id);
  331. messageHandler.notify(
  332. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  333. );
  334. if (!config.startAudioMuted
  335. || config.startAudioMuted > APP.conference.membersCount) {
  336. UIUtil.playSoundNotification('userLeft');
  337. }
  338. VideoLayout.removeParticipantContainer(id);
  339. };
  340. //FIXME: NOT USED. Should start using the lib
  341. // function onMucPresenceStatus(jid, info) {
  342. // VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
  343. // }
  344. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  345. VideoLayout.onVideoTypeChanged(id, newVideoType);
  346. };
  347. UI.updateLocalRole = function (isModerator) {
  348. VideoLayout.showModeratorIndicator();
  349. Toolbar.showSipCallButton(isModerator);
  350. Toolbar.showRecordingButton(isModerator);
  351. SettingsMenu.onRoleChanged();
  352. if (isModerator) {
  353. messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
  354. Toolbar.checkAutoRecord();
  355. }
  356. };
  357. /**
  358. * Check the role for the user and reflect it in the UI, moderator ui indication
  359. * and notifies user who is the moderator
  360. * @param user to check for moderator
  361. */
  362. UI.updateUserRole = function (user) {
  363. VideoLayout.showModeratorIndicator();
  364. if (!user.isModerator()) {
  365. return;
  366. }
  367. var displayName = user.getDisplayName();
  368. if (displayName) {
  369. messageHandler.notify(
  370. displayName, 'notify.somebody',
  371. 'connected', 'notify.grantedTo', {
  372. to: displayName
  373. }
  374. );
  375. } else {
  376. messageHandler.notify(
  377. '', 'notify.somebody',
  378. 'connected', 'notify.grantedToUnknown', {}
  379. );
  380. }
  381. };
  382. UI.toggleSmileys = function () {
  383. Chat.toggleSmileys();
  384. };
  385. UI.getSettings = function () {
  386. return Settings.getSettings();
  387. };
  388. UI.toggleFilmStrip = function () {
  389. BottomToolbar.toggleFilmStrip();
  390. };
  391. UI.toggleChat = function () {
  392. PanelToggler.toggleChat();
  393. };
  394. UI.toggleContactList = function () {
  395. PanelToggler.toggleContactList();
  396. };
  397. UI.inputDisplayNameHandler = function (value) {
  398. VideoLayout.inputDisplayNameHandler(value);
  399. };
  400. /**
  401. * Return the type of the remote video.
  402. * @param jid the jid for the remote video
  403. * @returns the video type video or screen.
  404. */
  405. UI.getRemoteVideoType = function (jid) {
  406. return VideoLayout.getRemoteVideoType(jid);
  407. };
  408. UI.connectionIndicatorShowMore = function(jid) {
  409. return VideoLayout.showMore(jid);
  410. };
  411. UI.showLoginPopup = function(callback) {
  412. console.log('password is required');
  413. var message = '<h2 data-i18n="dialog.passwordRequired">';
  414. message += APP.translation.translateString(
  415. "dialog.passwordRequired");
  416. message += '</h2>' +
  417. '<input name="username" type="text" ' +
  418. 'placeholder="user@domain.net" autofocus>' +
  419. '<input name="password" ' +
  420. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  421. ' placeholder="user password">';
  422. UI.messageHandler.openTwoButtonDialog(null, null, null, message,
  423. true,
  424. "dialog.Ok",
  425. function (e, v, m, f) {
  426. if (v) {
  427. if (f.username && f.password) {
  428. callback(f.username, f.password);
  429. }
  430. }
  431. },
  432. null, null, ':input:first'
  433. );
  434. };
  435. UI.askForNickname = function () {
  436. return window.prompt('Your nickname (optional)');
  437. };
  438. /**
  439. * Sets muted audio state for participant
  440. */
  441. UI.setAudioMuted = function (id, muted) {
  442. VideoLayout.onAudioMute(id, muted);
  443. if(APP.conference.isLocalId(id))
  444. UIUtil.buttonClick("#toolbar_button_mute",
  445. "icon-microphone icon-mic-disabled");
  446. };
  447. /**
  448. * Sets muted video state for participant
  449. */
  450. UI.setVideoMuted = function (id, muted) {
  451. VideoLayout.onVideoMute(id, muted);
  452. if(APP.conference.isLocalId(id))
  453. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  454. };
  455. UI.addListener = function (type, listener) {
  456. eventEmitter.on(type, listener);
  457. };
  458. UI.clickOnVideo = function (videoNumber) {
  459. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  460. if (remoteVideos.length > videoNumber) {
  461. remoteVideos[videoNumber].click();
  462. }
  463. };
  464. //Used by torture
  465. UI.showToolbar = function () {
  466. return ToolbarToggler.showToolbar();
  467. };
  468. //Used by torture
  469. UI.dockToolbar = function (isDock) {
  470. ToolbarToggler.dockToolbar(isDock);
  471. };
  472. UI.setUserAvatar = function (id, email) {
  473. // update avatar
  474. Avatar.setUserAvatar(id, email);
  475. var avatarUrl = Avatar.getAvatarUrl(id);
  476. VideoLayout.changeUserAvatar(id, avatarUrl);
  477. ContactList.changeUserAvatar(id, avatarUrl);
  478. if (APP.conference.isLocalId(id)) {
  479. SettingsMenu.changeAvatar(avatarUrl);
  480. }
  481. };
  482. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  483. var title = APP.translation.generateTranslationHTML(
  484. "dialog.error");
  485. var message;
  486. if (stropheErrorMsg) {
  487. message = APP.translation.generateTranslationHTML(
  488. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  489. } else {
  490. message = APP.translation.generateTranslationHTML(
  491. "dialog.connectError");
  492. }
  493. messageHandler.openDialog(
  494. title, message, true, {}, function (e, v, m, f) { return false; }
  495. );
  496. };
  497. UI.notifyFirefoxExtensionRequired = function (url) {
  498. messageHandler.openMessageDialog(
  499. "dialog.extensionRequired",
  500. null,
  501. null,
  502. APP.translation.generateTranslationHTML(
  503. "dialog.firefoxExtensionPrompt", {url: url}
  504. )
  505. );
  506. };
  507. UI.notifyInitiallyMuted = function () {
  508. messageHandler.notify(
  509. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  510. );
  511. };
  512. UI.markDominantSpeaker = function (id) {
  513. VideoLayout.onDominantSpeakerChanged(id);
  514. };
  515. UI.handleLastNEndpoints = function (ids) {
  516. VideoLayout.onLastNEndpointsChanged(ids, []);
  517. };
  518. UI.setAudioLevel = function (id, lvl) {
  519. VideoLayout.setAudioLevel(id, lvl);
  520. };
  521. UI.updateDesktopSharingButtons = function (isSharingScreen) {
  522. Toolbar.changeDesktopSharingButtonState(isSharingScreen);
  523. };
  524. UI.hideStats = function () {
  525. VideoLayout.hideStats();
  526. };
  527. UI.updateLocalStats = function (percent, stats) {
  528. VideoLayout.updateLocalConnectionStats(percent, stats);
  529. };
  530. UI.updateRemoteStats = function (id, percent, stats) {
  531. VideoLayout.updateConnectionStats(id, percent, stats);
  532. };
  533. UI.markVideoInterrupted = function (interrupted) {
  534. if (interrupted) {
  535. VideoLayout.onVideoInterrupted();
  536. } else {
  537. VideoLayout.onVideoRestored();
  538. }
  539. };
  540. UI.markRoomLocked = function (locked) {
  541. if (locked) {
  542. Toolbar.lockLockButton();
  543. } else {
  544. Toolbar.unlockLockButton();
  545. }
  546. };
  547. UI.addMessage = function (from, displayName, message, stamp) {
  548. Chat.updateChatConversation(from, displayName, message, stamp);
  549. };
  550. UI.updateDTMFSupport = function (isDTMFSupported) {
  551. //TODO: enable when the UI is ready
  552. //Toolbar.showDialPadButton(dtmfSupport);
  553. };
  554. /**
  555. * Invite participants to conference.
  556. */
  557. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  558. let keyText = "";
  559. if (key) {
  560. keyText = APP.translation.translateString(
  561. "email.sharedKey", {sharedKey: key}
  562. );
  563. }
  564. let and = APP.translation.translateString("email.and");
  565. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  566. let subject = APP.translation.translateString(
  567. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  568. );
  569. let body = APP.translation.translateString(
  570. "email.body", {
  571. appName:interfaceConfig.APP_NAME,
  572. sharedKeyText: keyText,
  573. roomUrl,
  574. supportedBrowsers
  575. }
  576. );
  577. body = body.replace(/\n/g, "%0D%0A");
  578. if (nick) {
  579. body += "%0D%0A%0D%0A" + nick;
  580. }
  581. if (interfaceConfig.INVITATION_POWERED_BY) {
  582. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  583. }
  584. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  585. };
  586. UI.requestFeedback = function () {
  587. return new Promise(function (resolve, reject) {
  588. if (Feedback.isEnabled()) {
  589. // If the user has already entered feedback, we'll show the window and
  590. // immidiately start the conference dispose timeout.
  591. if (Feedback.feedbackScore > 0) {
  592. Feedback.openFeedbackWindow();
  593. resolve();
  594. } else { // Otherwise we'll wait for user's feedback.
  595. Feedback.openFeedbackWindow(resolve);
  596. }
  597. } else {
  598. // If the feedback functionality isn't enabled we show a thank you
  599. // dialog.
  600. messageHandler.openMessageDialog(
  601. null, null, null,
  602. APP.translation.translateString(
  603. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  604. )
  605. );
  606. resolve();
  607. }
  608. });
  609. };
  610. UI.requestRecordingToken = function () {
  611. let msg = APP.translation.generateTranslationHTML("dialog.recordingToken");
  612. let token = APP.translation.translateString("dialog.token");
  613. return new Promise(function (resolve, reject) {
  614. messageHandler.openTwoButtonDialog(
  615. null, null, null,
  616. `<h2>${msg}</h2>
  617. <input name="recordingToken" type="text"
  618. data-i18n="[placeholder]dialog.token"
  619. placeholder="${token}" autofocus>`,
  620. false, "dialog.Save",
  621. function (e, v, m, f) {
  622. if (v && f.recordingToken) {
  623. resolve(UIUtil.escapeHtml(f.recordingToken));
  624. } else {
  625. reject();
  626. }
  627. },
  628. null,
  629. function () { },
  630. ':input:first'
  631. );
  632. });
  633. };
  634. UI.updateRecordingState = function (state) {
  635. Toolbar.updateRecordingState(state);
  636. };
  637. UI.notifyTokenAuthFailed = function () {
  638. messageHandler.showError("dialog.error", "dialog.tokenAuthFailed");
  639. };
  640. UI.updateAuthInfo = function (isAuthEnabled, login) {
  641. let loggedIn = !!login;
  642. Toolbar.showAuthenticateButton(isAuthEnabled);
  643. if (isAuthEnabled) {
  644. Toolbar.setAuthenticatedIdentity(login);
  645. Toolbar.showLoginButton(!loggedIn);
  646. Toolbar.showLogoutButton(loggedIn);
  647. }
  648. };
  649. UI.showPrezi = function (userId, url, slide) {
  650. preziManager.showPrezi(userId, url, slide);
  651. };
  652. UI.stopPrezi = function (userId) {
  653. if (preziManager.isSharing(userId)) {
  654. preziManager.removePrezi(userId);
  655. }
  656. };
  657. UI.onStartMutedChanged = function () {
  658. SettingsMenu.onStartMutedChanged();
  659. };
  660. /**
  661. * Returns the id of the current video shown on large.
  662. * Currently used by tests (troture).
  663. */
  664. UI.getLargeVideoID = function () {
  665. return VideoLayout.getLargeVideoID();
  666. };
  667. UI.showExtensionRequiredDialog = function (url) {
  668. APP.UI.messageHandler.openMessageDialog(
  669. "dialog.extensionRequired",
  670. null,
  671. null,
  672. APP.translation.generateTranslationHTML(
  673. "dialog.firefoxExtensionPrompt", {url: url}));
  674. }
  675. module.exports = UI;