rgb(r,g,b) values are now displayed as hex colors, too

This commit is contained in:
Tobi Schäfer 2002-08-03 22:58:33 +00:00
parent 35022eaa92
commit 9201c41331
4 changed files with 37 additions and 17 deletions

View file

@ -15,6 +15,19 @@ function openColorPicker(name, text) {
var cpWindow = window.open("<% root.url path="colorpicker" %>?name=" + name + "&text=" + text, "cpWindow", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,width=350,height=320");
}
function setColorPreview(name, color) {
document.getElementById('cp2_' + name).style.backgroundColor = color;
function normalizeColor(c) {
if (c && c.length == 6) {
var nonhex = new RegExp("[^0-9,a-f]");
nonhex.ignoreCase = true;
var found = c.match(nonhex);
if (!found) {
// color-string contains just hex-characters, so we prefix it with '#'
return("#" + c);
}
}
return(c);
}
function setColorPreview(name, color) {
document.getElementById('cp2_' + name).style.backgroundColor = normalizeColor(color);
}