Updated rgb2hex() to handle IE. It turns out that jQuery is giving hex
to IE and RGB to Firefox, Opera, Safari. Fun.
This commit is contained in:
parent
6c3149334c
commit
70ef9d89fa
@ -27,11 +27,12 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rgb2hex written by R0bb13 <robertorebollo@gmail.com> */
|
|
||||||
function rgb2hex(rgb) {
|
function rgb2hex(rgb) {
|
||||||
|
if (rgb.slice(0,1) == '#') { return rgb; }
|
||||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||||
return '#' + dec2hex(rgb[1]) + dec2hex(rgb[2]) + dec2hex(rgb[3]);
|
return '#' + dec2hex(rgb[1]) + dec2hex(rgb[2]) + dec2hex(rgb[3]);
|
||||||
}
|
}
|
||||||
|
/* dec2hex written by R0bb13 <robertorebollo@gmail.com> */
|
||||||
function dec2hex(x) {
|
function dec2hex(x) {
|
||||||
hexDigits = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
|
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 isNaN(x) ? '00' : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
|
||||||
|
Loading…
Reference in New Issue
Block a user