DO NOT try to do something in javascript that depends on a prior JSmol script having been executed. Rather, code the action in JSmol script, and call it from javascript. That way the JSmol code will not be executed until after the preceding requisite JSmol commands have been executed. Example: Defining bitsets of forked backbone and then conditionally rendering them in makeCartoonSpt(). The defining commands are in a huge makeJmolV1Script that ALSO includes later the cartoon rendering commands. The makeCartoonSpt() javascript is executed before the definitions occur in JSmol. SOLUTION: Define a function in JSmol that is called from makeCartoonSpt(). The rendering of forks in that function will be conditional upon the prior definition in JSmol (not in javacript) of forks. The JSmol script queue will keep things in order. ---------------------------------------------------------------------------- A script that defines something after the molecule is loaded, but before the Mol Info Tab is to appear can be added to makeView1Spt() (scripts.js), e.g. cf. makeDefineIncompleteSidechainsSpt(). This is where I added makeFindIsopepNOSBSpt() for FG 3.3. To add something done once after the model is loaded, consider putting it in modeldat.js getAtomCounts() An alert in getAtomCounts() appears before either left panel is loaded. I did this for "save structure authorstructure"; (?? later moved ??) I did this for getMissingCount() to get bmMissingCount in time for initial rendering. An alert at the end of setupControlPanelTabs() in controls.js appears after the control panel but before the intro help appears. Best place for something to happen after loading is completed and both panels are filled: Put it in returnToIntro() which is called during startup. See alertForks() there. [msgcall.js near end of processPDBHeader(). NOPE, an alert there occurs before either panel is filled.] When toggling preferences to More Details, returnToIntro() is not called. For toggling preferences to More Details, in order to get alertForks() to execute AFTER the crosses were rendered: 1. Had to use a special toggling flag (togglingForksPref). 2. Put alertForks() in scriptToJmol2() in top.js. 3. Has to use a setTimeout in a javascript command to JSmol. SEE >>>>>>> doPostLoadActions() TOP.JS <<<<<<<<<<< It occurs after the molecule is loaded and rendered [initially it had only alertUnusual(); now also label incomplete sidechains] called by processPDBHeader() in msgcall.js BUT this was apparently TOO EARLY to toggle quality off, see quality.txt. ----------------------- putJmolApplet() in moldoc.js starts Jmol with makeJmolInitScript(), which is defined in scripts.js: debugging options view1SptPrefix (scripts.js) echos "Jmol loading completed" loads 1Atom.pdb makeJmolV1Script() in scripts.js generates the load command in finalSpt. Complicated construction of load command for biounits. After the load command, finalSpt += makeView1Spt() + makeEchoPdbIdSpt(""); HUGE number of commands defining many things including makeDefineForkedBBSpt() is included in the spt BEFORE makeView1RenderSpt() which includes makeCartoonSpt() // for consurf, the real view1 script is from // makeConsurfViewSpt() in consurf/scriptsc.js makeView1Spt(): if (processHeaderBeforeMolView) // for consurf just make the gray echo "processing header" Message (4 lines) including "found biomolecule" reports molecule loaded. (msgcall.js) in top.js, processHeaderBeforeMolView is false unless the PDB filename contains "consurf" or another Tel Aviv server name. Therefore, for a non-consurf PDB file, too much redesign would seem to be needed to query Jmol for missing residues before the initial view appears. ------------------------ When a message goes thru messageCallback signalling the end of the PDB header, call processPDBHeader() in consurf/msgcall.js calls writeConsurfControls() calls makeConsurfControls2() calls makeInfoLinks() else if not consurf calls setupControlPanelTabs() + returnToIntro() ***showFGControls() called in consurf/ calls setupControlPanelTabs(); in controls.js showFGControls() (used only when doing so from the ConSurf control panel) calls writeFGControls() calls makeInfoLinks() -------------------------- FG 3.7 ConSurf -> FG tabs: showFGControls() first time: startupPanels() getHeaderBlocks() if no header, asks re: AlphaFold startupPanels2() setupControlPanelTabs() + intro if not consurf + doPostLoadActions() if not first time, headerBlocksGotten setupControlPanelTabs()