Select Color
function _CloseOnEsc() {
if (event.keyCode == 27) { window.close(); return; }
}
function Init() { // run on page load
document.body.onkeypress = _CloseOnEsc;
color = window.dialogArguments;
color = ValidateColor(color) || '000000';
View(color); // set default color
}
function View(color) { // preview color
document.all.ColorPreview.style.backgroundColor = '#' + color;
document.all.ColorHex.value = '#' + color;
}
function Set(string) { // select color
color = ValidateColor(string);
if (color == null) { alert("Invalid color code: " + string); } // invalid color
else { // valid color
View(color); // show selected color
window.returnValue = color; // set return value
window.close(); // close dialog
}
}
function ValidateColor(string) { // return valid color code
string = string || '';
string = string + "";
string = string.toUpperCase();
chars = '0123456789ABCDEF';
out = '';
for (i=0; i