1
0
mirror of https://github.com/bitwarden/web synced 2025-12-10 21:33:16 +00:00

move some values to constants for better sharing

This commit is contained in:
Kyle Spearrin
2017-04-10 18:55:18 -04:00
parent 58df3e692b
commit cf22ea2b78
9 changed files with 70 additions and 58 deletions

View File

@@ -5,13 +5,14 @@ angular
.directive('letterAvatar', function () {
// ref: http://stackoverflow.com/a/16348977/1090359
function stringToColor(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
var hash = 0,
i = 0;
for (i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var color = '#';
for (var i = 0; i < 3; i++) {
for (i = 0; i < 3; i++) {
var value = (hash >> (i * 8)) & 0xFF;
color += ('00' + value.toString(16)).substr(-2);
}