Jmol users,
I've updated the Jmol documentation to the level of "XHTML 1.0 Strict"
http://www.stolaf.edu/people/hansonr/jmol/docs
In connection with that, and in celebration of the latest Jmol.js, which now
allows us to use the functions much more broadly, I have upgraded the examples in
http://www.stolaf.edu/people/hansonr/jmol/docs/examples
to use Jmol.js. In connection with that, I found a couple of neat tricks
probably nobody other than myself would be interested in, but I thought I would
share them anyway.
The main new aspect of Jmol.js is that functions
jmolApplet() jmolBr() jmolButton() jmolCheckbox()
jmolHtml() jmolLink() jmolMenu() jmolRadio()
jmolRadioGroup()
all return the HTML code and only optionally write it to the page.
This may not seem like a big deal, but it is. Here are some ideas:
1) Quick checking of the code.
2) Imbedding applets in more complex page elements.
3) Selective writing to divs, spans, frames, or iframes.
4) Adding a message callback.
1) Quick checking of the code.
Now if you want to see what Jmol.js is writing, just change a call such as
jmolApplet(300,"load 1crn.pdb")
to
alert(jmolApplet(300,"load 1crn.pdb"))
2) Imbedding applets in more complex page elements.
If you are building the HTML around an applet, you don't have to use all those
jmolBr and JmolHtml functions anymore. Just do something like this:
jmolInitialize(".")
jmolSetDocument(false) //turns off document writing
var applet=jmolApplet(...)
var controls=jmolRadioGroup(...)
var s="<table><tr><td>"+controls+"</td><td>"+applet+"</td></tr></table>"
document.write(s)
jmolSetDocument(document) //turns document writing back on
What's interesting here is that we are creating the applet, then the controls,
but then writing the controls, then the applet. Easy!
3) Selective writing to divs, spans, frames, or iframes.
Say you already have a page up, but you don't start with an applet. (Ahem,
Miguel, maybe this for the home page, eh?) You can add it anytime with a link.
So, if we had:
<div id=applet_A></div>
or even
<p>Here is an applet added inline later:
<span id="applet_A">applet will appear here</span>
</p>
anytime later we could execute (perhaps from a link):
jmolInitialize(".")
jmolSetDocument(false)
document.getElementById("applet_A").innerHTML
=jmolApplet(300,"load 1crn.pdb","A")
and the applet will materialize out of thin air. The same goes for controls, of
course.
4) Adding a message callback.
Don't want to mess with jmolApplet(), but you need a messsage callback? Here is
how I got a message callback out of Jmol.js in the examples without touching the
Jmol.js code itself. What the following code does is add a messageCallback
parameter to the <object> or <applet> tag that Jmol.js returns.
isinitialized=0
function getapplet(name, model, codebase, height, width, script, msgcallback) {
//msgcallback is the NAME of a function
//(in string format, not the function itself)
if (!isinitialized)jmolInitialize("..")
isinitialized = 1
jmolSetDocument(0)
if (model)script = "load " + model + ";" + script
var s = jmolApplet([width,height], script, "X")
var sext = ""
if (msgcallback) {
sext = "\n<param name='MessageCallback' value='" + msgcallback + "' />"
s = s.replace(/\<param/, sext + "\n<param")
}
document.write(s)
}
(For peak picking messages, use the "set picking" command.)
How many other ideas can we come up with for this new facility?
Bob Hanson
--ps. I'm not getting animation frame change messages coming back to the message
queue when I do animation. Is that no longer available, Miguel? How would I
synchronize a page with a running animation?
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users