diff options
author | Sarven Capadisli <csarven@controlyourself.ca> | 2009-08-04 12:26:29 -0400 |
---|---|---|
committer | Sarven Capadisli <csarven@controlyourself.ca> | 2009-08-04 12:26:29 -0400 |
commit | 557e214ce968079362b73f36f2f2bd1bcbec61a7 (patch) | |
tree | c2233d80161dbbcaa64f50407b0445fb4438ffd1 /js | |
parent | cb2f668ff6a0d0208732837dca1f2cb7a16e814f (diff) |
Refactored rgb2hex
Diffstat (limited to 'js')
-rw-r--r-- | js/userdesign.go.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/js/userdesign.go.js b/js/userdesign.go.js index 4416dc8ae..c53569bea 100644 --- a/js/userdesign.go.js +++ b/js/userdesign.go.js @@ -30,11 +30,11 @@ $(document).ready(function() { /* rgb2hex written by R0bb13 <robertorebollo@gmail.com> */ function rgb2hex(rgb) { rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); - function hex(x) { - hexDigits = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"); - return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16]; - } - return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); + return '#' + dec2hex(rgb[1]) + dec2hex(rgb[2]) + dec2hex(rgb[3]); + } + function dec2hex(x) { + hexDigits = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + return isNaN(x) ? '00' : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16]; } function UpdateColors(S) { |