-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
1 lines (1 loc) · 819 Bytes
/
index.js
1
!function(){var e;e=function(){function e(e){return null!==e.match(/^([a-zA-Z]|\s|,|\.)+$/)}var t=["#78c06e","#f65e8d","#f6bf26","#f65e5e","#5e97f6","#9a89b9","#a1887f","#ff943e","#5ec9f6","#3bc2b5","#5c6bc0","#bd84cd","#6bb5ce","#c5cb63","#ff8e6b","#78919d"],c=t.length,n={getAvatar:function(e,t){var t=this._getShowName(e||t),c=this._getColor(t);return{name:t,color:c}},_getShowName:function(t){var c=t||"",n=[];return e(c)?(c=c.replace(/,|\./g," ").replace(/\s+/g," "),n=c.split(" "),1===n.length?c.slice(0,2):n[0].slice(0,1)+n[1].slice(0,1)):c.replace(/,|\.|\s+/g,"").slice(-2)},_getColor:function(e){var n=0;for(char in e)n+=e.charCodeAt(char);return t[n%c]}};return n}(),"object"==typeof exports?module.exports=e:"function"==typeof define&&(define.cmd||define.amd)?define(function(){return e}):this.ddAvatar=e}();