Skip to content

Commit

Permalink
Added support for 3 character hex code entry
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-whitehead committed Mar 31, 2015
1 parent 7cba888 commit c69c6cb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions js/colpick.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,22 @@ For usage and examples: colpick.com/plugin
},
fixHex = function (hex) {
var len = 6 - hex.length;
if (len > 0) {
var o = [];
for (var i=0; i<len; i++) {
o.push('0');
if (len == 3) {
var e = [];
for (var j = 0; j < len; j++) {
e.push(hex[j]);
e.push(hex[j]);
}
hex = e.join('');
} else {
if (len > 0) {
var o = [];
for (var i = 0; i < len; i++) {
o.push('0');
}
o.push(hex);
hex = o.join('');
}
o.push(hex);
hex = o.join('');
}
return hex;
},
Expand Down

0 comments on commit c69c6cb

Please sign in to comment.