Browse Source

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 years ago
parent
commit
27d509332a

+ 3
- 1
interface_config.js View File

27
     /**
27
     /**
28
      * Whether to only show the filmstrip (and hide the toolbar).
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 View File

219
 
219
 
220
     // Resize and reposition videos in full screen mode.
220
     // Resize and reposition videos in full screen mode.
221
     $(document).on(
221
     $(document).on(
222
-        'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
222
+        'webkitfullscreenchange mozfullscreenchange fullscreenchange',
223
+        onResize
223
     );
224
     );
224
 
225
 
225
     $(window).resize(onResize);
226
     $(window).resize(onResize);
570
     // update avatar
571
     // update avatar
571
     Avatar.setUserAvatar(id, email);
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
     if (APP.conference.isLocalId(id)) {
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 View File

16
             }
16
             }
17
             users[id] = email;
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
                 urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
53
                 urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
62
                 urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
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 View File

33
 function createAvatar(jid) {
33
 function createAvatar(jid) {
34
     let avatar = document.createElement('img');
34
     let avatar = document.createElement('img');
35
     avatar.className = "icon-avatar avatar";
35
     avatar.className = "icon-avatar avatar";
36
-    avatar.src = Avatar.getContactListUrl(jid);
36
+    avatar.src = Avatar.getAvatarUrl(jid);
37
 
37
 
38
     return avatar;
38
     return avatar;
39
 }
39
 }
162
         }
162
         }
163
     },
163
     },
164
 
164
 
165
-    changeUserAvatar (id, contactListUrl) {
165
+    changeUserAvatar (id, avatarUrl) {
166
         // set the avatar in the contact list
166
         // set the avatar in the contact list
167
         let contact = $(`#${id}>img`);
167
         let contact = $(`#${id}>img`);
168
         if (contact.length > 0) {
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 View File

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 View File

370
 
370
 
371
     resize (animate) {
371
     resize (animate) {
372
         // resize all containers
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
         this.$container.animate({
376
         this.$container.animate({
376
             width: this.width,
377
             width: this.width,
393
     /**
394
     /**
394
      * Updates the src of the dominant speaker avatar
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
     showAvatar (show) {
401
     showAvatar (show) {

+ 4
- 4
modules/UI/videolayout/SmallVideo.js View File

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

+ 4
- 4
modules/UI/videolayout/VideoLayout.js View File

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

Loading…
Cancel
Save