Bob,

Thanks! 

Should I be embarrassed?, but I just starting playing with html and
javascript last week -  my attentions so far have been tuned a bit
more to learning biophysics (grad student). But I do think I
understand your point (and later tim's), and I will play around a
little more this weekend. The odds that I will post again are quite
high, I think!

On 4/22/05, Bob Hanson <[EMAIL PROTECTED]> wrote:
> 
> 
> Shelley Green wrote:
> 
>  > Hi,
>  >
>  > Is it possible to not only pass a script along ot jmol using the
>  > jmolradiogroup, but can you nest other javascripts and/or items like
>  > "onclick= h$1 href etc"?
> 
> no
> 
>  >
>  > I would like to use a series of radio buttons to send rasmol scripts to
>  > jmol. The radio buttons would be logically connected to a landau plot - and
>  > the once the user selects one of the values, I would "swap" out the plot
>  > with one that matched this jmol state -
>  > http://www.shetlandstudios.com/grant/Sc.html Here, the "load" uses a swap
>  > image on mouse click.
> 
> great idea!
> 
>  >
>  > I've tried nesting this into the jmolradiogroup with no success. My next
>  > thought is to use something like <a
>  > href="javascript:document.jmol.script(approp script here), along with
>  > the swap image code.
>  >
> 
> this won't work because the applet name won't be "jmol".
> 
> Shelley, I think you've hit the limitation of jmol.js. It's just not 
> constructed
> to be that flexible. The easiest solution is to adapt jmol.js to your needs. I
> recommend just after your
> 
>    <script language="JavaScript" type="text/JavaScript" src="../jmol/Jmol.js">
> 
> tag (by the way, you are missing those language and type parameters) add an
> ADAPTED definition of the jmol.js function that writes the radio button. 
> Because
> this is not the actual function you call (note the _ at the beginning) you
> cannot just change its parameters. What I've done in this code is introduce a
> call another function you will write, doRadioScript().
> 
>    <script language="JavaScript" type="text/JavaScript">
> function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName) {
>    ++_jmol.radioCount;
>    if (groupName == undefined || groupName == null)
>      groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1);
>    if (!script)
>      return "";
>    if (labelHtml == undefined || labelHtml == null)
>      labelHtml = script.substring(0, 32);
>    if (! separatorHtml)
>      separatorHtml = "";
>    var scriptIndex = _jmolAddScript(script);
>    return "<input name='" + groupName +
> //CHANGE IS IN NEXT LINE
> //WAS:   "' type='radio' onClick='_jmolClick(" +
> /*NOW:*/ "' type='radio' onClick='doRadioScript("+scriptIndex+");_jmolClick(" 
> +
>           scriptIndex + _jmol.targetText +
>           ");return true;' onMouseover='_jmolMouseOver(" +
>           scriptIndex +
>           ");return true;' onMouseout='_jmolMouseOut()' " +
>          (isChecked ? "checked " : "") + _jmol.radioCssText + "/>" +
>           labelHtml + separatorHtml;
> }
> 
> function doRadioScript(index){
>         var s=_jmol.scripts[index]
> ...
> }
> 
>    </script>
> 
> Can you see what that is doing? You can now do whatever you want from
> information in that local s variable in doRadioScript(), which now contains 
> your
> script.
> 
> OK, now the problem is to know what to do with that script. If these are 
> simple
> scripts, can you know from the script itself what to do about the images? If
> not, here's an idea:
> 
> function doRadioScript(index){
>         var s=_jmol.scripts[index]
>         var cmd=s.split("#")[1]
>         if(cmd)eval(cmd)
> }
> 
> That is, you put whatever you want to execute in the script itself, just as 
> part
> of the comment, after the #. For example:
> 
> select *;color red #doSwapImage("test",3)
> 
> Jmol will ignore your extra stuff, because it is after the # sign.
> 
> doRadioScript(index) will load s with the full script. The split("#")[1]
> function strips off the stuff before the #, leaving only 
> doSwapImage("test",3),
> which is then evaluated.
> 
> The point is, you don't have to abandon jmol.js, but you do have to adapt it a
> bit. This would be my (first attempt at a) solution.
> 
> Bob Hanson
> 
> --
> Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107
> Professor of Chemistry, St. Olaf College 1520 St. Olaf Ave., Northfield, MN 
> 55057
> mailto:[EMAIL PROTECTED] http://www.stolaf.edu/people/hansonr
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to