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

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