Fellow Developers,

Regarding using the signed applet and http://chemapps.stolaf.edu/pe/protexpl

I spoke too soon. Turns out there's a simple trick to getting a signed 
applet to load any file from anywhere -- even if directed from 
Javascript. There is no need for any hacks that involve reloading the 
whole page or regenerating the applet div. Just give the command!

Check this out: At the Protein Explorer command prompt you can now give 
commands such as:

  load =1crn
  load c:/temp/1cdr.pdb
  load http://www.rcsb.org/pdb/files/1blu.pdb

(That first one loads the file from www.rcsb.org/pdb/files.) You will 
see the models appear just like you had entered a pdb ID in the "New 
Molecule" slot.
You can run local or remote scripts:

  script c:/temp/myscript.spt
  script http://chemapps.stolaf.edu/jmol/docs/examples-11/qtest.spt

You can load files into variables and display their contents:

  print load("http://www.stolaf.edu";)

You can run javascript as well:

  javascript "top.popupData (top.messages) "
  javascript "alert (eval (3.5*4.9))"

Basically, you can do anything you could do with the application except 
write files to disk. (Is there a way of doing that with a signed applet?)

Heck, with a little server help, we should be able to have that site 
EMAIL the Jmol state to yourself or a colleague as an attachment. OK, 
I'll set that up tomorrow!

Here's the scoop: Turns out the security in terms of signed applets not 
being able to open files directed by JavaScript is based on thread 
security. It's the JavaScript THREAD that cannot open files. Similarly, 
it is the Java applet THREAD that cannot execute JavaScript. A simple 
modification to Jmol allows both to work. Jmol 11.5.39 now recognizes 
that a signed applet is in use. (You can check yourself using SHOW 
_signedApplet.) When it is, then Jmol automatically starts using an 
independent thread for entering commands into the script queue. That 
apparently is all it takes. The applet does all of the above!

Jmol also now looks for "javascript " (with the trailing space, for now) 
in a script, and if it sees that, then is switches back to "JavaScript 
thread" mode so that it can access the document's JavaScript engine.

There is still more work to do on this -- my next task it to fix the 
BUSY/READY indicator to function properly. It would be nice to have a 
smart way of doing that. It doesn't really MATTER if Jmol is busy -- 
this should only be an indicator -- but I can see that it is nice to 
have it there. Maybe we just need a simple "ready" callback.

It's taken quite a bit of mental effort to wrap myself around the 
Protein Explorer code. I have to say, I'm mightily impressed. This is 
probably the most complex piece of JavaScript in the world. Really 
amazing what this can do. Eric Martz did a fabulous job getting it 
coordinated so well. I'm just totally excited about being able to have 
it working with Jmol.

I thought I would share a nice little code fragment with you:

  http://chemapps.stolaf.edu/pe/shared/stack.js

This bit of code allows you to dump stack traces, including arguments 
used in the calling, to new windows. If you have ever been frustrated 
with knowing from where a method was called, this is the way to go. Just add

  alert(getStackTrace())

do display a short version or

 getStackTrace(true)

to open a window with the full version. It's crude. But it should give 
you some ideas. I'd be interested in what others use in this regard. Do 
the new browsers let you walk through the JavaScript, setting 
breakpoints and such? Anyone had any success with that?

Bob















Bob Hanson wrote:

>Jmol developers:
>
>Take a look -- Protein Explorer now works with Jmol!
>
>http://chemapps.stolaf.edu/pe/protexpl
>
>
>-- developer notes --
>
>This uses the signed applet, and I'm happy to say it works 
>extraordinarily well. There are going to be limitations -- serious 
>thought, for example, should be given to MolSlides. This is not going to 
>work to have 20 large Jmol windows on a page. For one or two slides, I 
>think it might be OK, but I would recommend retooling that with an 
>applet in mind. (Scripts and text stored in JavaScript; a single DIV 
>replaced with files, something like that. More like a power point rather 
>than a long scroll of paper.
>
>There are more aspects there to get working, such as all the "advanced 
>options". But I think I will let people try it out now and tell me 
>what's working and what's not, what's important and what's not. (I'm 
>sure comparisons don't work, because I haven't taken the time to see how 
>you do that.)
>
>Lessons learned in this endeavor:
>
>--Just about all the hacks in Protein Explorer for
>different browses can be removed or bypassed --
>in terms of supporting modern browsers using Jmol.
>Only Opera balked. As far as I can tell, there are
>no differences between MSIE, Safari, and Firefox
>in terms of the operation of the applet. Hurray!
>
>--The signed applet works fabulously. There are tricks
>to getting this right, though. For example:
>
>---- You cannot load a file or run a script
>from another server using any JavaScript command.
> 
>---- If the Javascript creates a new applet
>with the load command in a <param name="script">
>tag, that's OK.
>
>---- Opera doesn't allow writing over a div with a
>new applet, but the others do. That's what I'm doing in PE.
>(Opera creates the applet but can't talk to it.)
>
>-- It's possible to create a page that uses the signed
>applet to read any file anywhere and report it's contents
>back to the opener in a function. This is how the [view]
>button works. This capability was not possible with Chime.
>
>--Jmol's scripting engine is robust. There is no problem
>with mis-ordered callbacks the way there was in Chime.
>
>
>
>
>Bob
>
>  
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get. 

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to