Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Commit

Permalink
Use core color generator if available
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Apr 16, 2016
1 parent 8b58e2a commit 29753d6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js/views/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ define(function(require) {

Handlebars.registerHelper('accountColor', function(account) {
var hash = md5(account);
var maxRange = parseInt('ffffffffffffffffffffffffffffffff', 16);
var hue = parseInt(hash, 16) / maxRange * 256;
return new Handlebars.SafeString('hsl(' + hue + ', 90%, 65%)');
if (typeof hash.toHsl === 'function') {
var hsl = hash.toHsl();
return new Handlebars.SafeString('hsl(' + hsl[0] + ', ' + hsl[1] + '%, ' + hsl[2] + '%)');
} else {
var maxRange = parseInt('ffffffffffffffffffffffffffffffff', 16);
var hue = parseInt(hash, 16) / maxRange * 256;
return new Handlebars.SafeString('hsl(' + hue + ', 90%, 65%)');
}
});

Handlebars.registerHelper('printAddressList', function(addressList) {
Expand Down

0 comments on commit 29753d6

Please sign in to comment.