Thanks for the tip Bob.

Yes, the access to caffeine.bonds.length would be done every time the loop 
repeats, which is very inefficient. The most inefficient part of Javascript is 
namespace calls, so when doing a.b.c, Javascript would have to find a, then 
find b, then find c. The reason this is inefficient is because Javascript 
scopes allow variables from all over. We stuck with the incrementing loop in 
tutorials for understandability, and also that those copy/pasting the code may 
have cases where order matters. But yes, the while(i--) loop removes the extra 
variable. I like this page that that goes over some Javascript tricks: 
http://www.sitepoint.com/google-closure-how-not-to-write-javascript/

I should note that optimizing Javascript can be tricky, as a technique that 
improves performance in one browser may actually reduce it in another.

Bests,
Kevin


On Apr 3, 2012, at 8:22 PM, Robert Hanson wrote:

> OK, I'm catching on. Just takes me a while. It still might be nice to develop 
> a general set of JavaScript functions that would be particularly handy. A 
> select() function would be very nice, for example. I guess that's what you 
> are doing....
> 
> By the way, is this to prevent the repetitive access to 
> "caffeine.bonds.length" in JavaScript?
> 
>    for(var i = 0, ii=caffeine.bonds.length; i<ii; i++)
> 
> Is there a reason you do that? Is that a general problem that one should 
> avoid in JavaScript because of the interpreted nature of the language? If so, 
> this is simpler and cleaner:
> 
>   for(var i = caffeine.bonds.length; --i >= 0;)
> 
> Just something I learned along the way.
> 
> Bob
> 
> 
> 
> 
> On Tue, Apr 3, 2012 at 5:54 PM, Kevin Theisen <ke...@ichemlabs.com> wrote:
> @Paul
> We do not currently have a querying function, and this is a great idea to 
> add. We have SMARTS support that we can pipe through, however, it will take 
> some work before we can deal with proteins in such a way. The script is 
> irrelevant to this functionality though, as the script in itself wouldn't 
> generate this ability.
> 
> @Bob
> Concerning the writing of a high level script on top of Javascript, I believe 
> it is redundant and produces unnecessary overhead. Chemists are quite smart, 
> and we have yet to encounter one that has been unable to use the ChemDoodle 
> API. Our goal is to make the API very clear and easy for chemists to master.
> 
> ChemDoodle components each have a VisualSpecifications object associated with 
> them that controls the rendering of graphics. As I linked before, you can use 
> this object to control how your graphics appear: 
> http://web.chemdoodle.com/tutorial/advanced/visual-specifications
> 
> "I think maybe it's limited to just a few simple operations being simple to 
> implement."
> 
> I'm not sure what you mean by this statement, are you trying to say we are 
> not capable of doing anything more complex? I assure you we have the 
> competence to do so, and the ChemDoodle API is adequately powerful.
> 
> Regardless, I believe both ChemDoodle and Jmol have weaknesses, and by 
> working together, we can help to achieve the functionality that everyone is 
> requesting. That is my goal. We continue to focus on expanding the ChemDoodle 
> Web Components, and I believe that the experience of the Jmol community will 
> help us to continue in the right direction. What Paul said also reinforced 
> what I stated before, there are many authors that use Jmol script, and I 
> think it's a better idea to try to write a Jmol script parser for ChemDoodle 
> rather than for us to go off and write our own. Personally, I would alway 
> choose the core Javascript interaction over a high level interface, but 
> certainly this type of parser would be very helpful for Jmol users.
> 
> Bests,
> Kevin
> 
> 
> 
> 
> On Apr 3, 2012, at 5:44 PM, Robert Hanson wrote:
> 
>> I wasn't necessarily trying to say anything. But I'm interested in what 
>> those controls can do. Is it limited to a few standard operations like 
>> changing overall rendering? I think maybe it's limited to just a few simple 
>> operations being simple to implement. At least now. For example, I haven't 
>> found a "select" command that lets me do something more interesting with a 
>> subset of the atoms. I could be missing it....
>> 
>> On Tue, Apr 3, 2012 at 3:07 PM, Jeff Hansen <jhan...@depauw.edu> wrote:
>> I'm not with you Bob.  I checked the ChemDoodle demos (quite nice really) 
>> and I see the same kind of functionality as I see on many Jmol sites, radio 
>> buttons and such to control the appearance or behavior of a molecule.  Are 
>> you saying you think this is easier to create using Jmol scripting than it 
>> would be using Javascript?  I'm not sure I would agree with that.  It seems 
>> it is easier mostly because of the Jmol.js javascript library that hides 
>> much of the complexity.  Something similar could be done for the ChemDoodle 
>> approach I'm sure.  Or am I just missing something?
>> 
>> 
>> ***********************************************
>> Jeff Hansen
>> Department of Chemistry and Biochemistry
>> DePauw University
>> 602 S. College Ave.
>> Greencastle, IN 46135
>> jhan...@depauw.edu
>> ***********************************************
>> 
>> 
>> On Apr 3, 2012, at 3:46 PM, Robert Hanson wrote:
>> 
>>> I think this question got lost in the lower reaches of my response. It's 
>>> fine if the answer is, "You can't do that, at least not yet." 
>>> 
>>> My point is that the power of Jmol isn't  the twiddle factor; it's the 
>>> scriptability (by people who are chemists, not JavaScript or Java experts). 
>>> I don't see any reason why one couldn't add a higher-level scripting 
>>> capability to ChemDoodle. Is the plan really to leave it at the JavaScript 
>>> level I see on those ChemDoodle web components pages? 
>>> 
>>> Bob
>>> 
>>> On Mon, Apr 2, 2012 at 6:59 PM, Robert Hanson <hans...@stolaf.edu> wrote:
>>> 
>>> 
>>> 
>>> Say I have a page with a ChemDoodle version of caffeine.
>>> 
>>> What do I do in ChemDoodle that would be equivalent to this in Jmol:
>>> 
>>>   select {carbon}; color red
>>> 
>>> or
>>> 
>>>   rotate x 30
>>> 
>>> or, I have a protein, let's say 1crn. What would I do in ChemDoodle to do 
>>> this?
>>> 
>>> select *; wireframe only
>>> select {helix}; cartoons only
>>> 
>>> ? Those are pretty simple operations, of course. But I think they are 
>>> representative of what I'm talking about. Are there any web pages out there 
>>> using ChemDoodle that have simple scripting like this?
>>> 
>>> 
>>> 
>>> Bob
>>> 
>>> 
>>> -- 
>>> Robert M. Hanson
>>> Professor of Chemistry
>>> St. Olaf College
>>> 1520 St. Olaf Ave.
>>> Northfield, MN 55057
>>> http://www.stolaf.edu/people/hansonr
>>> phone: 507-786-3107
>>> 
>>> 
>>> 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
>>> ------------------------------------------------------------------------------
>>> Better than sec? Nothing is better than sec when it comes to
>>> monitoring Big Data applications. Try Boundary one-second 
>>> resolution app monitoring today. Free.
>>> http://p.sf.net/sfu/Boundary-dev2dev_______________________________________________
>>> Jmol-users mailing list
>>> Jmol-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>> 
>> 
>> ------------------------------------------------------------------------------
>> Better than sec? Nothing is better than sec when it comes to
>> monitoring Big Data applications. Try Boundary one-second
>> resolution app monitoring today. Free.
>> http://p.sf.net/sfu/Boundary-dev2dev
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>> 
>> 
>> 
>> 
>> -- 
>> Robert M. Hanson
>> Professor of Chemistry
>> St. Olaf College
>> 1520 St. Olaf Ave.
>> Northfield, MN 55057
>> http://www.stolaf.edu/people/hansonr
>> phone: 507-786-3107
>> 
>> 
>> 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
>> ------------------------------------------------------------------------------
>> Better than sec? Nothing is better than sec when it comes to
>> monitoring Big Data applications. Try Boundary one-second 
>> resolution app monitoring today. Free.
>> http://p.sf.net/sfu/Boundary-dev2dev_______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
> 
> 
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
> 
> 
> 
> 
> -- 
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> 1520 St. Olaf Ave.
> Northfield, MN 55057
> http://www.stolaf.edu/people/hansonr
> phone: 507-786-3107
> 
> 
> 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
> ------------------------------------------------------------------------------
> Better than sec? Nothing is better than sec when it comes to
> monitoring Big Data applications. Try Boundary one-second 
> resolution app monitoring today. Free.
> http://p.sf.net/sfu/Boundary-dev2dev_______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to