diff --git a/app.js b/app.js index 8ec96f66a..a9005e47a 100644 --- a/app.js +++ b/app.js @@ -104,6 +104,8 @@ function connect(jid, password) { connection.emuc.addDisplayNameToPresence(nickname); } + connection.emuc.addUserIdToPresence(UserId.getUID()); + if (connection.disco) { // for chrome, add multistream cap } @@ -685,7 +687,7 @@ $(document).bind('joined.muc', function (event, jid, info) { VideoLayout.showFocusIndicator(); // Add myself to the contact list. - ContactList.addContact(jid); + ContactList.addContact(jid, UserId.getUID()); // Once we've joined the muc show the toolbar ToolbarToggler.showToolbar(); @@ -701,7 +703,8 @@ $(document).bind('entered.muc', function (event, jid, info, pres) { console.log('is focus? ' + (focus ? 'true' : 'false')); // Add Peer's container - VideoLayout.ensurePeerContainerExists(jid); + var userId = $(pres).find(">userID").text(); + VideoLayout.ensurePeerContainerExists(jid, userId); if (focus !== null) { // FIXME: this should prepare the video @@ -1566,3 +1569,8 @@ function hangup() { ); } + +$(document).on('videomuted.muc', function(event, who, value) { + var videoTag = $("#participant_" + Strophe.getResourceFromJid(who)).find('>video'); + videoTag.css("display", value === "false" ? 'inline-block' : 'none'); +}); diff --git a/contact_list.js b/contact_list.js index 9bb330110..00d180c52 100644 --- a/contact_list.js +++ b/contact_list.js @@ -17,13 +17,13 @@ var ContactList = (function (my) { * * @param peerJid the peerJid corresponding to the contact */ - my.ensureAddContact = function(peerJid) { + my.ensureAddContact = function(peerJid, userId) { var resourceJid = Strophe.getResourceFromJid(peerJid); var contact = $('#contactlist>ul>li[id="' + resourceJid + '"]'); if (!contact || contact.length <= 0) - ContactList.addContact(peerJid); + ContactList.addContact(peerJid, userId); }; /** @@ -31,7 +31,7 @@ var ContactList = (function (my) { * * @param peerJid the jid of the contact to add */ - my.addContact = function(peerJid) { + my.addContact = function(peerJid, userId) { var resourceJid = Strophe.getResourceFromJid(peerJid); var contactlist = $('#contactlist>ul'); @@ -39,7 +39,7 @@ var ContactList = (function (my) { var newContact = document.createElement('li'); newContact.id = resourceJid; - newContact.appendChild(createAvatar()); + newContact.appendChild(createAvatar(userId)); newContact.appendChild(createDisplayNameParagraph("Participant")); var clElement = contactlist.get(0); @@ -196,12 +196,13 @@ var ContactList = (function (my) { * * @return the newly created avatar element */ - function createAvatar() { - var avatar = document.createElement('i'); + function createAvatar(userId) { + var avatar = document.createElement('img'); avatar.className = "icon-avatar avatar"; + avatar.src = "https://www.gravatar.com/avatar/" + userId + "?d=retro&size=30"; return avatar; - }; + } /** * Creates the display name paragraph. diff --git a/css/videolayout_default.css b/css/videolayout_default.css index 2f6015578..255bee304 100644 --- a/css/videolayout_default.css +++ b/css/videolayout_default.css @@ -34,7 +34,9 @@ #remoteVideos .videocontainer { display: inline-block; - background-image:url(../images/avatar1.png); + background-color: black; + background-repeat: no-repeat; + background-position: 45; background-size: contain; border-radius:8px; border: 2px solid #212425; @@ -113,10 +115,6 @@ height: 100%; } -.dominantspeaker { - background: #000 !important; -} - #etherpad, #presentation { text-align: center; diff --git a/index.html b/index.html index 51371c65d..08a908847 100644 --- a/index.html +++ b/index.html @@ -30,14 +30,14 @@ - + - + @@ -47,7 +47,7 @@ - + @@ -58,9 +58,10 @@ + - + diff --git a/muc.js b/muc.js index 4eb1b8909..dac5a883d 100644 --- a/muc.js +++ b/muc.js @@ -301,6 +301,10 @@ Strophe.addConnectionPlugin('emuc', { pres.c('bridgeIsDown').up(); } + if(this.presMap['userId']) { + pres.c('userId').t(this.presMap['userId']).up(); + } + if (this.presMap['displayName']) { // XEP-0172 pres.c('nick', {xmlns: 'http://jabber.org/protocol/nick'}) @@ -409,5 +413,8 @@ Strophe.addConnectionPlugin('emuc', { }, addBridgeIsDownToPresence: function() { this.presMap['bridgeIsDown'] = true; + }, + addUserIdToPresence: function(userId) { + this.presMap['userId'] = userId; } }); diff --git a/user_id.js b/user_id.js new file mode 100644 index 000000000..92bffc598 --- /dev/null +++ b/user_id.js @@ -0,0 +1,37 @@ +var UserId = (function(my) { + var userId; + + function supportsLocalStorage() { + try { + return 'localStorage' in window && window.localStorage !== null; + } catch (e) { + console.log("localstorage is not supported"); + return false; + } + } + + function generateUniqueId() { + function _p8() { + var p = (Math.random().toString(16)+"000000000").substr(2,8); + return p.substr(0,4) + p.substr(4,4); + } + return _p8() + _p8() + _p8() + _p8(); + } + + if(supportsLocalStorage()) { + if(!window.localStorage.meetJitsiId) { + window.localStorage.meetJitsiId = generateUniqueId(); + console.log("generated id", window.localStorage.meetJitsiId); + } + userId = window.localStorage.meetJitsiId; + } else { + console.log("local storage is not supported"); + userId = generateUniqueId(); + } + + my.getUID = function() { + return userId; + }; + + return my; +})(UserId || {}); diff --git a/videolayout.js b/videolayout.js index ca8a650ea..4a0887a9e 100644 --- a/videolayout.js +++ b/videolayout.js @@ -301,8 +301,8 @@ var VideoLayout = (function (my) { * @return Returns true if the peer container exists, * false - otherwise */ - my.ensurePeerContainerExists = function(peerJid) { - ContactList.ensureAddContact(peerJid); + my.ensurePeerContainerExists = function(peerJid, userId) { + ContactList.ensureAddContact(peerJid, userId); var resourceJid = Strophe.getResourceFromJid(peerJid); @@ -311,14 +311,17 @@ var VideoLayout = (function (my) { if ($('#' + videoSpanId).length > 0) { // If there's been a focus change, make sure we add focus related // interface!! - if (focus && $('#remote_popupmenu_' + resourceJid).length <= 0) - addRemoteVideoMenu( peerJid, - document.getElementById(videoSpanId)); + if (focus && $('#remote_popupmenu_' + resourceJid).length <= 0) { + addRemoteVideoMenu(peerJid, + document.getElementById(videoSpanId)); + } } else { - var container - = VideoLayout.addRemoteVideoContainer(peerJid, videoSpanId); - + var container = + VideoLayout.addRemoteVideoContainer(peerJid, videoSpanId, userId); + $(container).css('background-image', + "url('https://www.gravatar.com/avatar/" + userId + + "?d=retro&size=100')"); // Set default display name. setDisplayName(videoSpanId);