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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  16. var Prezi = require("./prezi/Prezi");
  17. var Etherpad = require("./etherpad/Etherpad");
  18. var EventEmitter = require("events");
  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. if (APP.conference.isLocalId(id)) {
  142. Chat.setChatConversationMode(!!displayName);
  143. }
  144. };
  145. UI.initConference = function () {
  146. var id = APP.conference.localId;
  147. Toolbar.updateRoomUrl(window.location.href);
  148. var meHTML = APP.translation.generateTranslationHTML("me");
  149. var settings = Settings.getSettings();
  150. $("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
  151. // Make sure we configure our avatar id, before creating avatar for us
  152. UI.setUserAvatar(id, settings.email || settings.uid);
  153. // Add myself to the contact list.
  154. ContactList.addContact(id);
  155. // Once we've joined the muc show the toolbar
  156. ToolbarToggler.showToolbar();
  157. var displayName = config.displayJids ? id : settings.displayName;
  158. if (displayName) {
  159. UI.changeDisplayName('localVideoContainer', displayName);
  160. }
  161. VideoLayout.mucJoined();
  162. Toolbar.checkAutoEnableDesktopSharing();
  163. };
  164. function registerListeners() {
  165. UI.addListener(UIEvents.LARGEVIDEO_INIT, function () {
  166. AudioLevels.init();
  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. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  186. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.toggleFilmStrip);
  187. }
  188. function bindEvents() {
  189. function onResize() {
  190. PanelToggler.resizeChat();
  191. VideoLayout.resizeLargeVideoContainer();
  192. }
  193. // Resize and reposition videos in full screen mode.
  194. $(document).on(
  195. 'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
  196. );
  197. $(window).resize(onResize);
  198. }
  199. UI.start = function () {
  200. document.title = interfaceConfig.APP_NAME;
  201. var setupWelcomePage = null;
  202. if(config.enableWelcomePage && window.location.pathname == "/" &&
  203. (!window.localStorage.welcomePageDisabled ||
  204. window.localStorage.welcomePageDisabled == "false")) {
  205. $("#videoconference_page").hide();
  206. if (!setupWelcomePage)
  207. setupWelcomePage = require("./welcome_page/WelcomePage");
  208. setupWelcomePage();
  209. return;
  210. }
  211. $("#welcome_page").hide();
  212. // Set the defaults for prompt dialogs.
  213. $.prompt.setDefaults({persistent: false});
  214. registerListeners();
  215. VideoLayout.init(eventEmitter);
  216. ContactList.init(eventEmitter);
  217. bindEvents();
  218. setupPrezi();
  219. if (!interfaceConfig.filmStripOnly) {
  220. $("#videospace").mousemove(function () {
  221. return ToolbarToggler.showToolbar();
  222. });
  223. setupToolbars();
  224. setupChat();
  225. // Display notice message at the top of the toolbar
  226. if (config.noticeMessage) {
  227. $('#noticeText').text(config.noticeMessage);
  228. $('#notice').css({display: 'block'});
  229. }
  230. $("#downloadlog").click(function (event) {
  231. // dump(event.target);
  232. // FIXME integrate logs
  233. });
  234. Feedback.init();
  235. } else {
  236. $("#header").css("display", "none");
  237. $("#bottomToolbar").css("display", "none");
  238. $("#downloadlog").css("display", "none");
  239. $("#remoteVideos").css("padding", "0px 0px 18px 0px");
  240. $("#remoteVideos").css("right", "0px");
  241. messageHandler.disableNotifications();
  242. $('body').popover("disable");
  243. JitsiPopover.enabled = false;
  244. }
  245. document.title = interfaceConfig.APP_NAME;
  246. if(config.requireDisplayName) {
  247. if (APP.settings.getDisplayName()) {
  248. promptDisplayName();
  249. }
  250. }
  251. if (!interfaceConfig.filmStripOnly) {
  252. toastr.options = {
  253. "closeButton": true,
  254. "debug": false,
  255. "positionClass": "notification-bottom-right",
  256. "onclick": null,
  257. "showDuration": "300",
  258. "hideDuration": "1000",
  259. "timeOut": "2000",
  260. "extendedTimeOut": "1000",
  261. "showEasing": "swing",
  262. "hideEasing": "linear",
  263. "showMethod": "fadeIn",
  264. "hideMethod": "fadeOut",
  265. "reposition": function () {
  266. if (PanelToggler.isVisible()) {
  267. $("#toast-container").addClass("notification-bottom-right-center");
  268. } else {
  269. $("#toast-container").removeClass("notification-bottom-right-center");
  270. }
  271. },
  272. "newestOnTop": false
  273. };
  274. SettingsMenu.init();
  275. }
  276. };
  277. UI.addLocalStream = function (track) {
  278. switch (track.getType()) {
  279. case 'audio':
  280. VideoLayout.changeLocalAudio(track);
  281. break;
  282. case 'video':
  283. VideoLayout.changeLocalVideo(track);
  284. break;
  285. default:
  286. console.error("Unknown stream type: " + track.getType());
  287. break;
  288. }
  289. };
  290. UI.addRemoteStream = function (stream) {
  291. VideoLayout.onRemoteStreamAdded(stream);
  292. };
  293. function chatAddError(errorMessage, originalText) {
  294. return Chat.chatAddError(errorMessage, originalText);
  295. }
  296. UI.setSubject = function (subject) {
  297. Chat.setSubject(subject);
  298. };
  299. function initEtherpad(name) {
  300. Etherpad.init(name);
  301. }
  302. UI.addUser = function (id, displayName) {
  303. ContactList.addContact(id);
  304. messageHandler.notify(
  305. displayName,'notify.somebody', 'connected', 'notify.connected'
  306. );
  307. if (!config.startAudioMuted ||
  308. config.startAudioMuted > APP.conference.membersCount)
  309. UIUtil.playSoundNotification('userJoined');
  310. // Configure avatar
  311. UI.setUserAvatar(id, displayName);
  312. // Add Peer's container
  313. VideoLayout.addParticipantContainer(id);
  314. };
  315. UI.removeUser = function (id, displayName) {
  316. ContactList.removeContact(id);
  317. messageHandler.notify(
  318. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  319. );
  320. if (!config.startAudioMuted || config.startAudioMuted > APP.conference.membersCount) {
  321. UIUtil.playSoundNotification('userLeft');
  322. }
  323. VideoLayout.removeParticipantContainer(id);
  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. VideoLayout.updateLargeVideoSize();
  374. };
  375. UI.toggleChat = function () {
  376. PanelToggler.toggleChat();
  377. };
  378. UI.toggleContactList = function () {
  379. PanelToggler.toggleContactList();
  380. };
  381. UI.inputDisplayNameHandler = function (value) {
  382. VideoLayout.inputDisplayNameHandler(value);
  383. };
  384. /**
  385. * Return the type of the remote video.
  386. * @param jid the jid for the remote video
  387. * @returns the video type video or screen.
  388. */
  389. UI.getRemoteVideoType = function (jid) {
  390. return VideoLayout.getRemoteVideoType(jid);
  391. };
  392. UI.connectionIndicatorShowMore = function(jid) {
  393. return VideoLayout.showMore(jid);
  394. };
  395. UI.showLoginPopup = function(callback) {
  396. console.log('password is required');
  397. var message = '<h2 data-i18n="dialog.passwordRequired">';
  398. message += APP.translation.translateString(
  399. "dialog.passwordRequired");
  400. message += '</h2>' +
  401. '<input name="username" type="text" ' +
  402. 'placeholder="user@domain.net" autofocus>' +
  403. '<input name="password" ' +
  404. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  405. ' placeholder="user password">';
  406. UI.messageHandler.openTwoButtonDialog(null, null, null, message,
  407. true,
  408. "dialog.Ok",
  409. function (e, v, m, f) {
  410. if (v) {
  411. if (f.username && f.password) {
  412. callback(f.username, f.password);
  413. }
  414. }
  415. },
  416. null, null, ':input:first'
  417. );
  418. };
  419. UI.closeAuthenticationDialog = function () {
  420. Authentication.closeAuthenticationDialog();
  421. Authentication.stopInterval();
  422. };
  423. UI.askForNickname = function () {
  424. return window.prompt('Your nickname (optional)');
  425. };
  426. /**
  427. * Sets muted audio state for the local participant.
  428. */
  429. UI.setAudioMuted = function (mute) {
  430. VideoLayout.showLocalAudioIndicator(mute);
  431. UIUtil.buttonClick("#toolbar_button_mute", "icon-microphone icon-mic-disabled");
  432. };
  433. UI.setVideoMuted = function (muted) {
  434. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  435. };
  436. UI.addListener = function (type, listener) {
  437. eventEmitter.on(type, listener);
  438. };
  439. UI.clickOnVideo = function (videoNumber) {
  440. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  441. if (remoteVideos.length > videoNumber) {
  442. remoteVideos[videoNumber].click();
  443. }
  444. };
  445. //Used by torture
  446. UI.showToolbar = function () {
  447. return ToolbarToggler.showToolbar();
  448. };
  449. //Used by torture
  450. UI.dockToolbar = function (isDock) {
  451. ToolbarToggler.dockToolbar(isDock);
  452. };
  453. UI.setUserAvatar = function (id, email) {
  454. // update avatar
  455. Avatar.setUserAvatar(id, email);
  456. var thumbUrl = Avatar.getThumbUrl(id);
  457. var contactListUrl = Avatar.getContactListUrl(id);
  458. VideoLayout.changeUserAvatar(id, thumbUrl);
  459. ContactList.changeUserAvatar(id, contactListUrl);
  460. if (APP.conference.isLocalId(id)) {
  461. SettingsMenu.changeAvatar(thumbUrl);
  462. }
  463. };
  464. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  465. var title = APP.translation.generateTranslationHTML(
  466. "dialog.error");
  467. var message;
  468. if (stropheErrorMsg) {
  469. message = APP.translation.generateTranslationHTML(
  470. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  471. } else {
  472. message = APP.translation.generateTranslationHTML(
  473. "dialog.connectError");
  474. }
  475. messageHandler.openDialog(
  476. title, message, true, {}, function (e, v, m, f) { return false; }
  477. );
  478. };
  479. UI.notifyFirefoxExtensionRequired = function (url) {
  480. messageHandler.openMessageDialog(
  481. "dialog.extensionRequired",
  482. null,
  483. null,
  484. APP.translation.generateTranslationHTML(
  485. "dialog.firefoxExtensionPrompt", {url: url}
  486. )
  487. );
  488. };
  489. UI.notifyInitiallyMuted = function () {
  490. messageHandler.notify(
  491. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  492. );
  493. };
  494. UI.markDominantSpiker = function (id) {
  495. VideoLayout.onDominantSpeakerChanged(id);
  496. };
  497. UI.handleLastNEndpoints = function (ids) {
  498. VideoLayout.onLastNEndpointsChanged(ids, []);
  499. };
  500. UI.setAudioLevel = function (id, lvl) {
  501. AudioLevels.updateAudioLevel(
  502. id, lvl, VideoLayout.getLargeVideoId()
  503. );
  504. };
  505. UI.updateDesktopSharingButtons = function () {
  506. Toolbar.changeDesktopSharingButtonState();
  507. };
  508. UI.hideStats = function () {
  509. VideoLayout.hideStats();
  510. };
  511. UI.updateLocalStats = function (percent, stats) {
  512. VideoLayout.updateLocalConnectionStats(percent, stats);
  513. };
  514. UI.updateRemoteStats = function (jid, percent, stats) {
  515. VideoLayout.updateConnectionStats(jid, percent, stats);
  516. };
  517. UI.showAuthenticateButton = function (show) {
  518. Toolbar.showAuthenticateButton(show);
  519. };
  520. UI.markVideoInterrupted = function (interrupted) {
  521. if (interrupted) {
  522. VideoLayout.onVideoInterrupted();
  523. } else {
  524. VideoLayout.onVideoRestored();
  525. }
  526. };
  527. UI.markRoomLocked = function (locked) {
  528. if (locked) {
  529. Toolbar.lockLockButton();
  530. } else {
  531. Toolbar.unlockLockButton();
  532. }
  533. };
  534. UI.addMessage = function (from, displayName, message, stamp) {
  535. Chat.updateChatConversation(from, displayName, message, stamp);
  536. };
  537. UI.updateDTMFSupport = function (isDTMFSupported) {
  538. //TODO: enable when the UI is ready
  539. //Toolbar.showDialPadButton(dtmfSupport);
  540. };
  541. /**
  542. * Invite participants to conference.
  543. */
  544. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  545. let keyText = "";
  546. if (key) {
  547. keyText = APP.translation.translateString(
  548. "email.sharedKey", {sharedKey: key}
  549. );
  550. }
  551. let and = APP.translation.translateString("email.and");
  552. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  553. let subject = APP.translation.translateString(
  554. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  555. );
  556. let body = APP.translation.translateString(
  557. "email.body", {
  558. appName:interfaceConfig.APP_NAME,
  559. sharedKeyText: keyText,
  560. roomUrl,
  561. supportedBrowsers
  562. }
  563. );
  564. body = body.replace(/\n/g, "%0D%0A");
  565. if (nick) {
  566. body += "%0D%0A%0D%0A" + nick;
  567. }
  568. if (interfaceConfig.INVITATION_POWERED_BY) {
  569. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  570. }
  571. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  572. };
  573. UI.requestFeedback = function () {
  574. return new Promise(function (resolve, reject) {
  575. if (Feedback.isEnabled()) {
  576. // If the user has already entered feedback, we'll show the window and
  577. // immidiately start the conference dispose timeout.
  578. if (Feedback.feedbackScore > 0) {
  579. Feedback.openFeedbackWindow();
  580. resolve();
  581. } else { // Otherwise we'll wait for user's feedback.
  582. Feedback.openFeedbackWindow(resolve);
  583. }
  584. } else {
  585. // If the feedback functionality isn't enabled we show a thank you
  586. // dialog.
  587. messageHandler.openMessageDialog(
  588. null, null, null,
  589. APP.translation.translateString(
  590. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  591. )
  592. );
  593. resolve();
  594. }
  595. });
  596. };
  597. UI.requestRecordingToken = function () {
  598. let msg = APP.translation.generateTranslationHTML("dialog.recordingToken");
  599. let token = APP.translation.translateString("dialog.token");
  600. return new Promise(function (resolve, reject) {
  601. messageHandler.openTwoButtonDialog(
  602. null, null, null,
  603. `<h2>${msg}</h2>
  604. <input name="recordingToken" type="text"
  605. data-i18n="[placeholder]dialog.token"
  606. placeholder="${token}" autofocus>`,
  607. false, "dialog.Save",
  608. function (e, v, m, f) {
  609. if (v && f.recordingToken) {
  610. resolve(UIUtil.escapeHtml(f.recordingToken));
  611. } else {
  612. reject();
  613. }
  614. },
  615. null,
  616. function () { },
  617. ':input:first'
  618. );
  619. });
  620. };
  621. UI.updateRecordingState = function (state) {
  622. Toolbar.updateRecordingState(state);
  623. };
  624. module.exports = UI;