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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. /* jshint -W117 */
  2. /* application specific logic */
  3. var connection = null;
  4. var authenticatedUser = false;
  5. var focus = null;
  6. var activecall = null;
  7. var RTC = null;
  8. var nickname = null;
  9. var sharedKey = '';
  10. var recordingToken ='';
  11. var roomUrl = null;
  12. var roomName = null;
  13. var ssrc2jid = {};
  14. var mediaStreams = [];
  15. /**
  16. * The stats collector that process stats data and triggers updates to app.js.
  17. * @type {StatsCollector}
  18. */
  19. var statsCollector = null;
  20. /**
  21. * The stats collector for the local stream.
  22. * @type {LocalStatsCollector}
  23. */
  24. var localStatsCollector = null;
  25. /**
  26. * Indicates whether ssrc is camera video or desktop stream.
  27. * FIXME: remove those maps
  28. */
  29. var ssrc2videoType = {};
  30. var videoSrcToSsrc = {};
  31. /**
  32. * Currently focused video "src"(displayed in large video).
  33. * @type {String}
  34. */
  35. var focusedVideoSrc = null;
  36. var mutedAudios = {};
  37. var localVideoSrc = null;
  38. var flipXLocalVideo = true;
  39. var isFullScreen = false;
  40. var toolbarTimeout = null;
  41. var currentVideoWidth = null;
  42. var currentVideoHeight = null;
  43. /**
  44. * Method used to calculate large video size.
  45. * @type {function ()}
  46. */
  47. var getVideoSize;
  48. /**
  49. * Method used to get large video position.
  50. * @type {function ()}
  51. */
  52. var getVideoPosition;
  53. /* window.onbeforeunload = closePageWarning; */
  54. var sessionTerminated = false;
  55. function init() {
  56. RTC = setupRTC();
  57. if (RTC === null) {
  58. window.location.href = 'webrtcrequired.html';
  59. return;
  60. } else if (RTC.browser !== 'chrome') {
  61. window.location.href = 'chromeonly.html';
  62. return;
  63. }
  64. obtainAudioAndVideoPermissions(function (stream) {
  65. var audioStream = new webkitMediaStream(stream);
  66. var videoStream = new webkitMediaStream(stream);
  67. var videoTracks = stream.getVideoTracks();
  68. var audioTracks = stream.getAudioTracks();
  69. for (var i = 0; i < videoTracks.length; i++) {
  70. audioStream.removeTrack(videoTracks[i]);
  71. }
  72. VideoLayout.changeLocalAudio(audioStream);
  73. startLocalRtpStatsCollector(audioStream);
  74. for (i = 0; i < audioTracks.length; i++) {
  75. videoStream.removeTrack(audioTracks[i]);
  76. }
  77. VideoLayout.changeLocalVideo(videoStream, true);
  78. maybeDoJoin();
  79. });
  80. var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
  81. connect(jid);
  82. }
  83. function connect(jid, password) {
  84. connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
  85. if (nickname) {
  86. connection.emuc.addDisplayNameToPresence(nickname);
  87. }
  88. if (connection.disco) {
  89. // for chrome, add multistream cap
  90. }
  91. connection.jingle.pc_constraints = RTC.pc_constraints;
  92. if (config.useIPv6) {
  93. // https://code.google.com/p/webrtc/issues/detail?id=2828
  94. if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
  95. connection.jingle.pc_constraints.optional.push({googIPv6: true});
  96. }
  97. if(!password)
  98. password = document.getElementById('password').value;
  99. var anonymousConnectionFailed = false;
  100. connection.connect(jid, password, function (status, msg) {
  101. if (status === Strophe.Status.CONNECTED) {
  102. console.log('connected');
  103. if (config.useStunTurn) {
  104. connection.jingle.getStunAndTurnCredentials();
  105. }
  106. document.getElementById('connect').disabled = true;
  107. if(password)
  108. authenticatedUser = true;
  109. maybeDoJoin();
  110. } else if (status === Strophe.Status.CONNFAIL) {
  111. if(msg === 'x-strophe-bad-non-anon-jid') {
  112. anonymousConnectionFailed = true;
  113. }
  114. console.log('status', status);
  115. } else if (status === Strophe.Status.DISCONNECTED) {
  116. if(anonymousConnectionFailed) {
  117. // prompt user for username and password
  118. $(document).trigger('passwordrequired.main');
  119. }
  120. } else if (status === Strophe.Status.AUTHFAIL) {
  121. // wrong password or username, prompt user
  122. $(document).trigger('passwordrequired.main');
  123. } else {
  124. console.log('status', status);
  125. }
  126. });
  127. }
  128. /**
  129. * HTTPS only:
  130. * We first ask for audio and video combined stream in order to get permissions and not to ask twice.
  131. * Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
  132. */
  133. function obtainAudioAndVideoPermissions(callback) {
  134. // This makes sense only on https sites otherwise we'll be asked for permissions every time
  135. if (location.protocol !== 'https:') {
  136. callback();
  137. return;
  138. }
  139. // Get AV
  140. getUserMediaWithConstraints(
  141. ['audio', 'video'],
  142. function (avStream) {
  143. callback(avStream);
  144. },
  145. function (error) {
  146. console.error('failed to obtain audio/video stream - stop', error);
  147. },
  148. config.resolution || '360');
  149. }
  150. function maybeDoJoin() {
  151. if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
  152. && (connection.jingle.localAudio || connection.jingle.localVideo)) {
  153. doJoin();
  154. }
  155. }
  156. function doJoin() {
  157. var roomnode = null;
  158. var path = window.location.pathname;
  159. var roomjid;
  160. // determinde the room node from the url
  161. // TODO: just the roomnode or the whole bare jid?
  162. if (config.getroomnode && typeof config.getroomnode === 'function') {
  163. // custom function might be responsible for doing the pushstate
  164. roomnode = config.getroomnode(path);
  165. } else {
  166. /* fall back to default strategy
  167. * this is making assumptions about how the URL->room mapping happens.
  168. * It currently assumes deployment at root, with a rewrite like the
  169. * following one (for nginx):
  170. location ~ ^/([a-zA-Z0-9]+)$ {
  171. rewrite ^/(.*)$ / break;
  172. }
  173. */
  174. if (path.length > 1) {
  175. roomnode = path.substr(1).toLowerCase();
  176. } else {
  177. roomnode = Math.random().toString(36).substr(2, 20);
  178. window.history.pushState('VideoChat',
  179. 'Room: ' + roomnode, window.location.pathname + roomnode);
  180. }
  181. }
  182. roomName = roomnode + '@' + config.hosts.muc;
  183. roomjid = roomName;
  184. if (config.useNicks) {
  185. var nick = window.prompt('Your nickname (optional)');
  186. if (nick) {
  187. roomjid += '/' + nick;
  188. } else {
  189. roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
  190. }
  191. } else {
  192. var tmpJid = Strophe.getNodeFromJid(connection.jid);
  193. if(!authenticatedUser)
  194. tmpJid = tmpJid.substr(0, 8);
  195. roomjid += '/' + tmpJid;
  196. }
  197. connection.emuc.doJoin(roomjid);
  198. }
  199. function waitForRemoteVideo(selector, ssrc, stream) {
  200. if (selector.removed || !selector.parent().is(":visible")) {
  201. console.warn("Media removed before had started", selector);
  202. return;
  203. }
  204. if (stream.id === 'mixedmslabel') return;
  205. if (selector[0].currentTime > 0) {
  206. RTC.attachMediaStream(selector, stream); // FIXME: why do i have to do this for FF?
  207. // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
  208. // in order to get rid of too many maps
  209. if (ssrc && selector.attr('src')) {
  210. videoSrcToSsrc[selector.attr('src')] = ssrc;
  211. } else {
  212. console.warn("No ssrc given for video", selector);
  213. }
  214. $(document).trigger('videoactive.jingle', [selector]);
  215. } else {
  216. setTimeout(function () {
  217. waitForRemoteVideo(selector, ssrc, stream);
  218. }, 250);
  219. }
  220. }
  221. $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
  222. var sess = connection.jingle.sessions[sid];
  223. var thessrc;
  224. // look up an associated JID for a stream id
  225. if (data.stream.id.indexOf('mixedmslabel') === -1) {
  226. var ssrclines
  227. = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
  228. ssrclines = ssrclines.filter(function (line) {
  229. return line.indexOf('mslabel:' + data.stream.label) !== -1;
  230. });
  231. if (ssrclines.length) {
  232. thessrc = ssrclines[0].substring(7).split(' ')[0];
  233. // ok to overwrite the one from focus? might save work in colibri.js
  234. console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
  235. if (ssrc2jid[thessrc]) {
  236. data.peerjid = ssrc2jid[thessrc];
  237. }
  238. }
  239. }
  240. mediaStreams.push(new MediaStream(data, sid, thessrc));
  241. var container;
  242. var remotes = document.getElementById('remoteVideos');
  243. if (data.peerjid) {
  244. VideoLayout.ensurePeerContainerExists(data.peerjid);
  245. container = document.getElementById(
  246. 'participant_' + Strophe.getResourceFromJid(data.peerjid));
  247. } else {
  248. if (data.stream.id !== 'mixedmslabel') {
  249. console.error( 'can not associate stream',
  250. data.stream.id,
  251. 'with a participant');
  252. // We don't want to add it here since it will cause troubles
  253. return;
  254. }
  255. // FIXME: for the mixed ms we dont need a video -- currently
  256. container = document.createElement('span');
  257. container.id = 'mixedstream';
  258. container.className = 'videocontainer';
  259. remotes.appendChild(container);
  260. Util.playSoundNotification('userJoined');
  261. }
  262. var isVideo = data.stream.getVideoTracks().length > 0;
  263. if (container) {
  264. VideoLayout.addRemoteStreamElement( container,
  265. sid,
  266. data.stream,
  267. data.peerjid,
  268. thessrc);
  269. }
  270. // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
  271. if (isVideo &&
  272. data.peerjid && sess.peerjid === data.peerjid &&
  273. data.stream.getVideoTracks().length === 0 &&
  274. connection.jingle.localVideo.getVideoTracks().length > 0) {
  275. //
  276. window.setTimeout(function () {
  277. sendKeyframe(sess.peerconnection);
  278. }, 3000);
  279. }
  280. });
  281. /**
  282. * Returns the JID of the user to whom given <tt>videoSrc</tt> belongs.
  283. * @param videoSrc the video "src" identifier.
  284. * @returns {null | String} the JID of the user to whom given <tt>videoSrc</tt>
  285. * belongs.
  286. */
  287. function getJidFromVideoSrc(videoSrc)
  288. {
  289. if (videoSrc === localVideoSrc)
  290. return connection.emuc.myroomjid;
  291. var ssrc = videoSrcToSsrc[videoSrc];
  292. if (!ssrc)
  293. {
  294. return null;
  295. }
  296. return ssrc2jid[ssrc];
  297. }
  298. // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
  299. function sendKeyframe(pc) {
  300. console.log('sendkeyframe', pc.iceConnectionState);
  301. if (pc.iceConnectionState !== 'connected') return; // safe...
  302. pc.setRemoteDescription(
  303. pc.remoteDescription,
  304. function () {
  305. pc.createAnswer(
  306. function (modifiedAnswer) {
  307. pc.setLocalDescription(
  308. modifiedAnswer,
  309. function () {
  310. // noop
  311. },
  312. function (error) {
  313. console.log('triggerKeyframe setLocalDescription failed', error);
  314. }
  315. );
  316. },
  317. function (error) {
  318. console.log('triggerKeyframe createAnswer failed', error);
  319. }
  320. );
  321. },
  322. function (error) {
  323. console.log('triggerKeyframe setRemoteDescription failed', error);
  324. }
  325. );
  326. }
  327. // Really mute video, i.e. dont even send black frames
  328. function muteVideo(pc, unmute) {
  329. // FIXME: this probably needs another of those lovely state safeguards...
  330. // which checks for iceconn == connected and sigstate == stable
  331. pc.setRemoteDescription(pc.remoteDescription,
  332. function () {
  333. pc.createAnswer(
  334. function (answer) {
  335. var sdp = new SDP(answer.sdp);
  336. if (sdp.media.length > 1) {
  337. if (unmute)
  338. sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
  339. else
  340. sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
  341. sdp.raw = sdp.session + sdp.media.join('');
  342. answer.sdp = sdp.raw;
  343. }
  344. pc.setLocalDescription(answer,
  345. function () {
  346. console.log('mute SLD ok');
  347. },
  348. function (error) {
  349. console.log('mute SLD error');
  350. }
  351. );
  352. },
  353. function (error) {
  354. console.log(error);
  355. }
  356. );
  357. },
  358. function (error) {
  359. console.log('muteVideo SRD error');
  360. }
  361. );
  362. }
  363. /**
  364. * Callback for audio levels changed.
  365. * @param jid JID of the user
  366. * @param audioLevel the audio level value
  367. */
  368. function audioLevelUpdated(jid, audioLevel)
  369. {
  370. var resourceJid;
  371. if(jid === LocalStatsCollector.LOCAL_JID)
  372. {
  373. resourceJid = AudioLevels.LOCAL_LEVEL;
  374. if(isAudioMuted())
  375. return;
  376. }
  377. else
  378. {
  379. resourceJid = Strophe.getResourceFromJid(jid);
  380. }
  381. AudioLevels.updateAudioLevel(resourceJid, audioLevel);
  382. }
  383. /**
  384. * Starts the {@link StatsCollector} if the feature is enabled in config.js.
  385. */
  386. function startRtpStatsCollector()
  387. {
  388. stopRTPStatsCollector();
  389. if (config.enableRtpStats)
  390. {
  391. statsCollector = new StatsCollector(
  392. getConferenceHandler().peerconnection, 200, audioLevelUpdated);
  393. statsCollector.start();
  394. }
  395. }
  396. /**
  397. * Stops the {@link StatsCollector}.
  398. */
  399. function stopRTPStatsCollector()
  400. {
  401. if (statsCollector)
  402. {
  403. statsCollector.stop();
  404. statsCollector = null;
  405. }
  406. }
  407. /**
  408. * Starts the {@link LocalStatsCollector} if the feature is enabled in config.js
  409. * @param stream the stream that will be used for collecting statistics.
  410. */
  411. function startLocalRtpStatsCollector(stream)
  412. {
  413. if(config.enableRtpStats)
  414. {
  415. localStatsCollector = new LocalStatsCollector(stream, 100, audioLevelUpdated);
  416. localStatsCollector.start();
  417. }
  418. }
  419. /**
  420. * Stops the {@link LocalStatsCollector}.
  421. */
  422. function stopLocalRtpStatsCollector()
  423. {
  424. if(localStatsCollector)
  425. {
  426. localStatsCollector.stop();
  427. localStatsCollector = null;
  428. }
  429. }
  430. $(document).bind('callincoming.jingle', function (event, sid) {
  431. var sess = connection.jingle.sessions[sid];
  432. // TODO: do we check activecall == null?
  433. activecall = sess;
  434. startRtpStatsCollector();
  435. // Bind data channel listener in case we're a regular participant
  436. if (config.openSctp)
  437. {
  438. bindDataChannelListener(sess.peerconnection);
  439. }
  440. // TODO: check affiliation and/or role
  441. console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
  442. sess.usedrip = true; // not-so-naive trickle ice
  443. sess.sendAnswer();
  444. sess.accept();
  445. });
  446. $(document).bind('conferenceCreated.jingle', function (event, focus)
  447. {
  448. startRtpStatsCollector();
  449. });
  450. $(document).bind('conferenceCreated.jingle', function (event, focus)
  451. {
  452. // Bind data channel listener in case we're the focus
  453. if (config.openSctp)
  454. {
  455. bindDataChannelListener(focus.peerconnection);
  456. }
  457. });
  458. $(document).bind('callterminated.jingle', function (event, sid, jid, reason) {
  459. // Leave the room if my call has been remotely terminated.
  460. if (connection.emuc.joined && focus == null && reason === 'kick') {
  461. sessionTerminated = true;
  462. connection.emuc.doLeave();
  463. openMessageDialog( "Session Terminated",
  464. "Ouch! You have been kicked out of the meet!");
  465. }
  466. });
  467. $(document).bind('setLocalDescription.jingle', function (event, sid) {
  468. // put our ssrcs into presence so other clients can identify our stream
  469. var sess = connection.jingle.sessions[sid];
  470. var newssrcs = {};
  471. var directions = {};
  472. var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
  473. localSDP.media.forEach(function (media) {
  474. var type = SDPUtil.parse_mid(SDPUtil.find_line(media, 'a=mid:'));
  475. if (SDPUtil.find_line(media, 'a=ssrc:')) {
  476. // assumes a single local ssrc
  477. var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
  478. newssrcs[type] = ssrc;
  479. directions[type] = (
  480. SDPUtil.find_line(media, 'a=sendrecv') ||
  481. SDPUtil.find_line(media, 'a=recvonly') ||
  482. SDPUtil.find_line(media, 'a=sendonly') ||
  483. SDPUtil.find_line(media, 'a=inactive') ||
  484. 'a=sendrecv').substr(2);
  485. }
  486. });
  487. console.log('new ssrcs', newssrcs);
  488. // Have to clear presence map to get rid of removed streams
  489. connection.emuc.clearPresenceMedia();
  490. var i = 0;
  491. Object.keys(newssrcs).forEach(function (mtype) {
  492. i++;
  493. var type = mtype;
  494. // Change video type to screen
  495. if (mtype === 'video' && isUsingScreenStream) {
  496. type = 'screen';
  497. }
  498. connection.emuc.addMediaToPresence(i, type, newssrcs[mtype], directions[mtype]);
  499. });
  500. if (i > 0) {
  501. connection.emuc.sendPresence();
  502. }
  503. });
  504. $(document).bind('joined.muc', function (event, jid, info) {
  505. updateRoomUrl(window.location.href);
  506. document.getElementById('localNick').appendChild(
  507. document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
  508. );
  509. if (Object.keys(connection.emuc.members).length < 1) {
  510. focus = new ColibriFocus(connection, config.hosts.bridge);
  511. if (nickname !== null) {
  512. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  513. nickname);
  514. }
  515. Toolbar.showSipCallButton(true);
  516. Toolbar.showRecordingButton(false);
  517. }
  518. if (!focus)
  519. {
  520. Toolbar.showSipCallButton(false);
  521. }
  522. if (focus && config.etherpad_base) {
  523. Etherpad.init();
  524. }
  525. VideoLayout.showFocusIndicator();
  526. // Add myself to the contact list.
  527. ContactList.addContact(jid);
  528. // Once we've joined the muc show the toolbar
  529. Toolbar.showToolbar();
  530. var displayName = '';
  531. if (info.displayName)
  532. displayName = info.displayName + ' (me)';
  533. else
  534. displayName = "Me";
  535. $(document).trigger('displaynamechanged',
  536. ['localVideoContainer', displayName]);
  537. });
  538. $(document).bind('entered.muc', function (event, jid, info, pres) {
  539. console.log('entered', jid, info);
  540. console.log('is focus?' + focus ? 'true' : 'false');
  541. // Add Peer's container
  542. VideoLayout.ensurePeerContainerExists(jid);
  543. if (focus !== null) {
  544. // FIXME: this should prepare the video
  545. if (focus.confid === null) {
  546. console.log('make new conference with', jid);
  547. focus.makeConference(Object.keys(connection.emuc.members));
  548. Toolbar.showRecordingButton(true);
  549. } else {
  550. console.log('invite', jid, 'into conference');
  551. focus.addNewParticipant(jid);
  552. }
  553. }
  554. else if (sharedKey) {
  555. Toolbar.updateLockButton();
  556. }
  557. });
  558. $(document).bind('left.muc', function (event, jid) {
  559. console.log('left.muc', jid);
  560. // Need to call this with a slight delay, otherwise the element couldn't be
  561. // found for some reason.
  562. window.setTimeout(function () {
  563. var container = document.getElementById(
  564. 'participant_' + Strophe.getResourceFromJid(jid));
  565. if (container) {
  566. // hide here, wait for video to close before removing
  567. $(container).hide();
  568. VideoLayout.resizeThumbnails();
  569. }
  570. }, 10);
  571. // Unlock large video
  572. if (focusedVideoSrc)
  573. {
  574. if (getJidFromVideoSrc(focusedVideoSrc) === jid)
  575. {
  576. console.info("Focused video owner has left the conference");
  577. focusedVideoSrc = null;
  578. }
  579. }
  580. connection.jingle.terminateByJid(jid);
  581. if (focus == null
  582. // I shouldn't be the one that left to enter here.
  583. && jid !== connection.emuc.myroomjid
  584. && connection.emuc.myroomjid === connection.emuc.list_members[0]
  585. // If our session has been terminated for some reason
  586. // (kicked, hangup), don't try to become the focus
  587. && !sessionTerminated) {
  588. console.log('welcome to our new focus... myself');
  589. focus = new ColibriFocus(connection, config.hosts.bridge);
  590. if (nickname !== null) {
  591. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  592. nickname);
  593. }
  594. Toolbar.showSipCallButton(true);
  595. if (Object.keys(connection.emuc.members).length > 0) {
  596. focus.makeConference(Object.keys(connection.emuc.members));
  597. Toolbar.showRecordingButton(true);
  598. }
  599. $(document).trigger('focusechanged.muc', [focus]);
  600. }
  601. else if (focus && Object.keys(connection.emuc.members).length === 0) {
  602. console.log('everyone left');
  603. // FIXME: closing the connection is a hack to avoid some
  604. // problems with reinit
  605. disposeConference();
  606. focus = new ColibriFocus(connection, config.hosts.bridge);
  607. if (nickname !== null) {
  608. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  609. nickname);
  610. }
  611. Toolbar.showSipCallButton(true);
  612. Toolbar.showRecordingButton(false);
  613. }
  614. if (connection.emuc.getPrezi(jid)) {
  615. $(document).trigger('presentationremoved.muc',
  616. [jid, connection.emuc.getPrezi(jid)]);
  617. }
  618. });
  619. $(document).bind('presence.muc', function (event, jid, info, pres) {
  620. // Remove old ssrcs coming from the jid
  621. Object.keys(ssrc2jid).forEach(function (ssrc) {
  622. if (ssrc2jid[ssrc] == jid) {
  623. delete ssrc2jid[ssrc];
  624. }
  625. if (ssrc2videoType[ssrc] == jid) {
  626. delete ssrc2videoType[ssrc];
  627. }
  628. });
  629. $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
  630. //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
  631. var ssrcV = ssrc.getAttribute('ssrc');
  632. ssrc2jid[ssrcV] = jid;
  633. var type = ssrc.getAttribute('type');
  634. ssrc2videoType[ssrcV] = type;
  635. // might need to update the direction if participant just went from sendrecv to recvonly
  636. if (type === 'video' || type === 'screen') {
  637. var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
  638. switch (ssrc.getAttribute('direction')) {
  639. case 'sendrecv':
  640. el.show();
  641. break;
  642. case 'recvonly':
  643. el.hide();
  644. // FIXME: Check if we have to change large video
  645. //VideoLayout.updateLargeVideo(el);
  646. break;
  647. }
  648. }
  649. });
  650. if (info.displayName && info.displayName.length > 0)
  651. $(document).trigger('displaynamechanged',
  652. [jid, info.displayName]);
  653. if (focus !== null && info.displayName !== null) {
  654. focus.setEndpointDisplayName(jid, info.displayName);
  655. }
  656. });
  657. $(document).bind('presence.status.muc', function (event, jid, info, pres) {
  658. VideoLayout.setPresenceStatus(
  659. 'participant_' + Strophe.getResourceFromJid(jid), info.status);
  660. });
  661. $(document).bind('passwordrequired.muc', function (event, jid) {
  662. console.log('on password required', jid);
  663. $.prompt('<h2>Password required</h2>' +
  664. '<input id="lockKey" type="text" placeholder="shared key" autofocus>', {
  665. persistent: true,
  666. buttons: { "Ok": true, "Cancel": false},
  667. defaultButton: 1,
  668. loaded: function (event) {
  669. document.getElementById('lockKey').focus();
  670. },
  671. submit: function (e, v, m, f) {
  672. if (v) {
  673. var lockKey = document.getElementById('lockKey');
  674. if (lockKey.value !== null) {
  675. setSharedKey(lockKey.value);
  676. connection.emuc.doJoin(jid, lockKey.value);
  677. }
  678. }
  679. }
  680. });
  681. });
  682. $(document).bind('passwordrequired.main', function (event) {
  683. console.log('password is required');
  684. $.prompt('<h2>Password required</h2>' +
  685. '<input id="passwordrequired.username" type="text" placeholder="user@domain.net" autofocus>' +
  686. '<input id="passwordrequired.password" type="password" placeholder="user password">', {
  687. persistent: true,
  688. buttons: { "Ok": true, "Cancel": false},
  689. defaultButton: 1,
  690. loaded: function (event) {
  691. document.getElementById('passwordrequired.username').focus();
  692. },
  693. submit: function (e, v, m, f) {
  694. if (v) {
  695. var username = document.getElementById('passwordrequired.username');
  696. var password = document.getElementById('passwordrequired.password');
  697. if (username.value !== null && password.value != null) {
  698. connect(username.value, password.value);
  699. }
  700. }
  701. }
  702. });
  703. });
  704. /**
  705. * Checks if video identified by given src is desktop stream.
  706. * @param videoSrc eg.
  707. * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
  708. * @returns {boolean}
  709. */
  710. function isVideoSrcDesktop(videoSrc) {
  711. // FIXME: fix this mapping mess...
  712. // figure out if large video is desktop stream or just a camera
  713. var isDesktop = false;
  714. if (localVideoSrc === videoSrc) {
  715. // local video
  716. isDesktop = isUsingScreenStream;
  717. } else {
  718. // Do we have associations...
  719. var videoSsrc = videoSrcToSsrc[videoSrc];
  720. if (videoSsrc) {
  721. var videoType = ssrc2videoType[videoSsrc];
  722. if (videoType) {
  723. // Finally there...
  724. isDesktop = videoType === 'screen';
  725. } else {
  726. console.error("No video type for ssrc: " + videoSsrc);
  727. }
  728. } else {
  729. console.error("No ssrc for src: " + videoSrc);
  730. }
  731. }
  732. return isDesktop;
  733. }
  734. function getConferenceHandler() {
  735. return focus ? focus : activecall;
  736. }
  737. function toggleVideo() {
  738. if (!(connection && connection.jingle.localVideo))
  739. return;
  740. var sess = getConferenceHandler();
  741. if (sess) {
  742. sess.toggleVideoMute(
  743. function (isMuted) {
  744. if (isMuted) {
  745. $('#video').removeClass("icon-camera");
  746. $('#video').addClass("icon-camera icon-camera-disabled");
  747. } else {
  748. $('#video').removeClass("icon-camera icon-camera-disabled");
  749. $('#video').addClass("icon-camera");
  750. }
  751. }
  752. );
  753. }
  754. sess = focus || activecall;
  755. if (!sess) {
  756. return;
  757. }
  758. sess.pendingop = ismuted ? 'unmute' : 'mute';
  759. // connection.emuc.addVideoInfoToPresence(!ismuted);
  760. // connection.emuc.sendPresence();
  761. sess.modifySources();
  762. }
  763. /**
  764. * Mutes / unmutes audio for the local participant.
  765. */
  766. function toggleAudio() {
  767. if (!(connection && connection.jingle.localAudio)) {
  768. preMuted = true;
  769. // We still click the button.
  770. buttonClick("#mute", "icon-microphone icon-mic-disabled");
  771. return;
  772. }
  773. var localAudio = connection.jingle.localAudio;
  774. for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
  775. var audioEnabled = localAudio.getAudioTracks()[idx].enabled;
  776. localAudio.getAudioTracks()[idx].enabled = !audioEnabled;
  777. // isMuted is the opposite of audioEnabled
  778. connection.emuc.addAudioInfoToPresence(audioEnabled);
  779. connection.emuc.sendPresence();
  780. }
  781. buttonClick("#mute", "icon-microphone icon-mic-disabled");
  782. }
  783. /**
  784. * Checks whether the audio is muted or not.
  785. * @returns {boolean} true if audio is muted and false if not.
  786. */
  787. function isAudioMuted()
  788. {
  789. var localAudio = connection.jingle.localAudio;
  790. for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
  791. if(localAudio.getAudioTracks()[idx].enabled === true)
  792. return false;
  793. }
  794. return true;
  795. }
  796. // Starts or stops the recording for the conference.
  797. function toggleRecording() {
  798. if (focus === null || focus.confid === null) {
  799. console.log('non-focus, or conference not yet organized: not enabling recording');
  800. return;
  801. }
  802. if (!recordingToken)
  803. {
  804. $.prompt('<h2>Enter recording token</h2>' +
  805. '<input id="recordingToken" type="text" placeholder="token" autofocus>',
  806. {
  807. persistent: false,
  808. buttons: { "Save": true, "Cancel": false},
  809. defaultButton: 1,
  810. loaded: function (event) {
  811. document.getElementById('recordingToken').focus();
  812. },
  813. submit: function (e, v, m, f) {
  814. if (v) {
  815. var token = document.getElementById('recordingToken');
  816. if (token.value) {
  817. setRecordingToken(Util.escapeHtml(token.value));
  818. toggleRecording();
  819. }
  820. }
  821. }
  822. }
  823. );
  824. return;
  825. }
  826. var oldState = focus.recordingEnabled;
  827. Toolbar.toggleRecordingButtonState();
  828. focus.setRecording(!oldState,
  829. recordingToken,
  830. function (state) {
  831. console.log("New recording state: ", state);
  832. if (state == oldState) //failed to change, reset the token because it might have been wrong
  833. {
  834. Toolbar.toggleRecordingButtonState();
  835. setRecordingToken(null);
  836. }
  837. }
  838. );
  839. }
  840. /**
  841. * Returns an array of the video horizontal and vertical indents,
  842. * so that if fits its parent.
  843. *
  844. * @return an array with 2 elements, the horizontal indent and the vertical
  845. * indent
  846. */
  847. function getCameraVideoPosition(videoWidth,
  848. videoHeight,
  849. videoSpaceWidth,
  850. videoSpaceHeight) {
  851. // Parent height isn't completely calculated when we position the video in
  852. // full screen mode and this is why we use the screen height in this case.
  853. // Need to think it further at some point and implement it properly.
  854. var isFullScreen = document.fullScreen ||
  855. document.mozFullScreen ||
  856. document.webkitIsFullScreen;
  857. if (isFullScreen)
  858. videoSpaceHeight = window.innerHeight;
  859. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  860. var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
  861. return [horizontalIndent, verticalIndent];
  862. }
  863. /**
  864. * Returns an array of the video horizontal and vertical indents.
  865. * Centers horizontally and top aligns vertically.
  866. *
  867. * @return an array with 2 elements, the horizontal indent and the vertical
  868. * indent
  869. */
  870. function getDesktopVideoPosition(videoWidth,
  871. videoHeight,
  872. videoSpaceWidth,
  873. videoSpaceHeight) {
  874. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  875. var verticalIndent = 0;// Top aligned
  876. return [horizontalIndent, verticalIndent];
  877. }
  878. /**
  879. * Returns an array of the video dimensions, so that it covers the screen.
  880. * It leaves no empty areas, but some parts of the video might not be visible.
  881. *
  882. * @return an array with 2 elements, the video width and the video height
  883. */
  884. function getCameraVideoSize(videoWidth,
  885. videoHeight,
  886. videoSpaceWidth,
  887. videoSpaceHeight) {
  888. if (!videoWidth)
  889. videoWidth = currentVideoWidth;
  890. if (!videoHeight)
  891. videoHeight = currentVideoHeight;
  892. var aspectRatio = videoWidth / videoHeight;
  893. var availableWidth = Math.max(videoWidth, videoSpaceWidth);
  894. var availableHeight = Math.max(videoHeight, videoSpaceHeight);
  895. if (availableWidth / aspectRatio < videoSpaceHeight) {
  896. availableHeight = videoSpaceHeight;
  897. availableWidth = availableHeight * aspectRatio;
  898. }
  899. if (availableHeight * aspectRatio < videoSpaceWidth) {
  900. availableWidth = videoSpaceWidth;
  901. availableHeight = availableWidth / aspectRatio;
  902. }
  903. return [availableWidth, availableHeight];
  904. }
  905. $(document).ready(function () {
  906. if(config.enableWelcomePage && window.location.pathname == "/" &&
  907. (!window.localStorage.welcomePageDisabled || window.localStorage.welcomePageDisabled == "false"))
  908. {
  909. $("#videoconference_page").hide();
  910. $("#domain_name").text(window.location.host + "/");
  911. $("span[name='appName']").text(brand.appName);
  912. $("#enter_room_button").click(function()
  913. {
  914. var val = $("#enter_room_field").val();
  915. if(!val)
  916. val = $("#enter_room_field").attr("placeholder");
  917. window.location.pathname = "/" + val;
  918. });
  919. $("#enter_room_field").keydown(function (event) {
  920. if (event.keyCode === 13) {
  921. var val = Util.escapeHtml(this.value);
  922. window.location.pathname = "/" + val;
  923. }
  924. });
  925. function animate(word) {
  926. var currentVal = $("#enter_room_field").attr("placeholder");
  927. $("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
  928. setTimeout(function() {
  929. animate(word.substring(1, word.length))
  930. }, 150);
  931. }
  932. function update_roomname()
  933. {
  934. $("#enter_room_field").attr("placeholder", "");
  935. animate(RoomNameGenerator.generateRoomWithoutSeparator());
  936. setTimeout(update_roomname, 10000);
  937. }
  938. update_roomname();
  939. $("#disable_welcome").click(function () {
  940. window.localStorage.welcomePageDisabled = $("#disable_welcome").is(":checked");
  941. });
  942. return;
  943. }
  944. $("#welcome_page").hide();
  945. Chat.init();
  946. $('body').popover({ selector: '[data-toggle=popover]',
  947. trigger: 'click hover'});
  948. // Set the defaults for prompt dialogs.
  949. jQuery.prompt.setDefaults({persistent: false});
  950. // Set default desktop sharing method
  951. setDesktopSharing(config.desktopSharing);
  952. // Initialize Chrome extension inline installs
  953. if (config.chromeExtensionId) {
  954. initInlineInstalls();
  955. }
  956. // By default we use camera
  957. getVideoSize = getCameraVideoSize;
  958. getVideoPosition = getCameraVideoPosition;
  959. VideoLayout.resizeLargeVideoContainer();
  960. $(window).resize(function () {
  961. VideoLayout.resizeLargeVideoContainer();
  962. VideoLayout.positionLarge();
  963. });
  964. // Listen for large video size updates
  965. document.getElementById('largeVideo')
  966. .addEventListener('loadedmetadata', function (e) {
  967. currentVideoWidth = this.videoWidth;
  968. currentVideoHeight = this.videoHeight;
  969. VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
  970. });
  971. if (!$('#settings').is(':visible')) {
  972. console.log('init');
  973. init();
  974. } else {
  975. loginInfo.onsubmit = function (e) {
  976. if (e.preventDefault) e.preventDefault();
  977. $('#settings').hide();
  978. init();
  979. };
  980. }
  981. });
  982. $(window).bind('beforeunload', function () {
  983. if (connection && connection.connected) {
  984. // ensure signout
  985. $.ajax({
  986. type: 'POST',
  987. url: config.bosh,
  988. async: false,
  989. cache: false,
  990. contentType: 'application/xml',
  991. data: "<body rid='" + (connection.rid || connection._proto.rid) + "' xmlns='http://jabber.org/protocol/httpbind' sid='" + (connection.sid || connection._proto.sid) + "' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>",
  992. success: function (data) {
  993. console.log('signed out');
  994. console.log(data);
  995. },
  996. error: function (XMLHttpRequest, textStatus, errorThrown) {
  997. console.log('signout error', textStatus + ' (' + errorThrown + ')');
  998. }
  999. });
  1000. }
  1001. disposeConference(true);
  1002. });
  1003. function disposeConference(onUnload) {
  1004. var handler = getConferenceHandler();
  1005. if (handler && handler.peerconnection) {
  1006. // FIXME: probably removing streams is not required and close() should be enough
  1007. if (connection.jingle.localAudio) {
  1008. handler.peerconnection.removeStream(connection.jingle.localAudio);
  1009. }
  1010. if (connection.jingle.localVideo) {
  1011. handler.peerconnection.removeStream(connection.jingle.localVideo);
  1012. }
  1013. handler.peerconnection.close();
  1014. }
  1015. stopRTPStatsCollector();
  1016. if(onUnload) {
  1017. stopLocalRtpStatsCollector();
  1018. }
  1019. focus = null;
  1020. activecall = null;
  1021. }
  1022. function dump(elem, filename) {
  1023. elem = elem.parentNode;
  1024. elem.download = filename || 'meetlog.json';
  1025. elem.href = 'data:application/json;charset=utf-8,\n';
  1026. var data = {};
  1027. if (connection.jingle) {
  1028. Object.keys(connection.jingle.sessions).forEach(function (sid) {
  1029. var session = connection.jingle.sessions[sid];
  1030. if (session.peerconnection && session.peerconnection.updateLog) {
  1031. // FIXME: should probably be a .dump call
  1032. data["jingle_" + session.sid] = {
  1033. updateLog: session.peerconnection.updateLog,
  1034. stats: session.peerconnection.stats,
  1035. url: window.location.href
  1036. };
  1037. }
  1038. });
  1039. }
  1040. metadata = {};
  1041. metadata.time = new Date();
  1042. metadata.url = window.location.href;
  1043. metadata.ua = navigator.userAgent;
  1044. if (connection.logger) {
  1045. metadata.xmpp = connection.logger.log;
  1046. }
  1047. data.metadata = metadata;
  1048. elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
  1049. return false;
  1050. }
  1051. /**
  1052. * Changes the style class of the element given by id.
  1053. */
  1054. function buttonClick(id, classname) {
  1055. $(id).toggleClass(classname); // add the class to the clicked element
  1056. }
  1057. /**
  1058. * Shows a message to the user.
  1059. *
  1060. * @param titleString the title of the message
  1061. * @param messageString the text of the message
  1062. */
  1063. function openMessageDialog(titleString, messageString) {
  1064. $.prompt(messageString,
  1065. {
  1066. title: titleString,
  1067. persistent: false
  1068. }
  1069. );
  1070. }
  1071. /**
  1072. * Locks / unlocks the room.
  1073. */
  1074. function lockRoom(lock) {
  1075. if (lock)
  1076. connection.emuc.lockRoom(sharedKey);
  1077. else
  1078. connection.emuc.lockRoom('');
  1079. Toolbar.updateLockButton();
  1080. }
  1081. /**
  1082. * Sets the shared key.
  1083. */
  1084. function setSharedKey(sKey) {
  1085. sharedKey = sKey;
  1086. }
  1087. function setRecordingToken(token) {
  1088. recordingToken = token;
  1089. }
  1090. /**
  1091. * Updates the room invite url.
  1092. */
  1093. function updateRoomUrl(newRoomUrl) {
  1094. roomUrl = newRoomUrl;
  1095. // If the invite dialog has been already opened we update the information.
  1096. var inviteLink = document.getElementById('inviteLinkRef');
  1097. if (inviteLink) {
  1098. inviteLink.value = roomUrl;
  1099. inviteLink.select();
  1100. document.getElementById('jqi_state0_buttonInvite').disabled = false;
  1101. }
  1102. }
  1103. /**
  1104. * Warning to the user that the conference window is about to be closed.
  1105. */
  1106. function closePageWarning() {
  1107. if (focus !== null)
  1108. return "You are the owner of this conference call and"
  1109. + " you are about to end it.";
  1110. else
  1111. return "You are about to leave this conversation.";
  1112. }
  1113. /**
  1114. * Resizes and repositions videos in full screen mode.
  1115. */
  1116. $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
  1117. function () {
  1118. VideoLayout.resizeLargeVideoContainer();
  1119. VideoLayout.positionLarge();
  1120. isFullScreen = document.fullScreen ||
  1121. document.mozFullScreen ||
  1122. document.webkitIsFullScreen;
  1123. if (isFullScreen) {
  1124. setView("fullscreen");
  1125. }
  1126. else {
  1127. setView("default");
  1128. }
  1129. }
  1130. );
  1131. /**
  1132. * Sets the current view.
  1133. */
  1134. function setView(viewName) {
  1135. // if (viewName == "fullscreen") {
  1136. // document.getElementById('videolayout_fullscreen').disabled = false;
  1137. // document.getElementById('videolayout_default').disabled = true;
  1138. // }
  1139. // else {
  1140. // document.getElementById('videolayout_default').disabled = false;
  1141. // document.getElementById('videolayout_fullscreen').disabled = true;
  1142. // }
  1143. }
  1144. function hangUp() {
  1145. if (connection && connection.connected) {
  1146. // ensure signout
  1147. $.ajax({
  1148. type: 'POST',
  1149. url: config.bosh,
  1150. async: false,
  1151. cache: false,
  1152. contentType: 'application/xml',
  1153. data: "<body rid='" + (connection.rid || connection._proto.rid) + "' xmlns='http://jabber.org/protocol/httpbind' sid='" + (connection.sid || connection._proto.sid) + "' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>",
  1154. success: function (data) {
  1155. console.log('signed out');
  1156. console.log(data);
  1157. },
  1158. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1159. console.log('signout error', textStatus + ' (' + errorThrown + ')');
  1160. }
  1161. });
  1162. }
  1163. disposeConference(true);
  1164. }
  1165. $(document).bind('fatalError.jingle',
  1166. function (event, session, error)
  1167. {
  1168. sessionTerminated = true;
  1169. connection.emuc.doLeave();
  1170. openMessageDialog( "Sorry",
  1171. "Your browser version is too old. Please update and try again...");
  1172. }
  1173. );
  1174. function callSipButtonClicked()
  1175. {
  1176. $.prompt('<h2>Enter SIP number</h2>' +
  1177. '<input id="sipNumber" type="text" value="" autofocus>',
  1178. {
  1179. persistent: false,
  1180. buttons: { "Dial": true, "Cancel": false},
  1181. defaultButton: 2,
  1182. loaded: function (event)
  1183. {
  1184. document.getElementById('sipNumber').focus();
  1185. },
  1186. submit: function (e, v, m, f)
  1187. {
  1188. if (v)
  1189. {
  1190. var numberInput = document.getElementById('sipNumber');
  1191. if (numberInput.value && numberInput.value.length)
  1192. {
  1193. connection.rayo.dial(
  1194. numberInput.value, 'fromnumber', roomName);
  1195. }
  1196. }
  1197. }
  1198. }
  1199. );
  1200. }
  1201. function hangup() {
  1202. disposeConference();
  1203. sessionTerminated = true;
  1204. connection.emuc.doLeave();
  1205. var buttons = {};
  1206. if(config.enableWelcomePage)
  1207. {
  1208. setTimeout(function()
  1209. {
  1210. window.localStorage.welcomePageDisabled = false;
  1211. window.location.pathname = "/";
  1212. }, 10000);
  1213. }
  1214. $.prompt("Session Terminated",
  1215. {
  1216. title: "You hang up the call",
  1217. persistent: true,
  1218. buttons: {},
  1219. closeText: ''
  1220. }
  1221. );
  1222. }