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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461
  1. /* global APP, JitsiMeetJS, $, 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 EtherpadManager from './etherpad/Etherpad';
  15. import SharedVideoManager from './shared_video/SharedVideo';
  16. import Recording from "./recording/Recording";
  17. import GumPermissionsOverlay from './gum_overlay/UserMediaPermissionsGuidanceOverlay';
  18. import VideoLayout from "./videolayout/VideoLayout";
  19. import FilmStrip from "./videolayout/FilmStrip";
  20. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  21. import Settings from "./../settings/Settings";
  22. import { reload } from '../util/helpers';
  23. import RingOverlay from "./ring_overlay/RingOverlay";
  24. var EventEmitter = require("events");
  25. UI.messageHandler = require("./util/MessageHandler");
  26. var messageHandler = UI.messageHandler;
  27. var JitsiPopover = require("./util/JitsiPopover");
  28. var Feedback = require("./Feedback");
  29. import FollowMe from "../FollowMe";
  30. var eventEmitter = new EventEmitter();
  31. UI.eventEmitter = eventEmitter;
  32. let etherpadManager;
  33. let sharedVideoManager;
  34. let followMeHandler;
  35. let deviceErrorDialog;
  36. const TrackErrors = JitsiMeetJS.errors.track;
  37. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  38. microphone: {},
  39. camera: {}
  40. };
  41. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  42. = "dialog.cameraUnsupportedResolutionError";
  43. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  44. = "dialog.cameraUnknownError";
  45. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  46. = "dialog.cameraPermissionDeniedError";
  47. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  48. = "dialog.cameraNotFoundError";
  49. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  50. = "dialog.cameraConstraintFailedError";
  51. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  52. = "dialog.micUnknownError";
  53. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  54. = "dialog.micPermissionDeniedError";
  55. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  56. = "dialog.micNotFoundError";
  57. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  58. = "dialog.micConstraintFailedError";
  59. /**
  60. * Prompt user for nickname.
  61. */
  62. function promptDisplayName() {
  63. let nickRequiredMsg
  64. = APP.translation.translateString("dialog.displayNameRequired");
  65. let defaultNickMsg = APP.translation.translateString("defaultNickname");
  66. let message = `
  67. <h2 data-i18n="dialog.displayNameRequired">${nickRequiredMsg}</h2>
  68. <input name="displayName" type="text"
  69. data-i18n="[placeholder]defaultNickname"
  70. placeholder="${defaultNickMsg}" autofocus>`;
  71. // Don't use a translation string, because we're too early in the call and
  72. // the translation may not be initialised.
  73. let buttons = {Ok:true};
  74. let dialog = messageHandler.openDialog(
  75. null,
  76. message,
  77. true,
  78. buttons,
  79. function (e, v, m, f) {
  80. e.preventDefault();
  81. if (v) {
  82. let displayName = f.displayName;
  83. if (displayName) {
  84. UI.inputDisplayNameHandler(displayName);
  85. dialog.close();
  86. return;
  87. }
  88. }
  89. },
  90. function () {
  91. let form = $.prompt.getPrompt();
  92. let input = form.find("input[name='displayName']");
  93. input.focus();
  94. let button = form.find("button");
  95. button.attr("disabled", "disabled");
  96. input.keyup(function () {
  97. if (input.val()) {
  98. button.removeAttr("disabled");
  99. } else {
  100. button.attr("disabled", "disabled");
  101. }
  102. });
  103. }
  104. );
  105. }
  106. /**
  107. * Initialize chat.
  108. */
  109. function setupChat() {
  110. Chat.init(eventEmitter);
  111. $("#toggle_smileys").click(function() {
  112. Chat.toggleSmileys();
  113. });
  114. }
  115. /**
  116. * Initialize toolbars.
  117. */
  118. function setupToolbars() {
  119. Toolbar.init(eventEmitter);
  120. BottomToolbar.setupListeners(eventEmitter);
  121. }
  122. /**
  123. * Toggles the application in and out of full screen mode
  124. * (a.k.a. presentation mode in Chrome).
  125. * @see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
  126. */
  127. function toggleFullScreen () {
  128. // alternative standard method
  129. let isNotFullScreen = !document.fullscreenElement &&
  130. !document.mozFullScreenElement && // current working methods
  131. !document.webkitFullscreenElement &&
  132. !document.msFullscreenElement;
  133. if (isNotFullScreen) {
  134. if (document.documentElement.requestFullscreen) {
  135. document.documentElement.requestFullscreen();
  136. } else if (document.documentElement.msRequestFullscreen) {
  137. document.documentElement.msRequestFullscreen();
  138. } else if (document.documentElement.mozRequestFullScreen) {
  139. document.documentElement.mozRequestFullScreen();
  140. } else if (document.documentElement.webkitRequestFullscreen) {
  141. document.documentElement
  142. .webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  143. }
  144. } else {
  145. if (document.exitFullscreen) {
  146. document.exitFullscreen();
  147. } else if (document.msExitFullscreen) {
  148. document.msExitFullscreen();
  149. } else if (document.mozCancelFullScreen) {
  150. document.mozCancelFullScreen();
  151. } else if (document.webkitExitFullscreen) {
  152. document.webkitExitFullscreen();
  153. }
  154. }
  155. }
  156. /**
  157. * Notify user that server has shut down.
  158. */
  159. UI.notifyGracefulShutdown = function () {
  160. messageHandler.openMessageDialog(
  161. 'dialog.serviceUnavailable',
  162. 'dialog.gracefulShutdown'
  163. );
  164. };
  165. /**
  166. * Notify user that reservation error happened.
  167. */
  168. UI.notifyReservationError = function (code, msg) {
  169. var title = APP.translation.generateTranslationHTML(
  170. "dialog.reservationError");
  171. var message = APP.translation.generateTranslationHTML(
  172. "dialog.reservationErrorMsg", {code: code, msg: msg});
  173. messageHandler.openDialog(
  174. title,
  175. message,
  176. true, {},
  177. function (event, value, message, formVals) {
  178. return false;
  179. }
  180. );
  181. };
  182. /**
  183. * Notify user that he has been kicked from the server.
  184. */
  185. UI.notifyKicked = function () {
  186. messageHandler.openMessageDialog("dialog.sessTerminated", "dialog.kickMessage");
  187. };
  188. /**
  189. * Notify user that conference was destroyed.
  190. * @param reason {string} the reason text
  191. */
  192. UI.notifyConferenceDestroyed = function (reason) {
  193. //FIXME: use Session Terminated from translation, but
  194. // 'reason' text comes from XMPP packet and is not translated
  195. var title = APP.translation.generateTranslationHTML("dialog.sessTerminated");
  196. messageHandler.openDialog(
  197. title, reason, true, {},
  198. function (event, value, message, formVals) {
  199. return false;
  200. }
  201. );
  202. };
  203. /**
  204. * Notify user that Jitsi Videobridge is not accessible.
  205. */
  206. UI.notifyBridgeDown = function () {
  207. messageHandler.showError("dialog.error", "dialog.bridgeUnavailable");
  208. };
  209. /**
  210. * Show chat error.
  211. * @param err the Error
  212. * @param msg
  213. */
  214. UI.showChatError = function (err, msg) {
  215. if (interfaceConfig.filmStripOnly) {
  216. return;
  217. }
  218. Chat.chatAddError(err, msg);
  219. };
  220. /**
  221. * Change nickname for the user.
  222. * @param {string} id user id
  223. * @param {string} displayName new nickname
  224. */
  225. UI.changeDisplayName = function (id, displayName) {
  226. ContactList.onDisplayNameChange(id, displayName);
  227. VideoLayout.onDisplayNameChanged(id, displayName);
  228. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  229. SettingsMenu.changeDisplayName(displayName);
  230. Chat.setChatConversationMode(!!displayName);
  231. }
  232. };
  233. /**
  234. * Sets the "raised hand" status for a participant.
  235. */
  236. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  237. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  238. if (raisedHandStatus) {
  239. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  240. 'connected', 'notify.raisedHand');
  241. }
  242. };
  243. /**
  244. * Sets the local "raised hand" status.
  245. */
  246. UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
  247. VideoLayout.setRaisedHandStatus(APP.conference.getMyUserId(), raisedHandStatus);
  248. };
  249. /**
  250. * Initialize conference UI.
  251. */
  252. UI.initConference = function () {
  253. let id = APP.conference.getMyUserId();
  254. // Do not include query parameters in the invite URL
  255. // "https://example.com" + "/SomeConference1245"
  256. var inviteURL = window.location.origin + window.location.pathname;
  257. Toolbar.updateRoomUrl(inviteURL);
  258. // Clean up the URL displayed by the browser
  259. if (window.history && typeof window.history.replaceState === 'function') {
  260. window.history.replaceState({}, document.title, inviteURL);
  261. }
  262. // Add myself to the contact list.
  263. ContactList.addContact(id);
  264. //update default button states before showing the toolbar
  265. //if local role changes buttons state will be again updated
  266. UI.updateLocalRole(false);
  267. // Once we've joined the muc show the toolbar
  268. if (!RingOverlay.isDisplayed()) {
  269. ToolbarToggler.showToolbar();
  270. }
  271. let displayName = config.displayJids ? id : Settings.getDisplayName();
  272. if (displayName) {
  273. UI.changeDisplayName('localVideoContainer', displayName);
  274. }
  275. // Make sure we configure our avatar id, before creating avatar for us
  276. UI.setUserEmail(id, Settings.getEmail());
  277. Toolbar.checkAutoEnableDesktopSharing();
  278. if(!interfaceConfig.filmStripOnly) {
  279. Feedback.init(eventEmitter);
  280. }
  281. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  282. // other participants' UI. Consequently, it needs (1) read and write access
  283. // to the UI (depending on the moderator role of the local participant) and
  284. // (2) APP.conference as means of communication between the participants.
  285. followMeHandler = new FollowMe(APP.conference, UI);
  286. };
  287. UI.mucJoined = function () {
  288. VideoLayout.mucJoined();
  289. };
  290. /**
  291. * Setup some UI event listeners.
  292. */
  293. function registerListeners() {
  294. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  295. if (etherpadManager) {
  296. etherpadManager.toggleEtherpad();
  297. }
  298. });
  299. UI.addListener(UIEvents.SHARED_VIDEO_CLICKED, function () {
  300. if (sharedVideoManager) {
  301. sharedVideoManager.toggleSharedVideo();
  302. }
  303. });
  304. UI.addListener(UIEvents.FULLSCREEN_TOGGLE, toggleFullScreen);
  305. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  306. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  307. PanelToggler.toggleSettingsMenu();
  308. });
  309. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  310. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, function () {
  311. UI.toggleFilmStrip();
  312. VideoLayout.resizeVideoArea(PanelToggler.isVisible(), true, false);
  313. });
  314. UI.addListener(UIEvents.FOLLOW_ME_ENABLED, function (isEnabled) {
  315. if (followMeHandler)
  316. followMeHandler.enableFollowMe(isEnabled);
  317. });
  318. }
  319. /**
  320. * Setup some DOM event listeners.
  321. */
  322. function bindEvents() {
  323. function onResize() {
  324. PanelToggler.resizeChat();
  325. VideoLayout.resizeVideoArea(PanelToggler.isVisible());
  326. }
  327. // Resize and reposition videos in full screen mode.
  328. $(document).on(
  329. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  330. onResize
  331. );
  332. $(window).resize(onResize);
  333. }
  334. /**
  335. * Returns the shared document manager object.
  336. * @return {EtherpadManager} the shared document manager object
  337. */
  338. UI.getSharedVideoManager = function () {
  339. return sharedVideoManager;
  340. };
  341. /**
  342. * Starts the UI module and initializes all related components.
  343. *
  344. * @returns {boolean} true if the UI is ready and the conference should be
  345. * esablished, false - otherwise (for example in the case of welcome page)
  346. */
  347. UI.start = function () {
  348. document.title = interfaceConfig.APP_NAME;
  349. var setupWelcomePage = null;
  350. if(config.enableWelcomePage && window.location.pathname == "/" &&
  351. Settings.isWelcomePageEnabled()) {
  352. $("#videoconference_page").hide();
  353. if (!setupWelcomePage)
  354. setupWelcomePage = require("./welcome_page/WelcomePage");
  355. setupWelcomePage();
  356. // Return false to indicate that the UI hasn't been fully started and
  357. // conference ready. We're still waiting for input from the user.
  358. return false;
  359. }
  360. $("#welcome_page").hide();
  361. // Set the defaults for prompt dialogs.
  362. $.prompt.setDefaults({persistent: false});
  363. registerListeners();
  364. ToolbarToggler.init();
  365. BottomToolbar.init();
  366. FilmStrip.init(eventEmitter);
  367. VideoLayout.init(eventEmitter);
  368. if (!interfaceConfig.filmStripOnly) {
  369. VideoLayout.initLargeVideo(PanelToggler.isVisible());
  370. }
  371. VideoLayout.resizeVideoArea(PanelToggler.isVisible(), true, true);
  372. ContactList.init(eventEmitter);
  373. bindEvents();
  374. sharedVideoManager = new SharedVideoManager(eventEmitter);
  375. if (!interfaceConfig.filmStripOnly) {
  376. $("#videospace").mousemove(function () {
  377. return ToolbarToggler.showToolbar();
  378. });
  379. setupToolbars();
  380. setupChat();
  381. // Initialise the recording module.
  382. if (config.enableRecording)
  383. Recording.init(eventEmitter, config.recordingType);
  384. // Display notice message at the top of the toolbar
  385. if (config.noticeMessage) {
  386. $('#noticeText').text(config.noticeMessage);
  387. $('#notice').css({display: 'block'});
  388. }
  389. $("#downloadlog").click(function (event) {
  390. let logs = APP.conference.getLogs();
  391. let data = encodeURIComponent(JSON.stringify(logs, null, ' '));
  392. let elem = event.target.parentNode;
  393. elem.download = 'meetlog.json';
  394. elem.href = 'data:application/json;charset=utf-8,\n' + data;
  395. });
  396. } else {
  397. $("#header").css("display", "none");
  398. $("#downloadlog").css("display", "none");
  399. BottomToolbar.hide();
  400. FilmStrip.setupFilmStripOnly();
  401. messageHandler.enableNotifications(false);
  402. $('body').popover("disable");
  403. JitsiPopover.enabled = false;
  404. }
  405. document.title = interfaceConfig.APP_NAME;
  406. if(config.requireDisplayName) {
  407. if (!APP.settings.getDisplayName()) {
  408. promptDisplayName();
  409. }
  410. }
  411. if (!interfaceConfig.filmStripOnly) {
  412. toastr.options = {
  413. "closeButton": true,
  414. "debug": false,
  415. "positionClass": "notification-bottom-right",
  416. "onclick": null,
  417. "showDuration": "300",
  418. "hideDuration": "1000",
  419. "timeOut": "2000",
  420. "extendedTimeOut": "1000",
  421. "showEasing": "swing",
  422. "hideEasing": "linear",
  423. "showMethod": "fadeIn",
  424. "hideMethod": "fadeOut",
  425. "reposition": function () {
  426. if (PanelToggler.isVisible()) {
  427. $("#toast-container").addClass("notification-bottom-right-center");
  428. } else {
  429. $("#toast-container").removeClass("notification-bottom-right-center");
  430. }
  431. },
  432. "newestOnTop": false
  433. };
  434. SettingsMenu.init(eventEmitter);
  435. }
  436. if(APP.tokenData.callee) {
  437. UI.showRingOverLay();
  438. }
  439. // Return true to indicate that the UI has been fully started and
  440. // conference ready.
  441. return true;
  442. };
  443. /**
  444. * Show local stream on UI.
  445. * @param {JitsiTrack} track stream to show
  446. */
  447. UI.addLocalStream = function (track) {
  448. switch (track.getType()) {
  449. case 'audio':
  450. VideoLayout.changeLocalAudio(track);
  451. break;
  452. case 'video':
  453. VideoLayout.changeLocalVideo(track);
  454. break;
  455. default:
  456. console.error("Unknown stream type: " + track.getType());
  457. break;
  458. }
  459. };
  460. /**
  461. * Show remote stream on UI.
  462. * @param {JitsiTrack} track stream to show
  463. */
  464. UI.addRemoteStream = function (track) {
  465. VideoLayout.onRemoteStreamAdded(track);
  466. };
  467. /**
  468. * Removed remote stream from UI.
  469. * @param {JitsiTrack} track stream to remove
  470. */
  471. UI.removeRemoteStream = function (track) {
  472. VideoLayout.onRemoteStreamRemoved(track);
  473. };
  474. function chatAddError(errorMessage, originalText) {
  475. return Chat.chatAddError(errorMessage, originalText);
  476. }
  477. /**
  478. * Update chat subject.
  479. * @param {string} subject new chat subject
  480. */
  481. UI.setSubject = function (subject) {
  482. Chat.setSubject(subject);
  483. };
  484. /**
  485. * Setup and show Etherpad.
  486. * @param {string} name etherpad id
  487. */
  488. UI.initEtherpad = function (name) {
  489. if (etherpadManager || !config.etherpad_base || !name) {
  490. return;
  491. }
  492. console.log('Etherpad is enabled');
  493. etherpadManager
  494. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  495. Toolbar.showEtherpadButton();
  496. };
  497. /**
  498. * Returns the shared document manager object.
  499. * @return {EtherpadManager} the shared document manager object
  500. */
  501. UI.getSharedDocumentManager = function () {
  502. return etherpadManager;
  503. };
  504. /**
  505. * Show user on UI.
  506. * @param {string} id user id
  507. * @param {string} displayName user nickname
  508. */
  509. UI.addUser = function (id, displayName) {
  510. UI.hideRingOverLay();
  511. ContactList.addContact(id);
  512. messageHandler.notify(
  513. displayName,'notify.somebody', 'connected', 'notify.connected'
  514. );
  515. if (!config.startAudioMuted ||
  516. config.startAudioMuted > APP.conference.membersCount)
  517. UIUtil.playSoundNotification('userJoined');
  518. // Add Peer's container
  519. VideoLayout.addParticipantContainer(id);
  520. // Configure avatar
  521. UI.setUserEmail(id);
  522. // set initial display name
  523. if(displayName)
  524. UI.changeDisplayName(id, displayName);
  525. };
  526. /**
  527. * Remove user from UI.
  528. * @param {string} id user id
  529. * @param {string} displayName user nickname
  530. */
  531. UI.removeUser = function (id, displayName) {
  532. ContactList.removeContact(id);
  533. messageHandler.notify(
  534. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  535. );
  536. if (!config.startAudioMuted
  537. || config.startAudioMuted > APP.conference.membersCount) {
  538. UIUtil.playSoundNotification('userLeft');
  539. }
  540. VideoLayout.removeParticipantContainer(id);
  541. };
  542. UI.updateUserStatus = function (id, status) {
  543. VideoLayout.setPresenceStatus(id, status);
  544. };
  545. /**
  546. * Update videotype for specified user.
  547. * @param {string} id user id
  548. * @param {string} newVideoType new videotype
  549. */
  550. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  551. VideoLayout.onVideoTypeChanged(id, newVideoType);
  552. };
  553. /**
  554. * Update local user role and show notification if user is moderator.
  555. * @param {boolean} isModerator if local user is moderator or not
  556. */
  557. UI.updateLocalRole = function (isModerator) {
  558. VideoLayout.showModeratorIndicator();
  559. Toolbar.showSipCallButton(isModerator);
  560. Toolbar.showSharedVideoButton(isModerator);
  561. Recording.showRecordingButton(isModerator);
  562. SettingsMenu.showStartMutedOptions(isModerator);
  563. SettingsMenu.showFollowMeOptions(isModerator);
  564. if (isModerator) {
  565. messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
  566. Recording.checkAutoRecord();
  567. }
  568. };
  569. /**
  570. * Check the role for the user and reflect it in the UI, moderator ui indication
  571. * and notifies user who is the moderator
  572. * @param user to check for moderator
  573. */
  574. UI.updateUserRole = function (user) {
  575. VideoLayout.showModeratorIndicator();
  576. if (!user.isModerator()) {
  577. return;
  578. }
  579. var displayName = user.getDisplayName();
  580. if (displayName) {
  581. messageHandler.notify(
  582. displayName, 'notify.somebody',
  583. 'connected', 'notify.grantedTo', {
  584. to: UIUtil.escapeHtml(displayName)
  585. }
  586. );
  587. } else {
  588. messageHandler.notify(
  589. '', 'notify.somebody',
  590. 'connected', 'notify.grantedToUnknown', {}
  591. );
  592. }
  593. };
  594. /**
  595. * Toggles smileys in the chat.
  596. */
  597. UI.toggleSmileys = function () {
  598. Chat.toggleSmileys();
  599. };
  600. /**
  601. * Toggles film strip.
  602. */
  603. UI.toggleFilmStrip = function () {
  604. var self = FilmStrip;
  605. self.toggleFilmStrip.apply(self, arguments);
  606. };
  607. /**
  608. * Indicates if the film strip is currently visible or not.
  609. * @returns {true} if the film strip is currently visible, otherwise
  610. */
  611. UI.isFilmStripVisible = function () {
  612. return FilmStrip.isFilmStripVisible();
  613. };
  614. /**
  615. * Toggles chat panel.
  616. */
  617. UI.toggleChat = function () {
  618. PanelToggler.toggleChat();
  619. };
  620. /**
  621. * Toggles contact list panel.
  622. */
  623. UI.toggleContactList = function () {
  624. PanelToggler.toggleContactList();
  625. };
  626. /**
  627. * Handle new user display name.
  628. */
  629. UI.inputDisplayNameHandler = function (newDisplayName) {
  630. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  631. };
  632. /**
  633. * Return the type of the remote video.
  634. * @param jid the jid for the remote video
  635. * @returns the video type video or screen.
  636. */
  637. UI.getRemoteVideoType = function (jid) {
  638. return VideoLayout.getRemoteVideoType(jid);
  639. };
  640. UI.connectionIndicatorShowMore = function(id) {
  641. VideoLayout.showMore(id);
  642. };
  643. // FIXME check if someone user this
  644. UI.showLoginPopup = function(callback) {
  645. console.log('password is required');
  646. var message = '<h2 data-i18n="dialog.passwordRequired">';
  647. message += APP.translation.translateString(
  648. "dialog.passwordRequired");
  649. message += '</h2>' +
  650. '<input name="username" type="text" ' +
  651. 'placeholder="user@domain.net" autofocus>' +
  652. '<input name="password" ' +
  653. 'type="password" data-i18n="[placeholder]dialog.userPassword"' +
  654. ' placeholder="user password">';
  655. messageHandler.openTwoButtonDialog(null, null, null, message,
  656. true,
  657. "dialog.Ok",
  658. function (e, v, m, f) {
  659. if (v) {
  660. if (f.username && f.password) {
  661. callback(f.username, f.password);
  662. }
  663. }
  664. },
  665. null, null, ':input:first'
  666. );
  667. };
  668. UI.askForNickname = function () {
  669. return window.prompt('Your nickname (optional)');
  670. };
  671. /**
  672. * Sets muted audio state for participant
  673. */
  674. UI.setAudioMuted = function (id, muted) {
  675. VideoLayout.onAudioMute(id, muted);
  676. if (APP.conference.isLocalId(id)) {
  677. Toolbar.markAudioIconAsMuted(muted);
  678. }
  679. };
  680. /**
  681. * Sets muted video state for participant
  682. */
  683. UI.setVideoMuted = function (id, muted) {
  684. VideoLayout.onVideoMute(id, muted);
  685. if (APP.conference.isLocalId(id)) {
  686. Toolbar.markVideoIconAsMuted(muted);
  687. }
  688. };
  689. /**
  690. * Adds a listener that would be notified on the given type of event.
  691. *
  692. * @param type the type of the event we're listening for
  693. * @param listener a function that would be called when notified
  694. */
  695. UI.addListener = function (type, listener) {
  696. eventEmitter.on(type, listener);
  697. };
  698. /**
  699. * Removes the given listener for the given type of event.
  700. *
  701. * @param type the type of the event we're listening for
  702. * @param listener the listener we want to remove
  703. */
  704. UI.removeListener = function (type, listener) {
  705. eventEmitter.removeListener(type, listener);
  706. };
  707. UI.clickOnVideo = function (videoNumber) {
  708. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  709. if (remoteVideos.length > videoNumber) {
  710. remoteVideos[videoNumber].click();
  711. }
  712. };
  713. //Used by torture
  714. UI.showToolbar = function () {
  715. return ToolbarToggler.showToolbar();
  716. };
  717. //Used by torture
  718. UI.dockToolbar = function (isDock) {
  719. ToolbarToggler.dockToolbar(isDock);
  720. };
  721. /**
  722. * Updates the avatar for participant.
  723. * @param {string} id user id
  724. * @param {stirng} avatarUrl the URL for the avatar
  725. */
  726. function changeAvatar(id, avatarUrl) {
  727. VideoLayout.changeUserAvatar(id, avatarUrl);
  728. ContactList.changeUserAvatar(id, avatarUrl);
  729. if (APP.conference.isLocalId(id)) {
  730. SettingsMenu.changeAvatar(avatarUrl);
  731. }
  732. }
  733. /**
  734. * Update user email.
  735. * @param {string} id user id
  736. * @param {stirng} email user email
  737. */
  738. UI.setUserEmail = function (id, email) {
  739. // update avatar
  740. Avatar.setUserEmail(id, email);
  741. changeAvatar(id, Avatar.getAvatarUrl(id));
  742. };
  743. /**
  744. * Update user avatar URL.
  745. * @param {string} id user id
  746. * @param {stirng} url user avatar url
  747. */
  748. UI.setUserAvatarUrl = function (id, url) {
  749. // update avatar
  750. Avatar.setUserAvatarUrl(id, url);
  751. changeAvatar(id, Avatar.getAvatarUrl(id));
  752. };
  753. /**
  754. * Notify user that connection failed.
  755. * @param {string} stropheErrorMsg raw Strophe error message
  756. */
  757. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  758. var title = APP.translation.generateTranslationHTML(
  759. "dialog.error");
  760. var message;
  761. if (stropheErrorMsg) {
  762. message = APP.translation.generateTranslationHTML(
  763. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  764. } else {
  765. message = APP.translation.generateTranslationHTML(
  766. "dialog.connectError");
  767. }
  768. messageHandler.openDialog(
  769. title, message, true, {}, function (e, v, m, f) { return false; }
  770. );
  771. };
  772. /**
  773. * Notify user that maximum users limit has been reached.
  774. */
  775. UI.notifyMaxUsersLimitReached = function () {
  776. var title = APP.translation.generateTranslationHTML(
  777. "dialog.error");
  778. var message = APP.translation.generateTranslationHTML(
  779. "dialog.maxUsersLimitReached");
  780. messageHandler.openDialog(
  781. title, message, true, {}, function (e, v, m, f) { return false; }
  782. );
  783. };
  784. /**
  785. * Notify user that he was automatically muted when joned the conference.
  786. */
  787. UI.notifyInitiallyMuted = function () {
  788. messageHandler.notify(
  789. null, "notify.mutedTitle", "connected", "notify.muted", null, {timeOut: 120000}
  790. );
  791. };
  792. /**
  793. * Mark user as dominant speaker.
  794. * @param {string} id user id
  795. */
  796. UI.markDominantSpeaker = function (id) {
  797. VideoLayout.onDominantSpeakerChanged(id);
  798. };
  799. UI.handleLastNEndpoints = function (ids, enteringIds) {
  800. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  801. };
  802. /**
  803. * Update audio level visualization for specified user.
  804. * @param {string} id user id
  805. * @param {number} lvl audio level
  806. */
  807. UI.setAudioLevel = function (id, lvl) {
  808. VideoLayout.setAudioLevel(id, lvl);
  809. };
  810. /**
  811. * Update state of desktop sharing buttons.
  812. */
  813. UI.updateDesktopSharingButtons = function () {
  814. Toolbar.updateDesktopSharingButtonState();
  815. };
  816. /**
  817. * Hide connection quality statistics from UI.
  818. */
  819. UI.hideStats = function () {
  820. VideoLayout.hideStats();
  821. };
  822. /**
  823. * Update local connection quality statistics.
  824. * @param {number} percent
  825. * @param {object} stats
  826. */
  827. UI.updateLocalStats = function (percent, stats) {
  828. VideoLayout.updateLocalConnectionStats(percent, stats);
  829. };
  830. /**
  831. * Update connection quality statistics for remote user.
  832. * @param {string} id user id
  833. * @param {number} percent
  834. * @param {object} stats
  835. */
  836. UI.updateRemoteStats = function (id, percent, stats) {
  837. VideoLayout.updateConnectionStats(id, percent, stats);
  838. };
  839. /**
  840. * Mark video as interrupted or not.
  841. * @param {boolean} interrupted if video is interrupted
  842. */
  843. UI.markVideoInterrupted = function (interrupted) {
  844. if (interrupted) {
  845. VideoLayout.onVideoInterrupted();
  846. } else {
  847. VideoLayout.onVideoRestored();
  848. }
  849. };
  850. /**
  851. * Mark room as locked or not.
  852. * @param {boolean} locked if room is locked.
  853. */
  854. UI.markRoomLocked = function (locked) {
  855. if (locked) {
  856. Toolbar.lockLockButton();
  857. } else {
  858. Toolbar.unlockLockButton();
  859. }
  860. };
  861. /**
  862. * Add chat message.
  863. * @param {string} from user id
  864. * @param {string} displayName user nickname
  865. * @param {string} message message text
  866. * @param {number} stamp timestamp when message was created
  867. */
  868. UI.addMessage = function (from, displayName, message, stamp) {
  869. Chat.updateChatConversation(from, displayName, message, stamp);
  870. };
  871. UI.updateDTMFSupport = function (isDTMFSupported) {
  872. //TODO: enable when the UI is ready
  873. //Toolbar.showDialPadButton(dtmfSupport);
  874. };
  875. /**
  876. * Invite participants to conference.
  877. * @param {string} roomUrl
  878. * @param {string} conferenceName
  879. * @param {string} key
  880. * @param {string} nick
  881. */
  882. UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {
  883. let keyText = "";
  884. if (key) {
  885. keyText = APP.translation.translateString(
  886. "email.sharedKey", {sharedKey: key}
  887. );
  888. }
  889. let and = APP.translation.translateString("email.and");
  890. let supportedBrowsers = `Chromium, Google Chrome ${and} Opera`;
  891. let subject = APP.translation.translateString(
  892. "email.subject", {appName:interfaceConfig.APP_NAME, conferenceName}
  893. );
  894. let body = APP.translation.translateString(
  895. "email.body", {
  896. appName:interfaceConfig.APP_NAME,
  897. sharedKeyText: keyText,
  898. roomUrl,
  899. supportedBrowsers
  900. }
  901. );
  902. body = body.replace(/\n/g, "%0D%0A");
  903. if (nick) {
  904. body += "%0D%0A%0D%0A" + UIUtil.escapeHtml(nick);
  905. }
  906. if (interfaceConfig.INVITATION_POWERED_BY) {
  907. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  908. }
  909. window.open(`mailto:?subject=${subject}&body=${body}`, '_blank');
  910. };
  911. /**
  912. * Show user feedback dialog if its required or just show "thank you" dialog.
  913. * @returns {Promise} when dialog is closed.
  914. */
  915. UI.requestFeedback = function () {
  916. return new Promise(function (resolve, reject) {
  917. if (Feedback.isEnabled()) {
  918. // If the user has already entered feedback, we'll show the window and
  919. // immidiately start the conference dispose timeout.
  920. if (Feedback.feedbackScore > 0) {
  921. Feedback.openFeedbackWindow();
  922. resolve();
  923. } else { // Otherwise we'll wait for user's feedback.
  924. Feedback.openFeedbackWindow(resolve);
  925. }
  926. } else {
  927. // If the feedback functionality isn't enabled we show a thank you
  928. // dialog.
  929. messageHandler.openMessageDialog(
  930. null, null, null,
  931. APP.translation.translateString(
  932. "dialog.thankYou", {appName:interfaceConfig.APP_NAME}
  933. )
  934. );
  935. resolve();
  936. }
  937. });
  938. };
  939. UI.updateRecordingState = function (state) {
  940. Recording.updateRecordingState(state);
  941. };
  942. UI.notifyTokenAuthFailed = function () {
  943. messageHandler.showError("dialog.error", "dialog.tokenAuthFailed");
  944. };
  945. UI.notifyInternalError = function () {
  946. messageHandler.showError("dialog.sorry", "dialog.internalError");
  947. };
  948. UI.notifyFocusDisconnected = function (focus, retrySec) {
  949. messageHandler.notify(
  950. null, "notify.focus",
  951. 'disconnected', "notify.focusFail",
  952. {component: focus, ms: retrySec}
  953. );
  954. };
  955. /**
  956. * Notify user that focus left the conference so page should be reloaded.
  957. */
  958. UI.notifyFocusLeft = function () {
  959. let title = APP.translation.generateTranslationHTML(
  960. 'dialog.serviceUnavailable'
  961. );
  962. let msg = APP.translation.generateTranslationHTML(
  963. 'dialog.jicofoUnavailable'
  964. );
  965. messageHandler.openDialog(
  966. title,
  967. msg,
  968. true, // persistent
  969. [{title: 'retry'}],
  970. function () {
  971. reload();
  972. return false;
  973. }
  974. );
  975. };
  976. /**
  977. * Updates auth info on the UI.
  978. * @param {boolean} isAuthEnabled if authentication is enabled
  979. * @param {string} [login] current login
  980. */
  981. UI.updateAuthInfo = function (isAuthEnabled, login) {
  982. let loggedIn = !!login;
  983. Toolbar.showAuthenticateButton(isAuthEnabled);
  984. if (isAuthEnabled) {
  985. Toolbar.setAuthenticatedIdentity(login);
  986. Toolbar.showLoginButton(!loggedIn);
  987. Toolbar.showLogoutButton(loggedIn);
  988. }
  989. };
  990. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  991. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  992. };
  993. /**
  994. * Update list of available physical devices.
  995. * @param {object[]} devices new list of available devices
  996. */
  997. UI.onAvailableDevicesChanged = function (devices) {
  998. SettingsMenu.changeDevicesList(devices);
  999. };
  1000. /**
  1001. * Sets microphone's <select> element to select microphone ID from settings.
  1002. */
  1003. UI.setSelectedMicFromSettings = function () {
  1004. SettingsMenu.setSelectedMicFromSettings();
  1005. };
  1006. /**
  1007. * Sets camera's <select> element to select camera ID from settings.
  1008. */
  1009. UI.setSelectedCameraFromSettings = function () {
  1010. SettingsMenu.setSelectedCameraFromSettings();
  1011. };
  1012. /**
  1013. * Sets audio outputs's <select> element to select audio output ID from
  1014. * settings.
  1015. */
  1016. UI.setSelectedAudioOutputFromSettings = function () {
  1017. SettingsMenu.setSelectedAudioOutputFromSettings();
  1018. };
  1019. /**
  1020. * Returns the id of the current video shown on large.
  1021. * Currently used by tests (torture).
  1022. */
  1023. UI.getLargeVideoID = function () {
  1024. return VideoLayout.getLargeVideoID();
  1025. };
  1026. /**
  1027. * Returns the current video shown on large.
  1028. * Currently used by tests (torture).
  1029. */
  1030. UI.getLargeVideo = function () {
  1031. return VideoLayout.getLargeVideo();
  1032. };
  1033. /**
  1034. * Shows dialog with a link to FF extension.
  1035. */
  1036. UI.showExtensionRequiredDialog = function (url) {
  1037. messageHandler.openMessageDialog(
  1038. "dialog.extensionRequired",
  1039. null,
  1040. null,
  1041. APP.translation.generateTranslationHTML(
  1042. "dialog.firefoxExtensionPrompt", {url: url}));
  1043. };
  1044. /**
  1045. * Shows dialog with combined information about camera and microphone errors.
  1046. * @param {JitsiTrackError} micError
  1047. * @param {JitsiTrackError} cameraError
  1048. */
  1049. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1050. let localStoragePropName = "doNotShowErrorAgain";
  1051. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1052. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1053. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1054. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1055. let showDoNotShowWarning = false;
  1056. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1057. isCameraJitsiTrackErrorAndHasName) {
  1058. showDoNotShowWarning = true;
  1059. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1060. showDoNotShowWarning = true;
  1061. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1062. showDoNotShowWarning = true;
  1063. }
  1064. if (micError) {
  1065. localStoragePropName += "-mic-" + micError.name;
  1066. }
  1067. if (cameraError) {
  1068. localStoragePropName += "-camera-" + cameraError.name;
  1069. }
  1070. if (showDoNotShowWarning) {
  1071. if (window.localStorage[localStoragePropName] === "true") {
  1072. return;
  1073. }
  1074. }
  1075. let title = getTitleKey();
  1076. let titleMsg = `<span data-i18n="${title}"></span>`;
  1077. let cameraJitsiTrackErrorMsg = cameraError
  1078. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1079. : undefined;
  1080. let micJitsiTrackErrorMsg = micError
  1081. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1082. : undefined;
  1083. let cameraErrorMsg = cameraError
  1084. ? cameraJitsiTrackErrorMsg ||
  1085. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1086. : "";
  1087. let micErrorMsg = micError
  1088. ? micJitsiTrackErrorMsg ||
  1089. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1090. : "";
  1091. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1092. cameraError.message
  1093. ? `<div>${cameraError.message}</div>`
  1094. : ``;
  1095. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1096. micError.message
  1097. ? `<div>${micError.message}</div>`
  1098. : ``;
  1099. let doNotShowWarningAgainSection = showDoNotShowWarning
  1100. ? `<label>
  1101. <input type='checkbox' id='doNotShowWarningAgain'>
  1102. <span data-i18n='dialog.doNotShowWarningAgain'></span>
  1103. </label>`
  1104. : ``;
  1105. let message = '';
  1106. if (micError) {
  1107. message = `
  1108. ${message}
  1109. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1110. <h4 data-i18n='${micErrorMsg}'></h4>
  1111. ${additionalMicErrorMsg}`;
  1112. }
  1113. if (cameraError) {
  1114. message = `
  1115. ${message}
  1116. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1117. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1118. ${additionalCameraErrorMsg}`;
  1119. }
  1120. message = `${message}${doNotShowWarningAgainSection}`;
  1121. // To make sure we don't have multiple error dialogs open at the same time,
  1122. // we will just close the previous one if we are going to show a new one.
  1123. deviceErrorDialog && deviceErrorDialog.close();
  1124. deviceErrorDialog = messageHandler.openDialog(
  1125. titleMsg,
  1126. message,
  1127. false,
  1128. {Ok: true},
  1129. function () {
  1130. let form = $.prompt.getPrompt();
  1131. if (form) {
  1132. let input = form.find("#doNotShowWarningAgain");
  1133. if (input.length) {
  1134. window.localStorage[localStoragePropName] =
  1135. input.prop("checked");
  1136. }
  1137. }
  1138. },
  1139. null,
  1140. function () {
  1141. // Reset dialog reference to null to avoid memory leaks when
  1142. // user closed the dialog manually.
  1143. deviceErrorDialog = null;
  1144. }
  1145. );
  1146. APP.translation.translateElement($(".jqibox"));
  1147. function getTitleKey() {
  1148. let title = "dialog.error";
  1149. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1150. if (cameraError && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1151. title = "dialog.permissionDenied";
  1152. } else if (!cameraError) {
  1153. title = "dialog.permissionDenied";
  1154. }
  1155. } else if (cameraError &&
  1156. cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1157. title = "dialog.permissionDenied";
  1158. }
  1159. return title;
  1160. }
  1161. };
  1162. UI.updateDevicesAvailability = function (id, devices) {
  1163. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1164. };
  1165. /**
  1166. * Show shared video.
  1167. * @param {string} id the id of the sender of the command
  1168. * @param {string} url video url
  1169. * @param {string} attributes
  1170. */
  1171. UI.onSharedVideoStart = function (id, url, attributes) {
  1172. if (sharedVideoManager)
  1173. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1174. };
  1175. /**
  1176. * Update shared video.
  1177. * @param {string} id the id of the sender of the command
  1178. * @param {string} url video url
  1179. * @param {string} attributes
  1180. */
  1181. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1182. if (sharedVideoManager)
  1183. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1184. };
  1185. /**
  1186. * Stop showing shared video.
  1187. * @param {string} id the id of the sender of the command
  1188. * @param {string} attributes
  1189. */
  1190. UI.onSharedVideoStop = function (id, attributes) {
  1191. if (sharedVideoManager)
  1192. sharedVideoManager.onSharedVideoStop(id, attributes);
  1193. };
  1194. /**
  1195. * Disables camera toolbar button.
  1196. */
  1197. UI.disableCameraButton = function () {
  1198. Toolbar.markVideoIconAsDisabled(true);
  1199. };
  1200. /**
  1201. * Enables camera toolbar button.
  1202. */
  1203. UI.enableCameraButton = function () {
  1204. Toolbar.markVideoIconAsDisabled(false);
  1205. };
  1206. /**
  1207. * Disables microphone toolbar button.
  1208. */
  1209. UI.disableMicrophoneButton = function () {
  1210. Toolbar.markAudioIconAsDisabled(true);
  1211. };
  1212. /**
  1213. * Enables microphone toolbar button.
  1214. */
  1215. UI.enableMicrophoneButton = function () {
  1216. Toolbar.markAudioIconAsDisabled(false);
  1217. };
  1218. let bottomToolbarEnabled = null;
  1219. UI.showRingOverLay = function () {
  1220. RingOverlay.show(APP.tokenData.callee);
  1221. FilmStrip.toggleFilmStrip(false);
  1222. };
  1223. UI.hideRingOverLay = function () {
  1224. if (!RingOverlay.hide())
  1225. return;
  1226. FilmStrip.toggleFilmStrip(true);
  1227. };
  1228. /**
  1229. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1230. * @param {string} browser - name of browser for which to show the guidance
  1231. * overlay.
  1232. */
  1233. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1234. GumPermissionsOverlay.show(browser);
  1235. };
  1236. /**
  1237. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1238. */
  1239. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1240. GumPermissionsOverlay.hide();
  1241. };
  1242. /**
  1243. * Shows or hides the keyboard shortcuts panel, depending on the current state.'
  1244. */
  1245. UI.toggleKeyboardShortcutsPanel = function() {
  1246. $('#keyboard-shortcuts').toggle();
  1247. };
  1248. /**
  1249. * Shows or hides the keyboard shortcuts panel.'
  1250. */
  1251. UI.showKeyboardShortcutsPanel = function(show) {
  1252. if (show) {
  1253. $('#keyboard-shortcuts').show();
  1254. } else {
  1255. $('#keyboard-shortcuts').hide();
  1256. }
  1257. };
  1258. module.exports = UI;