jmol users (cross-posted to ChemWebDev-L as well)

Thanks to all for feedback on the test pages:

http://www.stolaf.edu/people/hansonr/jmol/applet/mscalc/view.htm

OK, I think we've learned a little more about how to interact with browsers. This thread has highlighted some important Mac OS/Java issues along the way.
Thank you all for your quick feedback.


So let me summarize what we've learned. (Correct me if I have this wrong.)

1. "show file" works great in a <param name=script> tag
2. using MOL file data as javascript data structures
3. Mac OS 10.3.8 and applet scripting
4. LiveConnect problems MacOS and Windows
5. need for setTimeout() with scripting from links
6. JavaScript can abort with a .script() command
7. File location and ../
8. handling of parseFloat("") different on different systems

1. "show file" can be used at the end of a <param name="script"> start-up script to deliver the MOL file contents to JavaScript via a messageCallback function. Identifying that message is a bit of a problem -- my hack was to just look for anything longer than 1000 characters. Probably OK for my applications.

2. It's not hard in JavaScript to parse the MOL file information to produce a data structure that can then be used to trace connectivity, measure molecular mass, etc.

3. The Mac OS 10.3.8 appears to be unique in handling <applet> tags. You can't reliably used document.getElementById().script() with this system. Instead, you have to use the name=elementname and the document[elementname].script() convention to access the scripting. Other systems don't seem to have this problem. But the point is, access to scripting should not assume one or the other method will automatically work. Of course, using Jmol.js should take care of this, because as reports come in, it will be the first thing fixed to handle odd browser characteristics.

4. I'm not 100% sure, but it's possible that some systems have trouble with liveConnect (JavaScript/java interaction) if pages are loaded together or sequentially with the same applet name. In particular, we have seen oddnesses such as the controls on one page operating the applet on another page (sorry, I can't find my own message to that effect in the archives) or, as in this case, trouble connecting to the applet via user actions after reloading a page. My workaround for this was to generate a random number for the applet id/name each time the page loads. No reference could possibly be to any other applet in that case.

5. Another issue involves setTimeout() and scripting an applet. If you are going to script the applet using a link, that is: <a href=javascript:....>, or if you want to support Opera at all, it is imperative that you use setTimeout() to trigger the event. This means that using

<a href="javascript:document.jmol.script('xxxx')">

is a sure-fire way to have user problems. I recommend

  <a href="javascript:doscript('whatever')">

and then creating a function that starts a new thread using

  setTimeout("applet.script('"+whatever+"',100)

I'm pretty sure jmol.js does NOT do this yet, so jmolLink() may not work on all platforms, and ANY scripting/callbacks may not work some Opera browsers. I can confirm that this is a problem even with messageCallbacks (not just links) under Opera 7.52.

6. This isn't something I've mentioned, but it's something else that came up during my testings. I had two functions:

showmass(a1,a2)  //change the colors of the atoms
showmolfile()    //redisplay the contents of the MOL file with color highlights

Originally I did them in that order. But I quickly -- ok NOT SO QUICKLY -- figured out that the showmolfile() command wasn't running. Somehow when the .script() command was issued at the end of the showmass() function, that stopped the javascript dead in its tracks. It never came out of the function. So I had to implement it as:

        var scmd=showmass(a1,0)
        showmolfile()
        sendscript(scmd)

Then it worked. I can't say this is a problem for all systems. Nor can I confirm that I can reproduce it. But it's something to look out for. Especially if you include alert() anywhere, threads can get messed up.

7. No reports to date indicate that ../ for a codebase is a problem, either on a hard drive on a web-based system.

8. While I'm at it, one more: Some browsers (Opera 7.52, e.g.) consider parseFloat("") to be 0 while others (NN, IE) consider it to be NaN (Not a Number).

thanks again for the feedback,

Bob Hanson



Bill Reusch writes:

Bob,
Good news! This version works on my Safari (OS 10.3.8) even after your other pages no longer function. I can reload the page and it continues to work.
The atoms and the molfile listing change color at the appropriate place. The rotate x button works, and the small text box returns a Script completed message.



Philip Bays wrote:

Bob:
These both now work for me. Just a minor point. Your alert is correct in directing the user to point to two adjacent atoms. However, the page directions leave out the word adjacent; you get some odd results if the two atoms are not adjacent.

Yeah, I know. Thanks. I'm not actually going to do anything with this page. It was just a test to see if "show file" could be used to generate the structure
in javascript, to give others some ideas, and possibly for use down the road.



Phil


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

"Imagination is more important than knowledge."  - Albert Einstein


------------------------------------------------------- This SF.Net email is sponsored by: New Crystal Reports XI. Version 11 adds new functionality designed to reduce time involved in creating, integrating, and deploying reporting solutions. Free runtime info, new features, or free trial, at: http://www.businessobjects.com/devxi/728 _______________________________________________ Jmol-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to