Hi everybody
I've adapted a simple javascript color picker to use in my pages. I find
it very useful for changing molecule and applet background color. It
generates a horizontal table (5 rows x 25 columns) or a vertical one
(25 rows x 5 columns). Some parameters like cell width and height are
hard-coded, but could be easily changed to variables. If there is enough
interest it could be improved and included as a function in Jmol.js.
Just a thought.
Best wishes
Sérgio
//////////////////////////////////////////////////////////////////
// Molecule color picker
//////////////////////////////////////////////////////////////////
HexMoleculeColor = new Array('00', '66', '99', 'cc', 'ff');
TableMoleculeColorPicker = '<table border="0" cellpadding="0"
cellspacing="0">';
for (greenMoleculeColorValue = 0; greenMoleculeColorValue < 5;
greenMoleculeColorValue++){
//Use the next line for a HORIZONTAL table
TableMoleculeColorPicker += '<tr>';
for (redMoleculeColorValue = 0; redMoleculeColorValue < 5;
redMoleculeColorValue++) {
//Use the next line for a VERTICAL table
//TableMoleculeColorPicker += '<tr>';
for (blueMoleculeColorValue = 0; blueMoleculeColorValue < 5;
blueMoleculeColorValue++) {
FinalHexMoleculeColor = '#' +
HexMoleculeColor[redMoleculeColorValue] +
HexMoleculeColor[greenMoleculeColorValue] +
HexMoleculeColor[blueMoleculeColorValue];
FinalJmolHexMoleculeColor = '[x' +
HexMoleculeColor[redMoleculeColorValue] +
HexMoleculeColor[greenMoleculeColorValue] +
HexMoleculeColor[blueMoleculeColorValue] + ']';
TableMoleculeColorPicker += '<td width="6" height="8"
align="center"'
+ ' style="' + 'background-color:' +
FinalHexMoleculeColor + ';"'
+ ' title="click on the desired color"'
+ ' onclick="javascript:jmolScript(\'color ' +
FinalJmolHexMoleculeColor + '\');"'
+ ' onmouseover="window.status=\'click on the desired
color\';"'
+ ' onmouseout="window.status=\' \';"'
+ '></td>';
}
//Use the next line for a VERTICAL table
//TableMoleculeColorPicker += '</tr>';
}
//Use the next line for a HORIZONTAL table
TableMoleculeColorPicker += '</tr>';
}
TableMoleculeColorPicker += '</table>';
document.write(TableMoleculeColorPicker);
//////////////////////////////////////////////////////////////////
// Applet background color picker
//////////////////////////////////////////////////////////////////
HexAppBgColor = new Array('00', '66', '99', 'cc', 'ff');
TableAppBgColorPicker = '<table border="0" cellpadding="0"
cellspacing="0">';
TableAppBgColorPicker += '<tr><td colspan="25" align="center"'
+ ' onclick="javascript:jmolScript(\'background [xD9EBFF]\');"'
+ ' style="{background-color:white; border-style:solid;
border-width:1px;}"'
+ ' title="click here for the page standard color">default<td></tr>';
TableAppBgColorPicker += '<tr><td colspan="25"><td></tr>';
for (greenAppBgColorValue = 0; greenAppBgColorValue < 5;
greenAppBgColorValue++){
//Use the next line for a HORIZONTAL table
TableAppBgColorPicker += '<tr>';
for (redAppBgColorValue = 0; redAppBgColorValue < 5;
redAppBgColorValue++) {
//Use the next line for a VERTICAL table
//TableAppBgColorPicker += '<tr>';
for (blueAppBgColorValue = 0; blueAppBgColorValue < 5;
blueAppBgColorValue++) {
FinalHexAppBgColor = '#' + HexAppBgColor[redAppBgColorValue]
+ HexAppBgColor[greenAppBgColorValue] + HexAppBgColor[blueAppBgColorValue];
FinalJmolHexAppBgColor = '[x' +
HexAppBgColor[redAppBgColorValue] + HexAppBgColor[greenAppBgColorValue]
+ HexAppBgColor[blueAppBgColorValue] + ']';
TableAppBgColorPicker += '<td width="6" height="8"
align="center"'
+ ' style="' + 'background-color:' + FinalHexAppBgColor
+ ';"'
+ ' title="click on the desired color"'
+ ' onclick="javascript:jmolScript(\'background ' +
FinalJmolHexAppBgColor + '\');"'
+ ' onmouseover="window.status=\'click on the desired
color\';"'
+ ' onmouseout="window.status=\' \';"'
+ '></td>';
}
//Use the next line for a VERTICAL table
//TableAppBgColorPicker += '</tr>';
}
//Use the next line for a HORIZONTAL table
TableAppBgColorPicker += '</tr>';
}
TableAppBgColorPicker += '</table>';
document.write(TableAppBgColorPicker);
--
Dr. Sérgio Ceroni da Silva
Centro de Biotecnologia, Universidade Federal do Rio Grande do Sul
Av. Bento Gonçalves, 9500 - Prédio 43421 - Campus do Vale - Caixa Postal 15005
Porto Alegre, RS - Brasil - 91501-970
==================================================
Tel.: +55 (51) 3316-6091 | Fax: +55 (51) 3316-7309
http://www6.ufrgs.br/bioquimica
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users