Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UI.js 21KB

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