[Brian's page isn't operating as smoothly as he would like relative to the user setting states with a checkbox and then jmol.js not recognizing those states later. That is, jmol.js doesn't allow for dynamic definitions of its scripts.]

Miguel wrote:

Brian, to solve this, you will have to "override" some of
the functions of jmol.js.


[snip]



Miguel probably won't like this solution because it isn't
general and probably violates some good programming
practice.


You are absolutely right about that!


:)

What Brian is doing is very typical: set some state. Go to a new model. Want the state to automatically carry over. It's a reasonable request, and it's a saveState()/restoreState() issue. Reminds me of the PostScript gsave/grestore.


One solution would be to allow an event handler in the user form interface:

function jmolSetHandleEvent(myfunction){
        _jmol.eventHandler={
                func: myfunction,
                applet:null,
                script:"",
                controlname:"",
                controlvalue:"",
                controlindex:""
        }
}

This would initialize a handler function that would be called after each of the scripts is delivered to an applet by jmolScript():

function jmolScript(script, targetSuffix) {
  if (script) {
    var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");
    var applet = _jmolFindApplet(target);
    if (applet)
      applet.script(script);
    else
      alert("could not find applet " + target);
    if (_jmol.eventHandler) {
                _jmol.eventHandler.script=script
                _jmol.eventHandler.applet=applet
                _jmol.eventHandler.func()
    }
  }
}

[.controlname, .controlvalue, .controlindex would be set by the appropriate interface code prior to its calling jmolScript()]

When the user pushes a button, clicks a link, hits a radio button, checks a box, etc. the JavaScript application can catch that action and respond to it.



This may not work if the user reloads the page, because the
checkbox will remain checked,


Do you know of any mechanism I can use to reset these things to initial
values when a page is reloaded ... sure seems like a browser bug to me,
but almost all browsers do it this way.


yes:

<body onload=document.info.reset()>
<form name=info>
<input type=checkbox>testing
</form>
</body>

[note that if it were <input type=checkbox checked>, then reset() would check the box, not uncheck it.]



and you would have to have an
initial function test that, which isn't being done. But
since these checkboxes are not being assigned names (Miguel,
I think that's an omission--you should be assigning all HTML
elements ids or names--) you can't just test it initially.


You are right.

and these names should be user-selectable, since the user might want to check their state or change their settings.




Also, I note that you are not including <form> tags around
this. That's important for some browsers. Good practice is
to make sure those inputs are within a <form> </form> region.


True.


Miguel


-- 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




------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ Jmol-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to