Yes, that's pretty much what you have to do. It's not an array; it's an
object. Jmol._applets will contain 2n or 2n+1 entries, where n is the
number of applets. The "or 2n+1" comes from the fact that I say because I
recently fixed a bug that introduced a useless single key/value pair that
ended up just for the last applet loaded. I had not realized that
JavaScript associative arrays had to have keys that are strings. I thought
they were like Java Hashtables, which can have any object as a key. So
until recently there has been a key "[object Object]" as well.
The code generating this is in JSmolCore.js:

    Jmol._registerApplet = function(id, applet) {
        return window[id] = Jmol._applets[id] = Jmol._applets[id + "__" +
Jmol._syncId + "__"] = applet;
    }

The reason there are two entries, the one with that "Jmol._syncId", has to
do with the fact that for the Java version of Jmol, an applet on one web
page can communicate via SYNC with applets on a different page, as long as
they are from the same domain. (Try it!) The syncId is added to make sure
that the applets have unique names, not just all "JmolApplet0", for
instance.

You could also use this in the HTML5 version, though not in Java:
JU.GenericApplet.htRegistry.keySet().size()/2



On Wed, Jan 20, 2016 at 5:13 AM, Angel Herráez <angel.herr...@uah.es> wrote:

> Hi all
>
> I need to find out the numer of Jmol objects existing so far in a page.
> I was expecting this to work
>
> alert( Jmol._applets.length )
>
> However, it returns 'undefined'. I can see that Jmol._applets does exist
> as  a
> Javascript object. Some posts in the users list say it is an array of
> objects.
> Then, how I cannot get its length?
>
> BTW, this works though it's unnecessary convoluted in my opinion
>         var i=0;
>         for (j in Jmol._applets) { i++; }
>         alert(i)
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



-- 
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department 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
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to