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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /* global Strophe, APP, $, config, interfaceConfig, toastr */
  2. /* jshint -W101 */
  3. var UI = {};
  4. var VideoLayout = require("./videolayout/VideoLayout.js");
  5. var AudioLevels = require("./audio_levels/AudioLevels.js");
  6. var Prezi = require("./prezi/Prezi.js");
  7. var Etherpad = require("./etherpad/Etherpad.js");
  8. var Chat = require("./side_pannels/chat/Chat.js");
  9. var Toolbar = require("./toolbars/Toolbar");
  10. var ToolbarToggler = require("./toolbars/ToolbarToggler");
  11. var BottomToolbar = require("./toolbars/BottomToolbar");
  12. var ContactList = require("./side_pannels/contactlist/ContactList");
  13. var Avatar = require("./avatar/Avatar");
  14. var EventEmitter = require("events");
  15. var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
  16. var Settings = require("./../settings/Settings");
  17. var PanelToggler = require("./side_pannels/SidePanelToggler");
  18. UI.messageHandler = require("./util/MessageHandler");
  19. var messageHandler = UI.messageHandler;
  20. var Authentication = require("./authentication/Authentication");
  21. var UIUtil = require("./util/UIUtil");
  22. var JitsiPopover = require("./util/JitsiPopover");
  23. var CQEvents = require("../../service/connectionquality/CQEvents");
  24. var DesktopSharingEventTypes
  25. = require("../../service/desktopsharing/DesktopSharingEventTypes");
  26. var StatisticsEvents = require("../../service/statistics/Events");
  27. var UIEvents = require("../../service/UI/UIEvents");
  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.FILM_STRIP_TOGGLED, function (isToggled) {
  166. VideoLayout.onFilmStripToggled(isToggled);
  167. });
  168. UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
  169. UI.setUserAvatar(APP.conference.localId, email);
  170. });
  171. UI.addListener(UIEvents.PREZI_CLICKED, function () {
  172. Prezi.openPreziDialog();
  173. });
  174. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  175. Etherpad.toggleEtherpad(0);
  176. });
  177. UI.addListener(UIEvents.FULLSCREEN_TOGGLE, toggleFullScreen);
  178. UI.addListener(UIEvents.AUTH_CLICKED, function () {
  179. Authentication.authenticate();
  180. });
  181. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  182. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  183. PanelToggler.toggleSettingsMenu();
  184. });
  185. }
  186. function bindEvents() {
  187. function onResize() {
  188. Chat.resizeChat();
  189. VideoLayout.resizeLargeVideoContainer();
  190. }
  191. // Resize and reposition videos in full screen mode.
  192. $(document).on(
  193. 'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
  194. );
  195. $(window).resize(onResize);
  196. }
  197. UI.start = function () {
  198. document.title = interfaceConfig.APP_NAME;
  199. var setupWelcomePage = null;
  200. if(config.enableWelcomePage && window.location.pathname == "/" &&
  201. (!window.localStorage.welcomePageDisabled ||
  202. window.localStorage.welcomePageDisabled == "false")) {
  203. $("#videoconference_page").hide();
  204. if (!setupWelcomePage)
  205. setupWelcomePage = require("./welcome_page/WelcomePage");
  206. setupWelcomePage();
  207. return;
  208. }
  209. $("#welcome_page").hide();
  210. // Set the defaults for prompt dialogs.
  211. $.prompt.setDefaults({persistent: false});
  212. registerListeners();
  213. VideoLayout.init(eventEmitter);
  214. bindEvents();
  215. setupPrezi();
  216. if (!interfaceConfig.filmStripOnly) {
  217. $("#videospace").mousemove(function () {
  218. return ToolbarToggler.showToolbar();
  219. });
  220. setupToolbars();
  221. setupChat();
  222. // Display notice message at the top of the toolbar
  223. if (config.noticeMessage) {
  224. $('#noticeText').text(config.noticeMessage);
  225. $('#notice').css({display: 'block'});
  226. }
  227. $("#downloadlog").click(function (event) {
  228. // dump(event.target);
  229. // FIXME integrate logs
  230. });
  231. Feedback.init();
  232. } else {
  233. $("#header").css("display", "none");
  234. $("#bottomToolbar").css("display", "none");
  235. $("#downloadlog").css("display", "none");
  236. $("#remoteVideos").css("padding", "0px 0px 18px 0px");
  237. $("#remoteVideos").css("right", "0px");
  238. messageHandler.disableNotifications();
  239. $('body').popover("disable");
  240. JitsiPopover.enabled = false;
  241. }
  242. document.title = interfaceConfig.APP_NAME;
  243. if(config.requireDisplayName) {
  244. if (APP.settings.getDisplayName()) {
  245. promptDisplayName();
  246. }
  247. }
  248. if (!interfaceConfig.filmStripOnly) {
  249. toastr.options = {
  250. "closeButton": true,
  251. "debug": false,
  252. "positionClass": "notification-bottom-right",
  253. "onclick": null,
  254. "showDuration": "300",
  255. "hideDuration": "1000",
  256. "timeOut": "2000",
  257. "extendedTimeOut": "1000",
  258. "showEasing": "swing",
  259. "hideEasing": "linear",
  260. "showMethod": "fadeIn",
  261. "hideMethod": "fadeOut",
  262. "reposition": function () {
  263. if (PanelToggler.isVisible()) {
  264. $("#toast-container").addClass("notification-bottom-right-center");
  265. } else {
  266. $("#toast-container").removeClass("notification-bottom-right-center");
  267. }
  268. },
  269. "newestOnTop": false
  270. };
  271. SettingsMenu.init();
  272. }
  273. };
  274. UI.addLocalStream = function (track) {
  275. switch (track.getType()) {
  276. case 'audio':
  277. VideoLayout.changeLocalAudio(track);
  278. break;
  279. case 'video':
  280. VideoLayout.changeLocalVideo(track);
  281. break;
  282. default:
  283. console.error("Unknown stream type: " + track.getType());
  284. break;
  285. }
  286. };
  287. UI.addRemoteStream = function (stream) {
  288. VideoLayout.onRemoteStreamAdded(stream);
  289. };
  290. function chatAddError(errorMessage, originalText) {
  291. return Chat.chatAddError(errorMessage, originalText);
  292. }
  293. function chatSetSubject(text) {
  294. return Chat.chatSetSubject(text);
  295. }
  296. function initEtherpad(name) {
  297. Etherpad.init(name);
  298. }
  299. UI.addUser = function (jid, id, displayName) {
  300. messageHandler.notify(
  301. displayName,'notify.somebody', 'connected', 'notify.connected'
  302. );
  303. if (!config.startAudioMuted ||
  304. config.startAudioMuted > APP.conference.membersCount)
  305. UIUtil.playSoundNotification('userJoined');
  306. // Configure avatar
  307. UI.setUserAvatar(jid, id);
  308. // Add Peer's container
  309. VideoLayout.ensurePeerContainerExists(jid);
  310. };
  311. UI.removeUser = function (jid) {
  312. console.log('left.muc', jid);
  313. var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
  314. '>.displayname').html();
  315. messageHandler.notify(displayName,'notify.somebody',
  316. 'disconnected',
  317. 'notify.disconnected');
  318. if (!config.startAudioMuted ||
  319. config.startAudioMuted > APP.conference.membersCount) {
  320. UIUtil.playSoundNotification('userLeft');
  321. }
  322. ContactList.removeContact(jid);
  323. VideoLayout.participantLeft(jid);
  324. };
  325. function onMucPresenceStatus(jid, info) {
  326. VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
  327. }
  328. function onPeerVideoTypeChanged(resourceJid, newVideoType) {
  329. VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
  330. }
  331. UI.updateLocalRole = function (isModerator) {
  332. VideoLayout.showModeratorIndicator();
  333. Toolbar.showSipCallButton(isModerator);
  334. Toolbar.showRecordingButton(isModerator);
  335. SettingsMenu.onRoleChanged();
  336. if (isModerator) {
  337. Authentication.closeAuthenticationWindow();
  338. messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
  339. Toolbar.checkAutoRecord();
  340. }
  341. };
  342. UI.updateUserRole = function (user) {
  343. VideoLayout.showModeratorIndicator();
  344. if (!user.isModerator()) {
  345. return;
  346. }
  347. var displayName = user.getDisplayName();
  348. if (displayName) {
  349. messageHandler.notify(
  350. displayName, 'notify.somebody',
  351. 'connected', 'notify.grantedTo', {
  352. to: displayName
  353. }
  354. );
  355. } else {
  356. messageHandler.notify(
  357. '', 'notify.somebody',
  358. 'connected', 'notify.grantedToUnknown', {}
  359. );
  360. }
  361. };
  362. UI.notifyAuthRequired = function (intervalCallback) {
  363. Authentication.openAuthenticationDialog(APP.conference.roomName, intervalCallback);
  364. };
  365. UI.toggleSmileys = function () {
  366. Chat.toggleSmileys();
  367. };
  368. UI.getSettings = function () {
  369. return Settings.getSettings();
  370. };
  371. UI.toggleFilmStrip = function () {
  372. BottomToolbar.toggleFilmStrip();
  373. };
  374. UI.toggleChat = function () {
  375. BottomToolbar.toggleChat();
  376. };
  377. UI.toggleContactList = function () {
  378. BottomToolbar.toggleContactList();
  379. };
  380. UI.inputDisplayNameHandler = function (value) {
  381. VideoLayout.inputDisplayNameHandler(value);
  382. };
  383. /**
  384. * Return the type of the remote video.
  385. * @param jid the jid for the remote video
  386. * @returns the video type video or screen.
  387. */
  388. UI.getRemoteVideoType = function (jid) {
  389. return VideoLayout.getRemoteVideoType(jid);
  390. };
  391. UI.connectionIndicatorShowMore = function(jid) {
  392. return VideoLayout.showMore(jid);
  393. };
  394. UI.showLoginPopup = function(callback) {
  395. console.log('password is required');
  396. var message = '<h2 data-i18n="dialog.passwordRequired">';
  397. message += APP.translation.translateString(
  398. "dialog.passwordRequired");
  399. message += '</h2>' +
  400. '<input name="username" type="text" ' +
  401. 'placeholder="user@domain.net" autofocus>' +
  402. '<input name="password" ' +
  403. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  404. ' placeholder="user password">';
  405. UI.messageHandler.openTwoButtonDialog(null, null, null, message,
  406. true,
  407. "dialog.Ok",
  408. function (e, v, m, f) {
  409. if (v) {
  410. if (f.username && f.password) {
  411. callback(f.username, f.password);
  412. }
  413. }
  414. },
  415. null, null, ':input:first'
  416. );
  417. };
  418. UI.closeAuthenticationDialog = function () {
  419. Authentication.closeAuthenticationDialog();
  420. Authentication.stopInterval();
  421. };
  422. UI.askForNickname = function () {
  423. return window.prompt('Your nickname (optional)');
  424. };
  425. /**
  426. * Sets muted audio state for the local participant.
  427. */
  428. UI.setAudioMuted = function (mute) {
  429. VideoLayout.showLocalAudioIndicator(mute);
  430. UIUtil.buttonClick("#toolbar_button_mute", "icon-microphone icon-mic-disabled");
  431. };
  432. UI.setVideoMuted = function (muted) {
  433. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  434. };
  435. UI.addListener = function (type, listener) {
  436. eventEmitter.on(type, listener);
  437. };
  438. UI.clickOnVideo = function (videoNumber) {
  439. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  440. if (remoteVideos.length > videoNumber) {
  441. remoteVideos[videoNumber].click();
  442. }
  443. };
  444. //Used by torture
  445. UI.showToolbar = function () {
  446. return ToolbarToggler.showToolbar();
  447. };
  448. //Used by torture
  449. UI.dockToolbar = function (isDock) {
  450. return ToolbarToggler.dockToolbar(isDock);
  451. };
  452. UI.setUserAvatar = function (id, email) {
  453. // update avatar
  454. Avatar.setUserAvatar(id, email);
  455. var thumbUrl = Avatar.getThumbUrl(id);
  456. var contactListUrl = Avatar.getContactListUrl(id);
  457. VideoLayout.changeUserAvatar(id, thumbUrl);
  458. ContactList.changeUserAvatar(id, contactListUrl);
  459. if (APP.conference.isLocalId(id)) {
  460. SettingsMenu.changeAvatar(thumbUrl);
  461. }
  462. };
  463. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  464. var title = APP.translation.generateTranslationHTML(
  465. "dialog.error");
  466. var message;
  467. if (stropheErrorMsg) {
  468. message = APP.translation.generateTranslationHTML(
  469. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  470. } else {
  471. message = APP.translation.generateTranslationHTML(
  472. "dialog.connectError");
  473. }
  474. messageHandler.openDialog(
  475. title, message, true, {}, function (e, v, m, f) { return false; }
  476. );
  477. };
  478. UI.notifyFirefoxExtensionRequired = function (url) {
  479. messageHandler.openMessageDialog(
  480. "dialog.extensionRequired",
  481. null,
  482. null,
  483. APP.translation.generateTranslationHTML(
  484. "dialog.firefoxExtensionPrompt", {url: url}
  485. )
  486. );
  487. };
  488. UI.notifyInitiallyMuted = function () {
  489. messageHandler.notify(
  490. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  491. );
  492. };
  493. UI.markDominantSpiker = function (id) {
  494. VideoLayout.onDominantSpeakerChanged(id);
  495. };
  496. UI.handleLastNEndpoints = function (ids) {
  497. VideoLayout.onLastNEndpointsChanged(ids, []);
  498. };
  499. UI.setAudioLevel = function (id, lvl) {
  500. AudioLevels.updateAudioLevel(
  501. id, lvl, VideoLayout.getLargeVideoResource()
  502. );
  503. };
  504. UI.updateDesktopSharingButtons = function () {
  505. Toolbar.changeDesktopSharingButtonState();
  506. };
  507. UI.hideStats = function () {
  508. VideoLayout.hideStats();
  509. };
  510. UI.updateLocalStats = function (percent, stats) {
  511. VideoLayout.updateLocalConnectionStats(percent, stats);
  512. };
  513. UI.updateRemoteStats = function (jid, percent, stats) {
  514. VideoLayout.updateConnectionStats(jid, percent, stats);
  515. };
  516. UI.showAuthenticateButton = function (show) {
  517. Toolbar.showAuthenticateButton(show);
  518. };
  519. UI.markVideoInterrupted = function (interrupted) {
  520. if (interrupted) {
  521. VideoLayout.onVideoInterrupted();
  522. } else {
  523. VideoLayout.onVideoRestored();
  524. }
  525. };
  526. UI.markRoomLocked = function (locked) {
  527. if (locked) {
  528. Toolbar.lockLockButton();
  529. } else {
  530. Toolbar.unlockLockButton();
  531. }
  532. };
  533. UI.addMessage = function (from, displayName, message, stamp) {
  534. Chat.updateChatConversation(from, displayName, message, stamp);
  535. };
  536. UI.updateDTMFSupport = function (isDTMFSupported) {
  537. //TODO: enable when the UI is ready
  538. //Toolbar.showDialPadButton(dtmfSupport);
  539. };
  540. /**
  541. * Invite participants to conference.
  542. */
  543. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  544. let keyText = "";
  545. if (key) {
  546. keyText = APP.translation.translateString(
  547. "email.sharedKey", {sharedKey: key}
  548. );
  549. }
  550. let and = APP.translation.translateString("email.and");
  551. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  552. let subject = APP.translation.translateString(
  553. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  554. );
  555. let body = APP.translation.translateString(
  556. "email.body", {
  557. appName:interfaceConfig.APP_NAME,
  558. sharedKeyText: keyText,
  559. roomUrl,
  560. supportedBrowsers
  561. }
  562. );
  563. body = body.replace(/\n/g, "%0D%0A");
  564. if (nick) {
  565. body += "%0D%0A%0D%0A" + nick;
  566. }
  567. if (interfaceConfig.INVITATION_POWERED_BY) {
  568. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  569. }
  570. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  571. };
  572. UI.requestFeedback = function () {
  573. return new Promise(function (resolve, reject) {
  574. if (Feedback.isEnabled()) {
  575. // If the user has already entered feedback, we'll show the window and
  576. // immidiately start the conference dispose timeout.
  577. if (Feedback.feedbackScore > 0) {
  578. Feedback.openFeedbackWindow();
  579. resolve();
  580. } else { // Otherwise we'll wait for user's feedback.
  581. Feedback.openFeedbackWindow(resolve);
  582. }
  583. } else {
  584. // If the feedback functionality isn't enabled we show a thank you
  585. // dialog.
  586. messageHandler.openMessageDialog(
  587. null, null, null,
  588. APP.translation.translateString(
  589. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  590. )
  591. );
  592. resolve();
  593. }
  594. });
  595. };
  596. UI.requestRecordingToken = function () {
  597. let msg = APP.translation.generateTranslationHTML("dialog.recordingToken");
  598. let token = APP.translation.translateString("dialog.token");
  599. return new Promise(function (resolve, reject) {
  600. messageHandler.openTwoButtonDialog(
  601. null, null, null,
  602. `<h2>${msg}</h2>
  603. <input name="recordingToken" type="text"
  604. data-i18n="[placeholder]dialog.token"
  605. placeholder="${token}" autofocus>`,
  606. false, "dialog.Save",
  607. function (e, v, m, f) {
  608. if (v && f.recordingToken) {
  609. resolve(UIUtil.escapeHtml(f.recordingToken));
  610. } else {
  611. reject();
  612. }
  613. },
  614. null,
  615. function () { },
  616. ':input:first'
  617. );
  618. });
  619. };
  620. UI.updateRecordingState = function (state) {
  621. Toolbar.updateRecordingState(state);
  622. };
  623. module.exports = UI;