You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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