OK,
Thanks Bob
I understand there are functional reasons behind that construction.
I still think this needs a rather convoluted method for something that is
conceptually simple: how many Jmol objects in a page.
And I am not too happy hard-coding this to using internal variables and
finding a particular string inside the object collection.
Couldn't we have some kind of
public function that will return the number?
something like Jmol.getNumber()
This is what I have managed now and seems to work (#2 is based on some
older code I had forgotten):
// METHOD ONE:
function nJmols() {
var n=0, k, jj = Jmol._applets;
for (k in jj) { n++; }
if (n>0) { n=(n-1)/2; } // COULD BE UNRELIABLE? 2n vs. 2n+1
return n;
}
// METHOD TWO:
function nJmols() {
var n=0, k, jj = Jmol._applets;
for (k in jj) {
if (jj.hasOwnProperty(k)) {
if ( !/__/.test(k) && !/\[/.test(k) ) {
//exclude duplicates, retain simple applet objects
n++;
}
}
}
return n;
}
------------------------------------------------------------------------------ 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