gravatar.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This module depends on the google CryptoJS library, you can load it by adding:
  2. // <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
  3. // to your page
  4. angular.module('Gravatar', [])
  5. .provider('$gravatar', function() {
  6. var avatarSize = 80; // Default size
  7. var avatarUrl = "http://www.gravatar.com/avatar/";
  8. this.setSize = function(size) {
  9. avatarSize = size;
  10. }
  11. this.$get = function(){
  12. return {
  13. generate: function(email){
  14. return avatarUrl + CryptoJS.MD5(email) + "?size=" + avatarSize.toString()
  15. }
  16. }
  17. }
  18. });
  19. /*
  20. These two are exactly the same. The above provider adds the `this.setSize` function for configuration
  21. */
  22. // angular.module('NoteWrangler').factory('GravatarService', function() {
  23. // var avatarSize = 80; // Default size
  24. // var avatarUrl = "http://www.gravatar.com/avatar/";
  25. //
  26. // return {
  27. // generate: function(email){
  28. // return avatarUrl + CryptoJS.MD5(email); + "?size=" + avatarSize.toString()
  29. // }
  30. // }
  31. // });
  32. // angular.module('NoteWrangler').provider('GravatarService', function gravatarServiceProvider() {
  33. // var avatarSize = 80; // Default size
  34. // var avatarUrl = "http://www.gravatar.com/avatar/";
  35. //
  36. // this.$get = function(){
  37. // return {
  38. // generate: function(email){
  39. // return avatarUrl + CryptoJS.MD5(email); + "?size=" + avatarSize.toString()
  40. // }
  41. // }
  42. // }
  43. // });