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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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 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 Feedback = require("./Feedback");
  28. var eventEmitter = new EventEmitter();
  29. UI.eventEmitter = eventEmitter;
  30. function promptDisplayName() {
  31. let nickRequiredMsg = APP.translation.translateString("dialog.displayNameRequired");
  32. let defaultNickMsg = APP.translation.translateString(
  33. "defaultNickname", {name: "Jane Pink"}
  34. );
  35. let message = `
  36. <h2 data-i18n="dialog.displayNameRequired">${nickRequiredMsg}</h2>
  37. <input name="displayName" type="text"
  38. data-i18n="[placeholder]defaultNickname"
  39. placeholder="${defaultNickMsg}" autofocus>`;
  40. let buttonTxt = APP.translation.generateTranslationHTML("dialog.Ok");
  41. let buttons = [{title: buttonTxt, value: "ok"}];
  42. messageHandler.openDialog(
  43. null, message,
  44. true,
  45. buttons,
  46. function (e, v, m, f) {
  47. if (v == "ok") {
  48. let displayName = f.displayName;
  49. if (displayName) {
  50. UI.inputDisplayNameHandler(displayName);
  51. return true;
  52. }
  53. }
  54. e.preventDefault();
  55. },
  56. function () {
  57. let form = $.prompt.getPrompt();
  58. let input = form.find("input[name='displayName']");
  59. input.focus();
  60. let button = form.find("button");
  61. button.attr("disabled", "disabled");
  62. input.keyup(function () {
  63. if (input.val()) {
  64. button.removeAttr("disabled");
  65. } else {
  66. button.attr("disabled", "disabled");
  67. }
  68. });
  69. }
  70. );
  71. }
  72. function setupPrezi() {
  73. $("#reloadPresentationLink").click(function() {
  74. Prezi.reloadPresentation();
  75. });
  76. }
  77. function setupChat() {
  78. Chat.init(eventEmitter);
  79. $("#toggle_smileys").click(function() {
  80. Chat.toggleSmileys();
  81. });
  82. }
  83. function setupToolbars() {
  84. Toolbar.init(eventEmitter);
  85. Toolbar.setupButtonsFromConfig();
  86. BottomToolbar.init(eventEmitter);
  87. }
  88. /**
  89. * Toggles the application in and out of full screen mode
  90. * (a.k.a. presentation mode in Chrome).
  91. */
  92. function toggleFullScreen () {
  93. let fsElement = document.documentElement;
  94. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  95. //Enter Full Screen
  96. if (fsElement.mozRequestFullScreen) {
  97. fsElement.mozRequestFullScreen();
  98. } else {
  99. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  100. }
  101. } else {
  102. //Exit Full Screen
  103. if (document.mozCancelFullScreen) {
  104. document.mozCancelFullScreen();
  105. } else {
  106. document.webkitCancelFullScreen();
  107. }
  108. }
  109. }
  110. UI.notifyGracefulShudown = function () {
  111. messageHandler.openMessageDialog(
  112. 'dialog.serviceUnavailable',
  113. 'dialog.gracefulShutdown'
  114. );
  115. };
  116. UI.notifyReservationError = function (code, msg) {
  117. var title = APP.translation.generateTranslationHTML(
  118. "dialog.reservationError");
  119. var message = APP.translation.generateTranslationHTML(
  120. "dialog.reservationErrorMsg", {code: code, msg: msg});
  121. messageHandler.openDialog(
  122. title,
  123. message,
  124. true, {},
  125. function (event, value, message, formVals) {
  126. return false;
  127. }
  128. );
  129. };
  130. UI.notifyKicked = function () {
  131. messageHandler.openMessageDialog("dialog.sessTerminated", "dialog.kickMessage");
  132. };
  133. UI.notifyBridgeDown = function () {
  134. messageHandler.showError("dialog.error", "dialog.bridgeUnavailable");
  135. };
  136. UI.changeDisplayName = function (id, displayName) {
  137. ContactList.onDisplayNameChange(id, displayName);
  138. SettingsMenu.onDisplayNameChange(id, displayName);
  139. VideoLayout.onDisplayNameChanged(id, displayName);
  140. if (APP.conference.isLocalId(id)) {
  141. Chat.setChatConversationMode(!!displayName);
  142. }
  143. };
  144. UI.initConference = function () {
  145. var id = APP.conference.localId;
  146. Toolbar.updateRoomUrl(window.location.href);
  147. var meHTML = APP.translation.generateTranslationHTML("me");
  148. var settings = Settings.getSettings();
  149. $("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
  150. // Make sure we configure our avatar id, before creating avatar for us
  151. UI.setUserAvatar(id, settings.email || settings.uid);
  152. // Add myself to the contact list.
  153. ContactList.addContact(id);
  154. // Once we've joined the muc show the toolbar
  155. ToolbarToggler.showToolbar();
  156. var displayName = config.displayJids ? id : settings.displayName;
  157. if (displayName) {
  158. UI.changeDisplayName('localVideoContainer', displayName);
  159. }
  160. VideoLayout.mucJoined();
  161. Toolbar.checkAutoEnableDesktopSharing();
  162. };
  163. function registerListeners() {
  164. UI.addListener(UIEvents.LARGEVIDEO_INIT, function () {
  165. AudioLevels.init();
  166. });
  167. UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
  168. UI.setUserAvatar(APP.conference.localId, email);
  169. });
  170. UI.addListener(UIEvents.PREZI_CLICKED, function () {
  171. Prezi.openPreziDialog();
  172. });
  173. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  174. Etherpad.toggleEtherpad(0);
  175. });
  176. UI.addListener(UIEvents.FULLSCREEN_TOGGLE, toggleFullScreen);
  177. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  178. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  179. PanelToggler.toggleSettingsMenu();
  180. });
  181. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  182. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.toggleFilmStrip);
  183. }
  184. function bindEvents() {
  185. function onResize() {
  186. PanelToggler.resizeChat();
  187. VideoLayout.resizeLargeVideoContainer();
  188. }
  189. // Resize and reposition videos in full screen mode.
  190. $(document).on(
  191. 'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
  192. );
  193. $(window).resize(onResize);
  194. }
  195. UI.start = function () {
  196. document.title = interfaceConfig.APP_NAME;
  197. var setupWelcomePage = null;
  198. if(config.enableWelcomePage && window.location.pathname == "/" &&
  199. (!window.localStorage.welcomePageDisabled ||
  200. window.localStorage.welcomePageDisabled == "false")) {
  201. $("#videoconference_page").hide();
  202. if (!setupWelcomePage)
  203. setupWelcomePage = require("./welcome_page/WelcomePage");
  204. setupWelcomePage();
  205. return;
  206. }
  207. $("#welcome_page").hide();
  208. // Set the defaults for prompt dialogs.
  209. $.prompt.setDefaults({persistent: false});
  210. registerListeners();
  211. VideoLayout.init(eventEmitter);
  212. ContactList.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. ContactList.addContact(id);
  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(id, displayName);
  308. // Add Peer's container
  309. VideoLayout.addParticipantContainer(id);
  310. };
  311. UI.removeUser = function (id, displayName) {
  312. ContactList.removeContact(id);
  313. messageHandler.notify(
  314. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  315. );
  316. if (!config.startAudioMuted || config.startAudioMuted > APP.conference.membersCount) {
  317. UIUtil.playSoundNotification('userLeft');
  318. }
  319. VideoLayout.removeParticipantContainer(id);
  320. };
  321. function onMucPresenceStatus(jid, info) {
  322. VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
  323. }
  324. function onPeerVideoTypeChanged(resourceJid, newVideoType) {
  325. VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
  326. }
  327. UI.updateLocalRole = function (isModerator) {
  328. VideoLayout.showModeratorIndicator();
  329. Toolbar.showSipCallButton(isModerator);
  330. Toolbar.showRecordingButton(isModerator);
  331. SettingsMenu.onRoleChanged();
  332. if (isModerator) {
  333. messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
  334. Toolbar.checkAutoRecord();
  335. }
  336. };
  337. UI.updateUserRole = function (user) {
  338. VideoLayout.showModeratorIndicator();
  339. if (!user.isModerator()) {
  340. return;
  341. }
  342. var displayName = user.getDisplayName();
  343. if (displayName) {
  344. messageHandler.notify(
  345. displayName, 'notify.somebody',
  346. 'connected', 'notify.grantedTo', {
  347. to: displayName
  348. }
  349. );
  350. } else {
  351. messageHandler.notify(
  352. '', 'notify.somebody',
  353. 'connected', 'notify.grantedToUnknown', {}
  354. );
  355. }
  356. };
  357. UI.toggleSmileys = function () {
  358. Chat.toggleSmileys();
  359. };
  360. UI.getSettings = function () {
  361. return Settings.getSettings();
  362. };
  363. UI.toggleFilmStrip = function () {
  364. BottomToolbar.toggleFilmStrip();
  365. VideoLayout.updateLargeVideoSize();
  366. };
  367. UI.toggleChat = function () {
  368. PanelToggler.toggleChat();
  369. };
  370. UI.toggleContactList = function () {
  371. PanelToggler.toggleContactList();
  372. };
  373. UI.inputDisplayNameHandler = function (value) {
  374. VideoLayout.inputDisplayNameHandler(value);
  375. };
  376. /**
  377. * Return the type of the remote video.
  378. * @param jid the jid for the remote video
  379. * @returns the video type video or screen.
  380. */
  381. UI.getRemoteVideoType = function (jid) {
  382. return VideoLayout.getRemoteVideoType(jid);
  383. };
  384. UI.connectionIndicatorShowMore = function(jid) {
  385. return VideoLayout.showMore(jid);
  386. };
  387. UI.showLoginPopup = function(callback) {
  388. console.log('password is required');
  389. var message = '<h2 data-i18n="dialog.passwordRequired">';
  390. message += APP.translation.translateString(
  391. "dialog.passwordRequired");
  392. message += '</h2>' +
  393. '<input name="username" type="text" ' +
  394. 'placeholder="user@domain.net" autofocus>' +
  395. '<input name="password" ' +
  396. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  397. ' placeholder="user password">';
  398. UI.messageHandler.openTwoButtonDialog(null, null, null, message,
  399. true,
  400. "dialog.Ok",
  401. function (e, v, m, f) {
  402. if (v) {
  403. if (f.username && f.password) {
  404. callback(f.username, f.password);
  405. }
  406. }
  407. },
  408. null, null, ':input:first'
  409. );
  410. };
  411. UI.askForNickname = function () {
  412. return window.prompt('Your nickname (optional)');
  413. };
  414. /**
  415. * Sets muted audio state for the local participant.
  416. */
  417. UI.setAudioMuted = function (mute) {
  418. VideoLayout.showLocalAudioIndicator(mute);
  419. UIUtil.buttonClick("#toolbar_button_mute", "icon-microphone icon-mic-disabled");
  420. };
  421. UI.setVideoMuted = function (muted) {
  422. $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
  423. };
  424. UI.addListener = function (type, listener) {
  425. eventEmitter.on(type, listener);
  426. };
  427. UI.clickOnVideo = function (videoNumber) {
  428. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  429. if (remoteVideos.length > videoNumber) {
  430. remoteVideos[videoNumber].click();
  431. }
  432. };
  433. //Used by torture
  434. UI.showToolbar = function () {
  435. return ToolbarToggler.showToolbar();
  436. };
  437. //Used by torture
  438. UI.dockToolbar = function (isDock) {
  439. ToolbarToggler.dockToolbar(isDock);
  440. };
  441. UI.setUserAvatar = function (id, email) {
  442. // update avatar
  443. Avatar.setUserAvatar(id, email);
  444. var thumbUrl = Avatar.getThumbUrl(id);
  445. var contactListUrl = Avatar.getContactListUrl(id);
  446. VideoLayout.changeUserAvatar(id, thumbUrl);
  447. ContactList.changeUserAvatar(id, contactListUrl);
  448. if (APP.conference.isLocalId(id)) {
  449. SettingsMenu.changeAvatar(thumbUrl);
  450. }
  451. };
  452. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  453. var title = APP.translation.generateTranslationHTML(
  454. "dialog.error");
  455. var message;
  456. if (stropheErrorMsg) {
  457. message = APP.translation.generateTranslationHTML(
  458. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  459. } else {
  460. message = APP.translation.generateTranslationHTML(
  461. "dialog.connectError");
  462. }
  463. messageHandler.openDialog(
  464. title, message, true, {}, function (e, v, m, f) { return false; }
  465. );
  466. };
  467. UI.notifyFirefoxExtensionRequired = function (url) {
  468. messageHandler.openMessageDialog(
  469. "dialog.extensionRequired",
  470. null,
  471. null,
  472. APP.translation.generateTranslationHTML(
  473. "dialog.firefoxExtensionPrompt", {url: url}
  474. )
  475. );
  476. };
  477. UI.notifyInitiallyMuted = function () {
  478. messageHandler.notify(
  479. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  480. );
  481. };
  482. UI.markDominantSpiker = function (id) {
  483. VideoLayout.onDominantSpeakerChanged(id);
  484. };
  485. UI.handleLastNEndpoints = function (ids) {
  486. VideoLayout.onLastNEndpointsChanged(ids, []);
  487. };
  488. UI.setAudioLevel = function (id, lvl) {
  489. AudioLevels.updateAudioLevel(
  490. id, lvl, VideoLayout.getLargeVideoId()
  491. );
  492. };
  493. UI.updateDesktopSharingButtons = function () {
  494. Toolbar.changeDesktopSharingButtonState();
  495. };
  496. UI.hideStats = function () {
  497. VideoLayout.hideStats();
  498. };
  499. UI.updateLocalStats = function (percent, stats) {
  500. VideoLayout.updateLocalConnectionStats(percent, stats);
  501. };
  502. UI.updateRemoteStats = function (jid, percent, stats) {
  503. VideoLayout.updateConnectionStats(jid, percent, stats);
  504. };
  505. UI.showAuthenticateButton = function (show) {
  506. Toolbar.showAuthenticateButton(show);
  507. };
  508. UI.markVideoInterrupted = function (interrupted) {
  509. if (interrupted) {
  510. VideoLayout.onVideoInterrupted();
  511. } else {
  512. VideoLayout.onVideoRestored();
  513. }
  514. };
  515. UI.markRoomLocked = function (locked) {
  516. if (locked) {
  517. Toolbar.lockLockButton();
  518. } else {
  519. Toolbar.unlockLockButton();
  520. }
  521. };
  522. UI.addMessage = function (from, displayName, message, stamp) {
  523. Chat.updateChatConversation(from, displayName, message, stamp);
  524. };
  525. UI.updateDTMFSupport = function (isDTMFSupported) {
  526. //TODO: enable when the UI is ready
  527. //Toolbar.showDialPadButton(dtmfSupport);
  528. };
  529. /**
  530. * Invite participants to conference.
  531. */
  532. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  533. let keyText = "";
  534. if (key) {
  535. keyText = APP.translation.translateString(
  536. "email.sharedKey", {sharedKey: key}
  537. );
  538. }
  539. let and = APP.translation.translateString("email.and");
  540. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  541. let subject = APP.translation.translateString(
  542. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  543. );
  544. let body = APP.translation.translateString(
  545. "email.body", {
  546. appName:interfaceConfig.APP_NAME,
  547. sharedKeyText: keyText,
  548. roomUrl,
  549. supportedBrowsers
  550. }
  551. );
  552. body = body.replace(/\n/g, "%0D%0A");
  553. if (nick) {
  554. body += "%0D%0A%0D%0A" + nick;
  555. }
  556. if (interfaceConfig.INVITATION_POWERED_BY) {
  557. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  558. }
  559. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  560. };
  561. UI.requestFeedback = function () {
  562. return new Promise(function (resolve, reject) {
  563. if (Feedback.isEnabled()) {
  564. // If the user has already entered feedback, we'll show the window and
  565. // immidiately start the conference dispose timeout.
  566. if (Feedback.feedbackScore > 0) {
  567. Feedback.openFeedbackWindow();
  568. resolve();
  569. } else { // Otherwise we'll wait for user's feedback.
  570. Feedback.openFeedbackWindow(resolve);
  571. }
  572. } else {
  573. // If the feedback functionality isn't enabled we show a thank you
  574. // dialog.
  575. messageHandler.openMessageDialog(
  576. null, null, null,
  577. APP.translation.translateString(
  578. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  579. )
  580. );
  581. resolve();
  582. }
  583. });
  584. };
  585. UI.requestRecordingToken = function () {
  586. let msg = APP.translation.generateTranslationHTML("dialog.recordingToken");
  587. let token = APP.translation.translateString("dialog.token");
  588. return new Promise(function (resolve, reject) {
  589. messageHandler.openTwoButtonDialog(
  590. null, null, null,
  591. `<h2>${msg}</h2>
  592. <input name="recordingToken" type="text"
  593. data-i18n="[placeholder]dialog.token"
  594. placeholder="${token}" autofocus>`,
  595. false, "dialog.Save",
  596. function (e, v, m, f) {
  597. if (v && f.recordingToken) {
  598. resolve(UIUtil.escapeHtml(f.recordingToken));
  599. } else {
  600. reject();
  601. }
  602. },
  603. null,
  604. function () { },
  605. ':input:first'
  606. );
  607. });
  608. };
  609. UI.updateRecordingState = function (state) {
  610. Toolbar.updateRecordingState(state);
  611. };
  612. module.exports = UI;