您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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.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. Chat.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. function chatSetSubject(text) {
  293. return Chat.chatSetSubject(text);
  294. }
  295. function initEtherpad(name) {
  296. Etherpad.init(name);
  297. }
  298. UI.addUser = function (jid, 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(jid, id);
  307. // Add Peer's container
  308. VideoLayout.ensurePeerContainerExists(jid);
  309. };
  310. UI.removeUser = function (jid) {
  311. console.log('left.muc', jid);
  312. var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
  313. '>.displayname').html();
  314. messageHandler.notify(displayName,'notify.somebody',
  315. 'disconnected',
  316. 'notify.disconnected');
  317. if (!config.startAudioMuted ||
  318. config.startAudioMuted > APP.conference.membersCount) {
  319. UIUtil.playSoundNotification('userLeft');
  320. }
  321. ContactList.removeContact(jid);
  322. VideoLayout.participantLeft(jid);
  323. };
  324. function onMucPresenceStatus(jid, info) {
  325. VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
  326. }
  327. function onPeerVideoTypeChanged(resourceJid, newVideoType) {
  328. VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
  329. }
  330. UI.updateLocalRole = function (isModerator) {
  331. VideoLayout.showModeratorIndicator();
  332. Toolbar.showSipCallButton(isModerator);
  333. Toolbar.showRecordingButton(isModerator);
  334. SettingsMenu.onRoleChanged();
  335. if (isModerator) {
  336. Authentication.closeAuthenticationWindow();
  337. messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
  338. Toolbar.checkAutoRecord();
  339. }
  340. };
  341. UI.updateUserRole = function (user) {
  342. VideoLayout.showModeratorIndicator();
  343. if (!user.isModerator()) {
  344. return;
  345. }
  346. var displayName = user.getDisplayName();
  347. if (displayName) {
  348. messageHandler.notify(
  349. displayName, 'notify.somebody',
  350. 'connected', 'notify.grantedTo', {
  351. to: displayName
  352. }
  353. );
  354. } else {
  355. messageHandler.notify(
  356. '', 'notify.somebody',
  357. 'connected', 'notify.grantedToUnknown', {}
  358. );
  359. }
  360. };
  361. UI.notifyAuthRequired = function (intervalCallback) {
  362. Authentication.openAuthenticationDialog(APP.conference.roomName, intervalCallback);
  363. };
  364. UI.toggleSmileys = function () {
  365. Chat.toggleSmileys();
  366. };
  367. UI.getSettings = function () {
  368. return Settings.getSettings();
  369. };
  370. UI.toggleFilmStrip = function () {
  371. BottomToolbar.toggleFilmStrip();
  372. VideoLayout.updateLargeVideoSize();
  373. };
  374. UI.toggleChat = function () {
  375. PanelToggler.toggleChat();
  376. };
  377. UI.toggleContactList = function () {
  378. PanelToggler.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;