Warwick wrote: > As part of our course development, we need a JavaScript to "reset" a JMol > applet. The use case is this > > (a) student loads a web page with default rendering of a molecule (eg > wireframe) > (b) student makes some changes using applet pop-up menu (eg changes render > scheme to ball and stick, does some rotations etc) > (c) student decides he/she is on the wrong track and wants to reset the > applet to its initial state, as on page load > > So what is the JavaScript to "reset" to initial state on page load? > > I tried document.applets['jmol'].init(), but this threw a security > excpetion. I was thinking that calling the applet's init method should > re-initialize the applet. > > Comments?
A couple of thoughts along different lines. Thought 1 ========= There is a *lot* of state in Jmol. And as we add more features, it will be difficult to clear it all. In other words, we are going to have bugs. The safest way to do a 'reset' is to reload the molecule. Q: Why not just reload the molecule into the applet? Thought 2 ========= This issue with startup and the initial state is complicated. Different people want different things from Jmol. Some people want wireframe only, others with to see sticks and balls. People like their balls to be different sizes ... Therefore, it seems to me that the most flexible way to handle this is to have a script on your server which sets the initial state for your molecules. That way, each person can configure their world the way they want. Run this script when the file first gets loaded. Then rerun the same script when the user presses the 'reset-the-world' button on the HTML page. Q: Would this meet your needs? In the past I considered building in some special support for this type of thing. I thought about putting in special support for an 'onLoad' script that would be automatically executed whenever a molecule was loaded. The idea was that you would specify this as a parameter to the JmolApplet and it would be run everytime a molecule was loaded. [applet ...] [param name="onLoad" value="cpk off; wireframe on; color orange;" /] [param name="load" value="myMolecule.cif" /] [param name="script" value="script do.whatever.txt" /] [/applet] Within the Jmol application this would serve as the mechanism for choosing your personal default settings. I had not considered this as a way to 'reset-the-world', but I suppose it would accomplish the same thing. Basically, this would be doing exactly the same thing that you can do in JavaScript ... with less administrative overhead. Q: From a web-application developer perspective, does it seem significantly more attractive to have this type of automated support for an onLoad script (which we could presumably tie to a 'reset' command of some sort). Miguel ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Jmol-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jmol-users

