Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /* jshint -W117 */
  2. /* application specific logic */
  3. var connection = null;
  4. var focus = null;
  5. var RTC;
  6. var RTCPeerConnection = null;
  7. var nickname = null;
  8. var sharedKey = '';
  9. var roomUrl = null;
  10. var ssrc2jid = {};
  11. window.onbeforeunload = closePageWarning;
  12. function init() {
  13. RTC = setupRTC();
  14. if (RTC === null) {
  15. window.location.href = 'webrtcrequired.html';
  16. return;
  17. } else if (RTC.browser != 'chrome') {
  18. window.location.href = 'chromeonly.html';
  19. return;
  20. }
  21. RTCPeerconnection = TraceablePeerConnection;
  22. connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
  23. if (connection.disco) {
  24. // for chrome, add multistream cap
  25. }
  26. connection.jingle.pc_constraints = RTC.pc_constraints;
  27. var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
  28. connection.connect(jid, document.getElementById('password').value, function (status) {
  29. if (status == Strophe.Status.CONNECTED) {
  30. console.log('connected');
  31. if (RTC.browser == 'firefox') {
  32. getUserMediaWithConstraints(['audio']);
  33. } else {
  34. getUserMediaWithConstraints(['audio', 'video'], '360');
  35. }
  36. document.getElementById('connect').disabled = true;
  37. } else {
  38. console.log('status', status);
  39. }
  40. });
  41. }
  42. function doJoin() {
  43. var roomnode = null;
  44. var path = window.location.pathname;
  45. var roomjid;
  46. // determinde the room node from the url
  47. // TODO: just the roomnode or the whole bare jid?
  48. if (config.getroomnode && typeof config.getroomnode === 'function') {
  49. // custom function might be responsible for doing the pushstate
  50. roomnode = config.getroomnode(path);
  51. } else {
  52. /* fall back to default strategy
  53. * this is making assumptions about how the URL->room mapping happens.
  54. * It currently assumes deployment at root, with a rewrite like the
  55. * following one (for nginx):
  56. location ~ ^/([a-zA-Z0-9]+)$ {
  57. rewrite ^/(.*)$ / break;
  58. }
  59. */
  60. if (path.length > 1) {
  61. roomnode = path.substr(1).toLowerCase();
  62. } else {
  63. roomnode = Math.random().toString(36).substr(2, 20);
  64. window.history.pushState('VideoChat', 'Room: ' + roomnode, window.location.pathname + roomnode);
  65. }
  66. }
  67. roomjid = roomnode + '@' + config.hosts.muc;
  68. if (config.useNicks) {
  69. var nick = window.prompt('Your nickname (optional)');
  70. if (nick) {
  71. roomjid += '/' + nick;
  72. } else {
  73. roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
  74. }
  75. } else {
  76. roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
  77. }
  78. connection.emuc.doJoin(roomjid);
  79. }
  80. $(document).bind('mediaready.jingle', function (event, stream) {
  81. connection.jingle.localStream = stream;
  82. RTC.attachMediaStream($('#localVideo'), stream);
  83. document.getElementById('localVideo').muted = true;
  84. document.getElementById('localVideo').autoplay = true;
  85. document.getElementById('localVideo').volume = 0;
  86. document.getElementById('largeVideo').volume = 0;
  87. document.getElementById('largeVideo').src = document.getElementById('localVideo').src;
  88. doJoin();
  89. });
  90. $(document).bind('mediafailure.jingle', function () {
  91. // FIXME
  92. });
  93. $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
  94. function waitForRemoteVideo(selector, sid) {
  95. var sess = connection.jingle.sessions[sid];
  96. videoTracks = data.stream.getVideoTracks();
  97. if (videoTracks.length === 0 || selector[0].currentTime > 0) {
  98. RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
  99. $(document).trigger('callactive.jingle', [selector, sid]);
  100. console.log('waitForremotevideo', sess.peerconnection.iceConnectionState, sess.peerconnection.signalingState);
  101. } else {
  102. setTimeout(function () { waitForRemoteVideo(selector, sid); }, 100);
  103. }
  104. }
  105. var sess = connection.jingle.sessions[sid];
  106. // look up an associated JID for a stream id
  107. if (data.stream.id.indexOf('mixedmslabel') == -1) {
  108. var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
  109. ssrclines = ssrclines.filter(function (line) {
  110. return line.indexOf('mslabel:' + data.stream.label) != -1;
  111. })
  112. if (ssrclines.length) {
  113. thessrc = ssrclines[0].substring(7).split(' ')[0];
  114. // ok to overwrite the one from focus? might save work in colibri.js
  115. console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
  116. if (ssrc2jid[thessrc]) {
  117. data.peerjid = ssrc2jid[thessrc];
  118. }
  119. }
  120. }
  121. var vid = document.createElement('video');
  122. // FIXME: the span should not be created here but on muc join
  123. var span = document.createElement('span');
  124. if (data.peerjid) {
  125. // FIXME: how to name this span? data.peerjid is not set for jingle clients
  126. span.id = 'participant_' + Strophe.getResourceFromJid(data.peerjid);
  127. } else if (data.stream.id != 'mixedmslabel') {
  128. console.warn('can not associate stream', data.stream.id, 'with a participant');
  129. }
  130. span.className = 'videocontainer';
  131. var id = 'remoteVideo_' + sid + '_' + data.stream.id;
  132. vid.id = id;
  133. vid.autoplay = true;
  134. vid.oncontextmenu = function () { return false; };
  135. var remotes = document.getElementById('remoteVideos');
  136. span.appendChild(vid);
  137. if (id.indexOf('mixedmslabel') != -1) {
  138. $(span).hide();
  139. }
  140. remotes.appendChild(span);
  141. var sel = $('#' + id);
  142. sel.hide();
  143. RTC.attachMediaStream(sel, data.stream);
  144. waitForRemoteVideo(sel, sid);
  145. data.stream.onended = function () {
  146. console.log('stream ended', this.id);
  147. var src = $('#' + id).attr('src');
  148. // FIXME: likewise, the parent should not be removed here
  149. // but on MUC part
  150. $('#' + id).parent().remove();
  151. if (src === $('#largeVideo').attr('src')) {
  152. // this is currently displayed as large
  153. // pick the last visible video in the row
  154. // if nobody else is left, this picks the local video
  155. var pick = $('#remoteVideos>span:visible:last>video').get(0);
  156. // mute if localvideo
  157. document.getElementById('largeVideo').volume = pick.volume;
  158. document.getElementById('largeVideo').src = pick.src;
  159. }
  160. resizeThumbnails();
  161. };
  162. sel.click(
  163. function () {
  164. console.log('hover in', $(this).attr('src'));
  165. var newSrc = $(this).attr('src');
  166. if ($('#largeVideo').attr('src') != newSrc) {
  167. document.getElementById('largeVideo').volume = 1;
  168. $('#largeVideo').fadeOut(300, function () {
  169. $(this).attr('src', newSrc);
  170. $(this).fadeIn(300);
  171. });
  172. }
  173. }
  174. );
  175. });
  176. $(document).bind('callincoming.jingle', function (event, sid) {
  177. var sess = connection.jingle.sessions[sid];
  178. // TODO: check affiliation and/or role
  179. console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
  180. sess.sendAnswer();
  181. sess.accept();
  182. });
  183. $(document).bind('callactive.jingle', function (event, videoelem, sid) {
  184. if (videoelem.attr('id').indexOf('mixedmslabel') == -1) {
  185. // ignore mixedmslabela0 and v0
  186. videoelem.show();
  187. resizeThumbnails();
  188. document.getElementById('largeVideo').volume = 1;
  189. $('#largeVideo').attr('src', videoelem.attr('src'));
  190. }
  191. });
  192. $(document).bind('callterminated.jingle', function (event, sid, reason) {
  193. // FIXME
  194. });
  195. $(document).bind('setLocalDescription.jingle', function (event, sid) {
  196. // put our ssrcs into presence so other clients can identify our stream
  197. var sess = connection.jingle.sessions[sid];
  198. var newssrcs = {};
  199. var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
  200. localSDP.media.forEach(function (media) {
  201. var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
  202. var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
  203. // assumes a single local ssrc
  204. newssrcs[type] = ssrc;
  205. });
  206. console.log('new ssrcs', newssrcs);
  207. // just blast off presence for everything -- TODO: optimize
  208. var pres = $pres({to: connection.emuc.myroomjid });
  209. pres.c('x', {xmlns: 'http://jabber.org/protocol/muc'}).up();
  210. pres.c('media', {xmlns: 'http://estos.de/ns/mjs'});
  211. Object.keys(newssrcs).forEach(function (mtype) {
  212. pres.c('source', {type: mtype, ssrc: newssrcs[mtype]}).up();
  213. });
  214. pres.up();
  215. connection.send(pres);
  216. });
  217. $(document).bind('joined.muc', function (event, jid, info) {
  218. updateRoomUrl(window.location.href);
  219. // Once we've joined the muc show the toolbar
  220. showToolbar();
  221. if (Object.keys(connection.emuc.members).length < 1) {
  222. focus = new ColibriFocus(connection, config.hosts.bridge);
  223. }
  224. });
  225. $(document).bind('entered.muc', function (event, jid, info, pres) {
  226. console.log('entered', jid, info);
  227. console.log(focus);
  228. if (focus !== null) {
  229. // FIXME: this should prepare the video
  230. if (focus.confid === null) {
  231. console.log('make new conference with', jid);
  232. focus.makeConference(Object.keys(connection.emuc.members));
  233. } else {
  234. console.log('invite', jid, 'into conference');
  235. focus.addNewParticipant(jid);
  236. }
  237. }
  238. else if (sharedKey) {
  239. updateLockButton();
  240. }
  241. $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
  242. //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
  243. ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
  244. });
  245. });
  246. $(document).bind('left.muc', function (event, jid) {
  247. console.log('left', jid);
  248. connection.jingle.terminateByJid(jid);
  249. // FIXME: this should actually hide the video already for a nicer UX
  250. if (Object.keys(connection.emuc.members).length === 0) {
  251. console.log('everyone left');
  252. if (focus !== null) {
  253. // FIXME: closing the connection is a hack to avoid some
  254. // problemswith reinit
  255. if (focus.peerconnection !== null) {
  256. focus.peerconnection.close();
  257. }
  258. focus = new ColibriFocus(connection, config.hosts.bridge);
  259. }
  260. }
  261. });
  262. $(document).bind('passwordrequired.muc', function (event, jid) {
  263. console.log('on password required', jid);
  264. $.prompt('<h2>Password required</h2>' +
  265. '<input id="lockKey" type="text" placeholder="shared key" autofocus>',
  266. {
  267. persistent: true,
  268. buttons: { "Ok": true , "Cancel": false},
  269. defaultButton: 1,
  270. loaded: function(event) {
  271. document.getElementById('lockKey').focus();
  272. },
  273. submit: function(e,v,m,f){
  274. if(v)
  275. {
  276. var lockKey = document.getElementById('lockKey');
  277. if (lockKey.value != null)
  278. {
  279. setSharedKey(lockKey);
  280. connection.emuc.doJoin(jid, lockKey.value);
  281. }
  282. }
  283. }
  284. });
  285. $(document).bind('presence.muc', function (event, jid, info, pres) {
  286. $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
  287. //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
  288. ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
  289. });
  290. });
  291. function toggleVideo() {
  292. if (!(connection && connection.jingle.localStream)) return;
  293. for (var idx = 0; idx < connection.jingle.localStream.getVideoTracks().length; idx++) {
  294. connection.jingle.localStream.getVideoTracks()[idx].enabled = !connection.jingle.localStream.getVideoTracks()[idx].enabled;
  295. }
  296. }
  297. function toggleAudio() {
  298. if (!(connection && connection.jingle.localStream)) return;
  299. for (var idx = 0; idx < connection.jingle.localStream.getAudioTracks().length; idx++) {
  300. connection.jingle.localStream.getAudioTracks()[idx].enabled = !connection.jingle.localStream.getAudioTracks()[idx].enabled;
  301. }
  302. }
  303. function resizeLarge() {
  304. var availableHeight = window.innerHeight;
  305. var chatspaceWidth = $('#chatspace').width();
  306. var numvids = $('#remoteVideos>video:visible').length;
  307. if (numvids < 5)
  308. availableHeight -= 100; // min thumbnail height for up to 4 videos
  309. else
  310. availableHeight -= 50; // min thumbnail height for more than 5 videos
  311. availableHeight -= 79; // padding + link ontop
  312. var availableWidth = window.innerWidth - chatspaceWidth;
  313. var aspectRatio = 16.0 / 9.0;
  314. if (availableHeight < availableWidth / aspectRatio) {
  315. availableWidth = Math.floor(availableHeight * aspectRatio);
  316. }
  317. if (availableWidth < 0 || availableHeight < 0) return;
  318. $('#largeVideo').parent().width(availableWidth);
  319. $('#largeVideo').parent().height(availableWidth / aspectRatio);
  320. resizeThumbnails();
  321. }
  322. function resizeThumbnails() {
  323. // Calculate the available height, which is the inner window height minus 39px for the header
  324. // minus 4px for the delimiter lines on the top and bottom of the large video,
  325. // minus the 36px space inside the remoteVideos container used for highlighting shadow.
  326. var availableHeight = window.innerHeight - $('#largeVideo').height() - 79;
  327. var numvids = $('#remoteVideos>span:visible').length;
  328. // Remove the 1px borders arround videos.
  329. var availableWinWidth = $('#remoteVideos').width() - 2 * numvids;
  330. var availableWidth = availableWinWidth / numvids;
  331. var aspectRatio = 16.0 / 9.0;
  332. var maxHeight = Math.min(160, availableHeight);
  333. availableHeight = Math.min(maxHeight, availableWidth / aspectRatio);
  334. if (availableHeight < availableWidth / aspectRatio) {
  335. availableWidth = Math.floor(availableHeight * aspectRatio);
  336. }
  337. // size videos so that while keeping AR and max height, we have a nice fit
  338. $('#remoteVideos').height(availableHeight+26); // add the 2*18px-padding-top border used for highlighting shadow.
  339. $('#remoteVideos>span').width(availableWidth);
  340. $('#remoteVideos>span').height(availableHeight);
  341. }
  342. $(document).ready(function () {
  343. $('#nickinput').keydown(function(event) {
  344. if (event.keyCode == 13) {
  345. event.preventDefault();
  346. var val = this.value;
  347. this.value = '';
  348. if (!nickname) {
  349. nickname = val;
  350. $('#nickname').css({visibility:"hidden"});
  351. $('#chatconversation').css({visibility:'visible'});
  352. $('#usermsg').css({visibility:'visible'});
  353. $('#usermsg').focus();
  354. return;
  355. }
  356. }
  357. });
  358. $('#usermsg').keydown(function(event) {
  359. if (event.keyCode == 13) {
  360. event.preventDefault();
  361. var message = this.value;
  362. $('#usermsg').val('').trigger('autosize.resize');
  363. this.focus();
  364. connection.emuc.sendMessage(message, nickname);
  365. }
  366. });
  367. $('#usermsg').autosize();
  368. resizeLarge();
  369. $(window).resize(function () {
  370. resizeLarge();
  371. });
  372. if (!$('#settings').is(':visible')) {
  373. console.log('init');
  374. init();
  375. } else {
  376. loginInfo.onsubmit = function (e) {
  377. if (e.preventDefault) e.preventDefault();
  378. $('#settings').hide();
  379. init();
  380. };
  381. }
  382. });
  383. $(window).bind('beforeunload', function () {
  384. if (connection && connection.connected) {
  385. // ensure signout
  386. $.ajax({
  387. type: 'POST',
  388. url: config.bosh,
  389. async: false,
  390. cache: false,
  391. contentType: 'application/xml',
  392. 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>",
  393. success: function (data) {
  394. console.log('signed out');
  395. console.log(data);
  396. },
  397. error: function (XMLHttpRequest, textStatus, errorThrown) {
  398. console.log('signout error', textStatus + ' (' + errorThrown + ')');
  399. }
  400. });
  401. }
  402. });
  403. function dump(elem, filename) {
  404. console.log("ELEMENT", elem);
  405. elem = elem.parentNode;
  406. elem.download = filename || 'xmpplog.json';
  407. elem.href = 'data:application/json;charset=utf-8,\n';
  408. var data = {};
  409. data.time = new Date();
  410. data.url = window.location.href;
  411. data.ua = navigator.userAgent;
  412. if (connection.logger) {
  413. data.xmpp = connection.logger.log;
  414. }
  415. if (connection.jingle) {
  416. Object.keys(connection.jingle.sessions).forEach(function (sid) {
  417. var session = connection.jingle.sessions[sid];
  418. if (session.peerconnection && session.peerconnection.updateLog) {
  419. // FIXME: should probably be a .dump call
  420. data["jingle_" + session.sid] = session.peerconnection.updateLog;
  421. }
  422. });
  423. }
  424. elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
  425. return false;
  426. }
  427. /*
  428. * Appends the given message to the chat conversation.
  429. */
  430. // <a onclick="dump(event.target);">my download button</a>
  431. function dump(elem, filename){
  432. elem = elem.parentNode;
  433. elem.download = filename || 'xmpplog.json';
  434. elem.href = 'data:application/json;charset=utf-8,\n';
  435. var data = {};
  436. data.time = new Date();
  437. data.url = window.location.href;
  438. data.ua = navigator.userAgent;
  439. if (connection.logger) {
  440. data.xmpp = connection.logger.log;
  441. }
  442. if (connection.jingle) {
  443. Object.keys(connection.jingle.sessions).forEach(function (sid) {
  444. var session = connection.jingle.sessions[sid];
  445. if (session.peerconnection && session.peerconnection.updateLog) {
  446. // FIXME: should probably be a .dump call
  447. data["jingle_" + session.sid] = session.peerconnection.updateLog;
  448. }
  449. });
  450. }
  451. elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
  452. return false;
  453. }
  454. /*
  455. * Appends the given message to the chat conversation.
  456. */
  457. function updateChatConversation(nick, message)
  458. {
  459. var divClassName = '';
  460. if (nickname == nick)
  461. divClassName = "localuser";
  462. else
  463. divClassName = "remoteuser";
  464. $('#chatconversation').append('<div class="' + divClassName + '"><b>' + nick + ': </b>' + message + '</div>');
  465. $('#chatconversation').animate({ scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
  466. }
  467. /*
  468. * Changes the style class of the element given by id.
  469. */
  470. function buttonClick(id, classname) {
  471. $(id).toggleClass(classname); // add the class to the clicked element
  472. }
  473. /*
  474. * Opens the lock room dialog.
  475. */
  476. function openLockDialog() {
  477. // Only the focus is able to set a shared key.
  478. if (focus == null) {
  479. if (sharedKey)
  480. $.prompt("This conversation is currently protected by a shared secret key.",
  481. {
  482. title: "Secrect key",
  483. persistent: false
  484. });
  485. else
  486. $.prompt("This conversation isn't currently protected by a secret key. Only the owner of the conference could set a shared key.",
  487. {
  488. title: "Secrect key",
  489. persistent: false
  490. });
  491. }
  492. else {
  493. if (sharedKey)
  494. $.prompt("Are you sure you would like to remove your secret key?",
  495. {
  496. title: "Remove secrect key",
  497. persistent: false,
  498. buttons: { "Remove": true, "Cancel": false},
  499. defaultButton: 1,
  500. submit: function(e,v,m,f){
  501. if(v)
  502. {
  503. setSharedKey('');
  504. lockRoom(false);
  505. }
  506. }
  507. });
  508. else
  509. $.prompt('<h2>Set a secrect key to lock your room</h2>' +
  510. '<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
  511. {
  512. persistent: false,
  513. buttons: { "Save": true , "Cancel": false},
  514. defaultButton: 1,
  515. loaded: function(event) {
  516. document.getElementById('lockKey').focus();
  517. },
  518. submit: function(e,v,m,f){
  519. if(v)
  520. {
  521. var lockKey = document.getElementById('lockKey');
  522. if (lockKey.value)
  523. {
  524. setSharedKey(lockKey.value);
  525. lockRoom(true);
  526. }
  527. }
  528. }
  529. });
  530. }
  531. }
  532. /*
  533. * Opens the invite link dialog.
  534. */
  535. function openLinkDialog() {
  536. $.prompt('<input id="inviteLinkRef" type="text" value="' + roomUrl + '" onclick="this.select();">',
  537. {
  538. title: "Share this link with everyone you want to invite",
  539. persistent: false,
  540. buttons: { "Cancel": false},
  541. loaded: function(event) {
  542. document.getElementById('inviteLinkRef').select();
  543. }
  544. });
  545. }
  546. /*
  547. * Locks / unlocks the room.
  548. */
  549. function lockRoom(lock) {
  550. console.log("LOCK", sharedKey);
  551. if (lock)
  552. connection.emuc.lockRoom(sharedKey);
  553. else
  554. connection.emuc.lockRoom('');
  555. updateLockButton();
  556. }
  557. /*
  558. * Sets the shared key.
  559. */
  560. function setSharedKey(sKey) {
  561. sharedKey = sKey;
  562. }
  563. /*
  564. * Updates the lock button state.
  565. */
  566. function updateLockButton() {
  567. buttonClick("#lockIcon", "fa fa-unlock fa-lg fa fa-lock fa-lg");
  568. }
  569. /*
  570. * Opens / closes the chat area.
  571. */
  572. function openChat() {
  573. var chatspace = $('#chatspace');
  574. var videospace = $('#videospace');
  575. var chatspaceWidth = chatspace.width();
  576. if (chatspace.css("opacity") == 1) {
  577. chatspace.animate({opacity: 0}, "fast");
  578. chatspace.animate({width: 0}, "slow");
  579. videospace.animate({right: 0, width:"100%"}, "slow");
  580. }
  581. else {
  582. chatspace.animate({width:"20%"}, "slow");
  583. chatspace.animate({opacity: 1}, "slow");
  584. videospace.animate({right:chatspaceWidth, width:"80%"}, "slow");
  585. }
  586. // Request the focus in the nickname field or the chat input field.
  587. if ($('#nickinput').is(':visible'))
  588. $('#nickinput').focus();
  589. else
  590. $('#usermsg').focus();
  591. }
  592. /*
  593. * Shows the call main toolbar.
  594. */
  595. function showToolbar() {
  596. $('#toolbar').css({visibility:"visible"});
  597. }
  598. /*
  599. * Updates the room invite url.
  600. */
  601. function updateRoomUrl(newRoomUrl) {
  602. roomUrl = newRoomUrl;
  603. }
  604. /*
  605. * Warning to the user that the conference window is about to be closed.
  606. */
  607. function closePageWarning() {
  608. if (focus != null)
  609. return "You are the owner of this conference call and you are about to end it.";
  610. else
  611. return "You are about to leave this conversation.";
  612. }