Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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