Angel Herraez escreveu:
On 1 Apr 2007 at 20:09, Sérgio Ceroni da Silva wrote:
Has anyone ever (thought about || felt the need for) adding support for
the HTML <optgroup> tag in jmolMenu() function?
Hi Sérgio
I have tried and it's easy to do with a small change in Jmol.js. Here is the mechanism, in
case someone has any suggestions; if people find it OK, I will update Jmol.js soon.
Add the optgroup entry as one more element in the array that is passed to Jmol.js. The
first element must be the caption for the group ("label" in HTML syntax); the second and
(optional) third elements are not used.
Then add an extra element to signal the end of the group.
Example:
jmolMenu([
[null, ".... select ....", "selected"],
["color cpk", "- CPK pattern", null],
["#optgroup", "... Color by: ....", null],
["color structure", "- structure", null],
["color chain", "- chain", null],
["color group", "- group", null],
["#optgroupEnd", null, null],
["#optgroup", ".... Other colors: ....", null],
["color formalcharge", "- electric charge", null],
["color amino", "- amino-acids", null],
["color shapely", "- nucleotides", null],
["#optgroupEnd", null, null]
]);
The key words are "#optgroup" and "#optgroupEnd" which must be used exactly so.
Great!
The only other way I could achieve this was by replacing this code:
jmolMenu([
[null, "||||||| select |||||||", "selected"],
["color cpk", "- CPK", null],
[null, "||||||| Color by: |||||||", null],
["color structure", "- structures", null],
["color chain", "- chains", null],
["color group", "- groups", null],
["color formalcharge", "- charge", null],
["color amino", "- amino acids", null],
["color shapely", "- nucleotides", null]
]);
with this one:
jmolHtml("<span><select
onchange=\"jmolScript(this.options[this.selectedIndex].value);\">");
jmolHtml("<option selected>||||||| select |||||||</option>");
jmolHtml("<optgroup label=\"CPK\">");
jmolHtml(" <option value=\"color cpk\">CPK</option>");
jmolHtml("</optgroup>");
jmolHtml("<optgroup label=\"Color by:\">");
jmolHtml(" <option value=\"color structure\">structures</option>");
jmolHtml(" <option value=\"color chain\">chains</option>");
jmolHtml(" <option value=\"color group\">groups</option>");
jmolHtml(" <option value=\"color formalcharge\">charge</option>");
jmolHtml(" <option value=\"color amino\">amino acids</option>");
jmolHtml(" <option value=\"color shapely\">nucleotides</option>");
jmolHtml("</optgroup>");
jmolHtml("</select></span>");
I had to use onchange inside <select> because IE doesn't support onclick
inside <option> (when is MS going to follow international standards?!).
Obviously your solution is much better.
Many thanks
Sérgio
--
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
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users