Bob,

After reading your note, I think item 2 (my original note below) is the trouble maker. Item 1 (my original note below) is simple Jmol script that could really go directly in the load script - setting echo characteristics, turning hover off, etc. Here's the JavaScript function called via the timeout. I call this function on load and after every model change. It does the following:

1) Gets the Jmol stoichiometric formula of the model.
2) Puts the Jmol formula into more standard notation, including treating fragments as separate formulas delimited by +.
3) Places this modified formula in our stoichiometric calculator field.
Note: In addition to being a cute toy that I'm attached to, this calculator field keeps track of how many models are in the window - important to us. 4) Puts the Jmol SMILES for the model into a JavaScript global variable via a Jmol Script callback. This is for model identity tracking via a database.


function getFormula() {
var atomArr; var calcHold = ""; var fs = new Array(); var f = new Array(); var j;
    fs = jmolGetPropertyAsArray("moleculeInfo.mf");
    try {
        for (var i = 0; i < fs.length; i++) {
            if (fs[i].indexOf(" ") > -1) {
                atomArr = fs[i].split(" ");
                for (j = 0; j < atomArr.length; j++) {
                    f[j] = atomArr[j];
                }
if (f[0] == "H" && f[2] == "C") { atomArr[0] = f[2]; atomArr[1] = f[3]; atomArr[2] = f[0]; atomArr[3] = f[1]; }
                fs[i] = atomArr.join(" ") + " ";
calcHold += fs[i].replace(/ 1 /g, "").split(" ").join("") + "+";
            }
        }
document.getElementById("calcDisplay").value = calcHold.substring(0, calcHold.length - 1);
        calcWinTxt = calcHold.substring(0, calcHold.length - 1);
        if (stateSet) { jmolScript("print {*}.find('SMILES')"); }
        else {
            jmolScript("echo;print {*}.find('SMILES');" + loadScpt);
        }
    }
    catch (e) {
        //alert(e);
        jmolScript("boundbox {*};centerat boundbox;");
    }
}

So that you have everything, here's the JmolScript call that precedes the getFormula() call:

jmolScript("hover off;color label pink;select formalCharge <> 0;label %C;set echo top left;font echo 16 sansserif;color echo yellow;echo;set PickCallBack 'processPick';set MessageCallBack 'processMessage';select *;set debugscript true");


You can see this timeout delay on our original model kit page by checking the stoichiometric calculator display:

http://chemagic.com/web_molecules/script_page_large.aspx

The problem page (again the problem is random and not frequent) is our new model exercise page (deeply under construction!):

http://chemagic.com/web_molecules/template.aspx

In the case of the new page, the calculator field is hidden. The command calcon (followed by enter) in the command field shows this field. At this point, only the first two exercise types in the Problem Menu are active.

The getFormula() function is pretty important to us, but there may be a better way to do it. Any suggestions welcome!

Otis


Otis Rothenberger
chemagic.com


On 10/17/2010 10:09 PM, Robert Hanson wrote:
oh, I see. I think I missed the semicolon there. Sure.



On Sun, Oct 17, 2010 at 4:37 PM, Otis Rothenberger <osrot...@chemagic.com <mailto:osrot...@chemagic.com>> wrote:

    Bob,

    My jmolInit() is pretty involved:

    1) An immediate jmolScript() call.
    2) A JavaScript setTimeout() that makes a jmolGetPropertyAsArray()
    call and another jmolScript call.

    Maybe that jmolInit() function is getting me into trouble.


I'm sure it is. You are messing with two queued calls and in between those an asynchronous get property. Yeiks!

Can you show me that page?

Bob


    Otis

    Otis Rothenberger
    chemagic.com  <http://chemagic.com>



sers
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to