Kaynağa Gözat

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

j8
yanas 9 yıl önce
ebeveyn
işleme
27d509332a

+ 3
- 1
interface_config.js Dosyayı Görüntüle

@@ -27,5 +27,7 @@ var interfaceConfig = {
27 27
     /**
28 28
      * Whether to only show the filmstrip (and hide the toolbar).
29 29
      */
30
-    filmStripOnly: false
30
+    filmStripOnly: false,
31
+    RANDOM_AVATAR_URL_PREFIX: false,
32
+    RANDOM_AVATAR_URL_SUFFIX: false
31 33
 };

+ 6
- 6
modules/UI/UI.js Dosyayı Görüntüle

@@ -219,7 +219,8 @@ function bindEvents() {
219 219
 
220 220
     // Resize and reposition videos in full screen mode.
221 221
     $(document).on(
222
-        'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
222
+        'webkitfullscreenchange mozfullscreenchange fullscreenchange',
223
+        onResize
223 224
     );
224 225
 
225 226
     $(window).resize(onResize);
@@ -570,13 +571,12 @@ UI.setUserAvatar = function (id, email) {
570 571
     // update avatar
571 572
     Avatar.setUserAvatar(id, email);
572 573
 
573
-    var thumbUrl = Avatar.getThumbUrl(id);
574
-    var contactListUrl = Avatar.getContactListUrl(id);
574
+    var avatarUrl = Avatar.getAvatarUrl(id);
575 575
 
576
-    VideoLayout.changeUserAvatar(id, thumbUrl);
577
-    ContactList.changeUserAvatar(id, contactListUrl);
576
+    VideoLayout.changeUserAvatar(id, avatarUrl);
577
+    ContactList.changeUserAvatar(id, avatarUrl);
578 578
     if (APP.conference.isLocalId(id)) {
579
-        SettingsMenu.changeAvatar(thumbUrl);
579
+        SettingsMenu.changeAvatar(avatarUrl);
580 580
     }
581 581
 };
582 582
 

+ 29
- 44
modules/UI/avatar/Avatar.js Dosyayı Görüntüle

@@ -16,62 +16,47 @@ var Avatar = {
16 16
             }
17 17
             users[id] = email;
18 18
         }
19
-        var thumbUrl = this.getThumbUrl(id);
20
-        var contactListUrl = this.getContactListUrl(id);
19
+        var avatarUrl = this.getAvatarUrl(id);
21 20
     },
22 21
     /**
23
-     * Returns image URL for the avatar to be displayed on large video area
24
-     * where current dominant speaker is presented.
25
-     * @param id id of the user for whom we want to obtain avatar URL
22
+     * Returns the URL of the image for the avatar of a particular user,
23
+     + identified by its jid
24
+     * @param jid
26 25
      */
27
-    getDominantSpeakerUrl: function (id) {
28
-        return this.getGravatarUrl(id, 100);
29
-    },
30
-    /**
31
-     * Returns image URL for the avatar to be displayed on small video thumbnail
32
-     * @param id id of the user for whom we want to obtain avatar URL
33
-     */
34
-    getThumbUrl: function (id) {
35
-        return this.getGravatarUrl(id, 100);
36
-    },
37
-    /**
38
-     * Returns the URL for the avatar to be displayed as contactlist item
39
-     * @param id id of the user for whom we want to obtain avatar URL
40
-     */
41
-    getContactListUrl: function (id) {
42
-        return this.getGravatarUrl(id, 30);
43
-    },
44
-    getGravatarUrl: function (id, size) {
45
-        if (!id) {
46
-            console.error("Get gravatar - id is undefined");
47
-            return null;
48
-        }
26
+    getAvatarUrl: function (jid) {
27
+        if (config.disableThirdPartyRequests) {
28
+            return 'images/avatar2.png';
29
+        } else {
30
+            if (!jid) {
31
+                console.error("Get avatar - jid is undefined");
32
+                    return null;
33
+            }
34
+            var id = users[jid];
49 35
 
50
-        // Default to using gravatar.
51
-        var urlPref = 'https://www.gravatar.com/avatar/';
52
-        var urlSuf = "?d=wavatar&size=" + (size || "30");
36
+            // If the ID looks like an email, we'll use gravatar.
37
+            // Otherwise, it's a random avatar, and we'll use the configured
38
+            // URL.
39
+            var random = !id || id.indexOf('@') < 0;
40
+
41
+            if (!id) {
42
+                console.warn(
43
+                "No avatar stored yet for " + jid + " - using JID as ID");
44
+                id = jid;
45
+            }
46
+            id = MD5.hexdigest(id.trim().toLowerCase());
53 47
 
54
-        // If we have a real email we will use it for the gravatar and we'll
55
-        // use the pre-configured URL if any. Otherwise, it's a random avatar.
56
-        var email = users[id];
57
-        if (email && email.indexOf('@')) {
58
-            id = email;
48
+            // Default to using gravatar.
49
+            var urlPref = 'https://www.gravatar.com/avatar/';
50
+            var urlSuf = "?d=wavatar&size=100";
59 51
 
60
-            if (interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
52
+            if (random && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
61 53
                 urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
62 54
                 urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
63 55
             }
64
-        }
65 56
 
66
-        if (!config.disableThirdPartyRequests) {
67
-            return urlPref +
68
-                MD5.hexdigest(id.trim().toLowerCase()) +
69
-                urlSuf;
70
-        } else {
71
-            return 'images/avatar2.png';
57
+            return urlPref + id + urlSuf;
72 58
         }
73 59
     }
74
-
75 60
 };
76 61
 
77 62
 

+ 3
- 3
modules/UI/side_pannels/contactlist/ContactList.js Dosyayı Görüntüle

@@ -33,7 +33,7 @@ function updateNumberOfParticipants(delta) {
33 33
 function createAvatar(jid) {
34 34
     let avatar = document.createElement('img');
35 35
     avatar.className = "icon-avatar avatar";
36
-    avatar.src = Avatar.getContactListUrl(jid);
36
+    avatar.src = Avatar.getAvatarUrl(jid);
37 37
 
38 38
     return avatar;
39 39
 }
@@ -162,11 +162,11 @@ var ContactList = {
162 162
         }
163 163
     },
164 164
 
165
-    changeUserAvatar (id, contactListUrl) {
165
+    changeUserAvatar (id, avatarUrl) {
166 166
         // set the avatar in the contact list
167 167
         let contact = $(`#${id}>img`);
168 168
         if (contact.length > 0) {
169
-            contact.attr('src', contactListUrl);
169
+            contact.attr('src', avatarUrl);
170 170
         }
171 171
     }
172 172
 };

+ 2
- 2
modules/UI/side_pannels/settings/SettingsMenu.js Dosyayı Görüntüle

@@ -92,7 +92,7 @@ export default {
92 92
         }
93 93
     },
94 94
 
95
-    changeAvatar (thumbUrl) {
96
-        $('#avatar').attr('src', thumbUrl);
95
+    changeAvatar (avatarUrl) {
96
+        $('#avatar').attr('src', avatarUrl);
97 97
     }
98 98
 };

+ 4
- 3
modules/UI/videolayout/LargeVideo.js Dosyayı Görüntüle

@@ -370,7 +370,8 @@ export default class LargeVideoManager {
370 370
 
371 371
     resize (animate) {
372 372
         // resize all containers
373
-        Object.keys(this.containers).forEach(type => this.resizeContainer(type, animate));
373
+        Object.keys(this.containers)
374
+            .forEach(type => this.resizeContainer(type, animate));
374 375
 
375 376
         this.$container.animate({
376 377
             width: this.width,
@@ -393,8 +394,8 @@ export default class LargeVideoManager {
393 394
     /**
394 395
      * Updates the src of the dominant speaker avatar
395 396
      */
396
-    updateAvatar (thumbUrl) {
397
-        $("#dominantSpeakerAvatar").attr('src', thumbUrl);
397
+    updateAvatar (avatarUrl) {
398
+        $("#dominantSpeakerAvatar").attr('src', avatarUrl);
398 399
     }
399 400
 
400 401
     showAvatar (show) {

+ 4
- 4
modules/UI/videolayout/SmallVideo.js Dosyayı Görüntüle

@@ -338,7 +338,7 @@ SmallVideo.prototype.updateView = function () {
338 338
     if (!this.hasAvatar) {
339 339
         if (this.id) {
340 340
             // Init avatar
341
-            this.avatarChanged(Avatar.getThumbUrl(this.id));
341
+            this.avatarChanged(Avatar.getAvatarUrl(this.id));
342 342
         } else {
343 343
             console.error("Unable to init avatar - no id", this);
344 344
             return;
@@ -380,20 +380,20 @@ SmallVideo.prototype.updateView = function () {
380 380
     }
381 381
 };
382 382
 
383
-SmallVideo.prototype.avatarChanged = function (thumbUrl) {
383
+SmallVideo.prototype.avatarChanged = function (avatarUrl) {
384 384
     var thumbnail = $('#' + this.videoSpanId);
385 385
     var avatar = $('#avatar_' + this.id);
386 386
     this.hasAvatar = true;
387 387
 
388 388
     // set the avatar in the thumbnail
389 389
     if (avatar && avatar.length > 0) {
390
-        avatar[0].src = thumbUrl;
390
+        avatar[0].src = avatarUrl;
391 391
     } else {
392 392
         if (thumbnail && thumbnail.length > 0) {
393 393
             avatar = document.createElement('img');
394 394
             avatar.id = 'avatar_' + this.id;
395 395
             avatar.className = 'userAvatar';
396
-            avatar.src = thumbUrl;
396
+            avatar.src = avatarUrl;
397 397
             thumbnail.append(avatar);
398 398
         }
399 399
     }

+ 4
- 4
modules/UI/videolayout/VideoLayout.js Dosyayı Görüntüle

@@ -910,17 +910,17 @@ var VideoLayout = {
910 910
         }
911 911
     },
912 912
 
913
-    changeUserAvatar (id, thumbUrl) {
913
+    changeUserAvatar (id, avatarUrl) {
914 914
         var smallVideo = VideoLayout.getSmallVideo(id);
915 915
         if (smallVideo) {
916
-            smallVideo.avatarChanged(thumbUrl);
916
+            smallVideo.avatarChanged(avatarUrl);
917 917
         } else {
918 918
             console.warn(
919 919
                 "Missed avatar update - no small video yet for " + id
920 920
             );
921 921
         }
922 922
         if (this.isCurrentlyOnLarge(id)) {
923
-            largeVideo.updateAvatar(thumbUrl);
923
+            largeVideo.updateAvatar(avatarUrl);
924 924
         }
925 925
     },
926 926
 
@@ -988,7 +988,7 @@ var VideoLayout = {
988 988
                     oldSmallVideo && oldSmallVideo.updateView();
989 989
 
990 990
                     // change the avatar url on large
991
-                    largeVideo.updateAvatar(Avatar.getThumbUrl(smallVideo.id));
991
+                    largeVideo.updateAvatar(Avatar.getAvatarUrl(smallVideo.id));
992 992
                     // show the avatar on large if needed
993 993
                     largeVideo.showAvatar(smallVideo.stream.isMuted());
994 994
                 });

Loading…
İptal
Kaydet