nice. Yes, saving the state would be more general:
Jmol.getPropertyAsString("stateInfo")

Otis, what events exactly are you using for triggering the save and restore
scripts?


> var stash = localStorage.getItem("chemagicTEMP”);
> if (stash == null || stash == undefined || stash == "") { stash = ""; } //
> Overkill, I’m a bit retentive...
>

A simpler, more concise, coding of this might be:

 var stash = localStorage.getItem("chemagicTEMP”) || "";


Since the state is a script, you do not need the MODS thing:

function saveState() {
localStorage.setItem("JSmolState", Jmol.getPropertyAsString(jmolApplet0,
"stateInfo"));
}

function restoreState() {
  var state = localStorage.removeItem("JSmolState") || "";
  if (state.indexOf("# Jmol state") >= 0)
       Jmol.script(jmolApplet0, state);

}

But I think, actually,  there are some very serious additional issues that
might prevent this from being a general method. Specifically, when some
file types are loaded, such as PDB files in gzip format, they are inserted
into JSmol's own cache, which is a binary array cache, not a string. When
the state is saved, the reference to this file is not the original call,
but instead a call to the local JSmol cache. But when this localStorage
business is implemented, then all you can save are strings, not binary
arrays. So the script fails.

Bob
------------------------------------------------------------------------------
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=272487151&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to