[Sorry, somehow I don't have reference to Chuck's original here...]

On Mon, Feb 10, 2014 at 3:24 AM, Angel HerrŠez <angel.herraez@uah.es> wrote:
Hi Chuck

I'm returning this to the list thread, for everyone's benefit.

Charles Harrison Shubert wrote:
> I seem to have gotten the behavior I wanted using your suggestion. I
> not longer need Jmol.setXHTML when I use Jmol.getAppletHTML to invoke
> Jmol.
> Instead of using the "document.getElement ..", I used jQuery: $('#' +
> model.ids.id_jsmol).html( Jmol.getAppletHtml(model.ids.id_jsmol +
> "JmolObject", Info);

When you use Jmol.getAppletHtml(xxx, Info),

then a JavaScript object is created:


That is the "applet" object. If you really don't know what model.ids.id_jsmol is, then you could short-cut that later with:

jmolObject = window[model.ids.id_jsmol+"JmolObject"];

I apologize about the ambiguity of "applet" here. We have the JavaScript object and the (formerly/occasionally) Java applet or its JavaScript equivalent. In the JavaScript on the page,


is the Java/whatever applet that has all the public functions of the original Jmol Java applet plus, in JavaScript, all private methods and fields, such as


I probably should not even mention that, because anything not public for the Java, though public for JavaScript, is considered fair game for development changes. No guarantee that "modelSet" will be called that tomorrow! Fair use for testing and development, but don't use this for production.

Yes, that's right. I just thought the HTML version would be more
readable (it is for me), but the equivalent jQuery is OK.

Funny the way jQuery grows on you... I now see $("#xxx")[0] as being way nicer than document.getElementById("xxx").

> I then recreated a local jmolObject with:
> jmolObject = eval(model.ids.id_jsmol + "JmolObject");

as mentioned. Just use window[....] not eval(). Or you could use self[...]. Anyway, in JSmol.js we have:

††† Jmol._registerApplet = function(id, applet) {
††† ††† return window[id] = Jmol._applets[id] = Jmol._applets[applet] = applet;
††† }

So window[id] is guaranteed to be your applet object.

> to use with
> Jmol.resizeApplet(jmolObject, "100%", "100%");

I learned a few ays ago that you can use this too to refer to the
object, to avoid eval() which seems to raise distrust among

†jmolObject = window[model.ids.id_jsmol + "JmolObject"];

There you go. Right, eval() can do more than you want it to. Stick with† window[].

> I'm still a little confused by some of the jmolObject details as is
> my code, but Jmol is now where I want it in my page and has the
> correct size and z-order (that's in my css).
> I'll spend some time tomorrow cleaning up the code and send you a
> summary.

Next release allows setting the z-order of the applets prior to execution of Jmol.min.js. But now that I think of it, I think


would be in order. Note that there are a range of objects that need z indexes -- menu, console, dialogs, etc. That can be customized already, but Info.zIndexBase (currently 9000) would probably be nice to have.


> Many thanks,
> -Chuck
> On Feb 9, 2014, at 4:42 PM, Angel HerrŠez <angel.herraez@uah.es>
> wrote:
> † † Hi Chuck
> † † I've been recently playing with ways to inject the Jmol objecr after
> † † page is loaded, so I will try to give a hint, see if it works
> † † Jmol.setXHTML(model.ids.id_jsmol);
> † † It's not clear to me where you define that ID
> † † You need an id in your Jmol container div:
> † † <div> app
> † † <div> menubar </div>
> † † <div>
> † † <div> tabs </div>
> † † <divid="JmolPlace"> jmol </div>
> † † </div
> † † </dib>
> † † Then
> † † document.getElementById("JmolPlace").innerHTML =
> † † Jmol.getAppletHtml('myJmol', Info);
> † † Does that work?

Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
Jmol-users mailing list

Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN

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