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

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