Merges Boris Grozev's commit from Dec 8, 2015, named: Uses a single avatar URL, allows to override gravatar with a custom URL. Commit: a2c41392
This commit is contained in:
parent
2af941d607
commit
27d509332a
|
@ -27,5 +27,7 @@ var interfaceConfig = {
|
||||||
/**
|
/**
|
||||||
* Whether to only show the filmstrip (and hide the toolbar).
|
* Whether to only show the filmstrip (and hide the toolbar).
|
||||||
*/
|
*/
|
||||||
filmStripOnly: false
|
filmStripOnly: false,
|
||||||
|
RANDOM_AVATAR_URL_PREFIX: false,
|
||||||
|
RANDOM_AVATAR_URL_SUFFIX: false
|
||||||
};
|
};
|
||||||
|
|
|
@ -219,7 +219,8 @@ function bindEvents() {
|
||||||
|
|
||||||
// Resize and reposition videos in full screen mode.
|
// Resize and reposition videos in full screen mode.
|
||||||
$(document).on(
|
$(document).on(
|
||||||
'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
|
'webkitfullscreenchange mozfullscreenchange fullscreenchange',
|
||||||
|
onResize
|
||||||
);
|
);
|
||||||
|
|
||||||
$(window).resize(onResize);
|
$(window).resize(onResize);
|
||||||
|
@ -570,13 +571,12 @@ UI.setUserAvatar = function (id, email) {
|
||||||
// update avatar
|
// update avatar
|
||||||
Avatar.setUserAvatar(id, email);
|
Avatar.setUserAvatar(id, email);
|
||||||
|
|
||||||
var thumbUrl = Avatar.getThumbUrl(id);
|
var avatarUrl = Avatar.getAvatarUrl(id);
|
||||||
var contactListUrl = Avatar.getContactListUrl(id);
|
|
||||||
|
|
||||||
VideoLayout.changeUserAvatar(id, thumbUrl);
|
VideoLayout.changeUserAvatar(id, avatarUrl);
|
||||||
ContactList.changeUserAvatar(id, contactListUrl);
|
ContactList.changeUserAvatar(id, avatarUrl);
|
||||||
if (APP.conference.isLocalId(id)) {
|
if (APP.conference.isLocalId(id)) {
|
||||||
SettingsMenu.changeAvatar(thumbUrl);
|
SettingsMenu.changeAvatar(avatarUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,62 +16,47 @@ var Avatar = {
|
||||||
}
|
}
|
||||||
users[id] = email;
|
users[id] = email;
|
||||||
}
|
}
|
||||||
var thumbUrl = this.getThumbUrl(id);
|
var avatarUrl = this.getAvatarUrl(id);
|
||||||
var contactListUrl = this.getContactListUrl(id);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns image URL for the avatar to be displayed on large video area
|
* Returns the URL of the image for the avatar of a particular user,
|
||||||
* where current dominant speaker is presented.
|
+ identified by its jid
|
||||||
* @param id id of the user for whom we want to obtain avatar URL
|
* @param jid
|
||||||
*/
|
*/
|
||||||
getDominantSpeakerUrl: function (id) {
|
getAvatarUrl: function (jid) {
|
||||||
return this.getGravatarUrl(id, 100);
|
if (config.disableThirdPartyRequests) {
|
||||||
},
|
return 'images/avatar2.png';
|
||||||
/**
|
} else {
|
||||||
* Returns image URL for the avatar to be displayed on small video thumbnail
|
if (!jid) {
|
||||||
* @param id id of the user for whom we want to obtain avatar URL
|
console.error("Get avatar - jid is undefined");
|
||||||
*/
|
return null;
|
||||||
getThumbUrl: function (id) {
|
}
|
||||||
return this.getGravatarUrl(id, 100);
|
var id = users[jid];
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Returns the URL for the avatar to be displayed as contactlist item
|
|
||||||
* @param id id of the user for whom we want to obtain avatar URL
|
|
||||||
*/
|
|
||||||
getContactListUrl: function (id) {
|
|
||||||
return this.getGravatarUrl(id, 30);
|
|
||||||
},
|
|
||||||
getGravatarUrl: function (id, size) {
|
|
||||||
if (!id) {
|
|
||||||
console.error("Get gravatar - id is undefined");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to using gravatar.
|
// If the ID looks like an email, we'll use gravatar.
|
||||||
var urlPref = 'https://www.gravatar.com/avatar/';
|
// Otherwise, it's a random avatar, and we'll use the configured
|
||||||
var urlSuf = "?d=wavatar&size=" + (size || "30");
|
// URL.
|
||||||
|
var random = !id || id.indexOf('@') < 0;
|
||||||
|
|
||||||
// If we have a real email we will use it for the gravatar and we'll
|
if (!id) {
|
||||||
// use the pre-configured URL if any. Otherwise, it's a random avatar.
|
console.warn(
|
||||||
var email = users[id];
|
"No avatar stored yet for " + jid + " - using JID as ID");
|
||||||
if (email && email.indexOf('@')) {
|
id = jid;
|
||||||
id = email;
|
}
|
||||||
|
id = MD5.hexdigest(id.trim().toLowerCase());
|
||||||
|
|
||||||
if (interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
|
// Default to using gravatar.
|
||||||
|
var urlPref = 'https://www.gravatar.com/avatar/';
|
||||||
|
var urlSuf = "?d=wavatar&size=100";
|
||||||
|
|
||||||
|
if (random && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
|
||||||
urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
|
urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
|
||||||
urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
|
urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.disableThirdPartyRequests) {
|
return urlPref + id + urlSuf;
|
||||||
return urlPref +
|
|
||||||
MD5.hexdigest(id.trim().toLowerCase()) +
|
|
||||||
urlSuf;
|
|
||||||
} else {
|
|
||||||
return 'images/avatar2.png';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ function updateNumberOfParticipants(delta) {
|
||||||
function createAvatar(jid) {
|
function createAvatar(jid) {
|
||||||
let avatar = document.createElement('img');
|
let avatar = document.createElement('img');
|
||||||
avatar.className = "icon-avatar avatar";
|
avatar.className = "icon-avatar avatar";
|
||||||
avatar.src = Avatar.getContactListUrl(jid);
|
avatar.src = Avatar.getAvatarUrl(jid);
|
||||||
|
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
|
@ -162,11 +162,11 @@ var ContactList = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeUserAvatar (id, contactListUrl) {
|
changeUserAvatar (id, avatarUrl) {
|
||||||
// set the avatar in the contact list
|
// set the avatar in the contact list
|
||||||
let contact = $(`#${id}>img`);
|
let contact = $(`#${id}>img`);
|
||||||
if (contact.length > 0) {
|
if (contact.length > 0) {
|
||||||
contact.attr('src', contactListUrl);
|
contact.attr('src', avatarUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,7 +92,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeAvatar (thumbUrl) {
|
changeAvatar (avatarUrl) {
|
||||||
$('#avatar').attr('src', thumbUrl);
|
$('#avatar').attr('src', avatarUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -370,7 +370,8 @@ export default class LargeVideoManager {
|
||||||
|
|
||||||
resize (animate) {
|
resize (animate) {
|
||||||
// resize all containers
|
// resize all containers
|
||||||
Object.keys(this.containers).forEach(type => this.resizeContainer(type, animate));
|
Object.keys(this.containers)
|
||||||
|
.forEach(type => this.resizeContainer(type, animate));
|
||||||
|
|
||||||
this.$container.animate({
|
this.$container.animate({
|
||||||
width: this.width,
|
width: this.width,
|
||||||
|
@ -393,8 +394,8 @@ export default class LargeVideoManager {
|
||||||
/**
|
/**
|
||||||
* Updates the src of the dominant speaker avatar
|
* Updates the src of the dominant speaker avatar
|
||||||
*/
|
*/
|
||||||
updateAvatar (thumbUrl) {
|
updateAvatar (avatarUrl) {
|
||||||
$("#dominantSpeakerAvatar").attr('src', thumbUrl);
|
$("#dominantSpeakerAvatar").attr('src', avatarUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
showAvatar (show) {
|
showAvatar (show) {
|
||||||
|
|
|
@ -338,7 +338,7 @@ SmallVideo.prototype.updateView = function () {
|
||||||
if (!this.hasAvatar) {
|
if (!this.hasAvatar) {
|
||||||
if (this.id) {
|
if (this.id) {
|
||||||
// Init avatar
|
// Init avatar
|
||||||
this.avatarChanged(Avatar.getThumbUrl(this.id));
|
this.avatarChanged(Avatar.getAvatarUrl(this.id));
|
||||||
} else {
|
} else {
|
||||||
console.error("Unable to init avatar - no id", this);
|
console.error("Unable to init avatar - no id", this);
|
||||||
return;
|
return;
|
||||||
|
@ -380,20 +380,20 @@ SmallVideo.prototype.updateView = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SmallVideo.prototype.avatarChanged = function (thumbUrl) {
|
SmallVideo.prototype.avatarChanged = function (avatarUrl) {
|
||||||
var thumbnail = $('#' + this.videoSpanId);
|
var thumbnail = $('#' + this.videoSpanId);
|
||||||
var avatar = $('#avatar_' + this.id);
|
var avatar = $('#avatar_' + this.id);
|
||||||
this.hasAvatar = true;
|
this.hasAvatar = true;
|
||||||
|
|
||||||
// set the avatar in the thumbnail
|
// set the avatar in the thumbnail
|
||||||
if (avatar && avatar.length > 0) {
|
if (avatar && avatar.length > 0) {
|
||||||
avatar[0].src = thumbUrl;
|
avatar[0].src = avatarUrl;
|
||||||
} else {
|
} else {
|
||||||
if (thumbnail && thumbnail.length > 0) {
|
if (thumbnail && thumbnail.length > 0) {
|
||||||
avatar = document.createElement('img');
|
avatar = document.createElement('img');
|
||||||
avatar.id = 'avatar_' + this.id;
|
avatar.id = 'avatar_' + this.id;
|
||||||
avatar.className = 'userAvatar';
|
avatar.className = 'userAvatar';
|
||||||
avatar.src = thumbUrl;
|
avatar.src = avatarUrl;
|
||||||
thumbnail.append(avatar);
|
thumbnail.append(avatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -910,17 +910,17 @@ var VideoLayout = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeUserAvatar (id, thumbUrl) {
|
changeUserAvatar (id, avatarUrl) {
|
||||||
var smallVideo = VideoLayout.getSmallVideo(id);
|
var smallVideo = VideoLayout.getSmallVideo(id);
|
||||||
if (smallVideo) {
|
if (smallVideo) {
|
||||||
smallVideo.avatarChanged(thumbUrl);
|
smallVideo.avatarChanged(avatarUrl);
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
"Missed avatar update - no small video yet for " + id
|
"Missed avatar update - no small video yet for " + id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.isCurrentlyOnLarge(id)) {
|
if (this.isCurrentlyOnLarge(id)) {
|
||||||
largeVideo.updateAvatar(thumbUrl);
|
largeVideo.updateAvatar(avatarUrl);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ var VideoLayout = {
|
||||||
oldSmallVideo && oldSmallVideo.updateView();
|
oldSmallVideo && oldSmallVideo.updateView();
|
||||||
|
|
||||||
// change the avatar url on large
|
// change the avatar url on large
|
||||||
largeVideo.updateAvatar(Avatar.getThumbUrl(smallVideo.id));
|
largeVideo.updateAvatar(Avatar.getAvatarUrl(smallVideo.id));
|
||||||
// show the avatar on large if needed
|
// show the avatar on large if needed
|
||||||
largeVideo.showAvatar(smallVideo.stream.isMuted());
|
largeVideo.showAvatar(smallVideo.stream.isMuted());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue