2015-05-06 23:45:28 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gravatar - A service to build the Gravatar URL for an email address
|
|
|
|
* @memberof SOGo.Common
|
|
|
|
* @param {string} email
|
|
|
|
* @param {number} [size] - the size of the image
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
function Gravatar() {
|
|
|
|
return function(email, size) {
|
2015-08-06 22:18:10 +02:00
|
|
|
var x, y, hash, s = size;
|
2015-05-06 23:45:28 +02:00
|
|
|
if (!email) {
|
|
|
|
return '';
|
|
|
|
}
|
2015-08-06 22:18:10 +02:00
|
|
|
x = email.indexOf('<');
|
|
|
|
if (x >= 0) {
|
|
|
|
y = email.indexOf('>', x);
|
|
|
|
if (y > x)
|
|
|
|
email = email.substring(x+1,y);
|
|
|
|
}
|
2015-05-06 23:45:28 +02:00
|
|
|
if (!size) {
|
|
|
|
s = 48; // default to 48 pixels
|
|
|
|
}
|
|
|
|
hash = email.md5();
|
|
|
|
|
2015-07-24 22:14:53 +02:00
|
|
|
// return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=identicon';
|
2015-05-06 23:45:28 +02:00
|
|
|
return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=wavatar';
|
2015-07-24 22:14:53 +02:00
|
|
|
};
|
2015-05-06 23:45:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('SOGo.Common')
|
|
|
|
.factory('Gravatar', Gravatar);
|
|
|
|
})();
|