User:Canadabonk/sandbox.js: Difference between revisions

Content deleted Content added
Canadabonk (talk | contribs)
No edit summary
Canadabonk (talk | contribs)
No edit summary
Tag: Reverted
Line 74:
if (color.match(/^rgb/)) {
rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
r = rgb[1].toString(16);
return (rgb && rgb.length === 4) ? "#" +
("0"g += parseInt(rgb[12],10).toString(16)).slice(-2) +;
("0"b += parseInt(rgb[23],10).toString(16)).slice(-2) +;
returnif (rgb && rgbr.length === 41) ?r = "#0" + r;
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
if (g.length == 1) g = "0" + g;
if (b.length == 1) b = "0" + b;
return "#" + r + g + b;
} else if (color.match(/^#.../)) {
return "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3];