For what it’s worth, here is the code to use browser local storage to “stash” a 
model when you leave a JSmol page. I’m using the molfile, but Jmol 
state/restore should also work - See note at end of email. An extension of the 
approach should also allow you to save/reset JavaScript variables that are 
important to your web page state as well as multiple models.

Run stashMol() below when you leave the page:

function stashMol() { 
        localStorage.setItem("chemagicTEMP", "!MODS!" + 
Jmol.getPropertyAsString(jmolApplet0, "extractModel"));
        // (Stash more complex JavaScript and JSmol Stuff to restore variables 
and possibly other models)
}

// !MODS! is just a flag to mark the general usage memory location chemagicTEMP 
content as remembered model data.


In the page jmol_ready callback, run the following. It will ensure that no 
matter how you return to the page - back/forward/link, your previous model(s) 
will load. Note that with Safari, you will have to use the back button fix in 
my previous email.

var stash = localStorage.getItem("chemagicTEMP”);
if (stash == null || stash == undefined || stash == "") { stash = ""; } // 
Overkill, I’m a bit retentive...
if (stash.indexOf("!MODS!") > -1) {
         stash = stash.replace("!MODS!", "");  // Get rid of the flag.
        localStorage.removeItem("chemagicTEMP”); // It’s important to keep this 
memory location null after grabbing the model data.
        Jmol.script(jmolApplet0, 'var molf2 = "' + molf1 + '"; load "@molf2"; 
hover off;’); // Load stash model, replacing default load.
        // (Do other more complex JavaScript and JSmol Stuff to restore 
variables and possibly other models)
}

Note: My problems with Jmol state date back to when I was trying to do this 
type of thing by saving a state file to server. I think my problems related to 
state file characters that my Windows server via VB.NET did not like. Now that 
I’m using local storage, I have to revisit the state approach.

Otis
--
Otis Rothenberger
o...@chemagic.org
http://chemagic.org

> On Feb 12, 2016, at 7:04 PM, Robert Hanson <hans...@stolaf.edu> wrote:
> 
> 
> 
> On Fri, Feb 12, 2016 at 1:52 PM, Rolf Huehne <rolf.hue...@leibniz-fli.de 
> <mailto:rolf.hue...@leibniz-fli.de>> wrote:
> 
> And the "back" function actually isn't totally disabled. At least in
> Firefox and Safari (not tested in other browsers) the "click and hold"
> function to select a specific step in the history still works.
> 
> 
> How about that. I never knew about "click and hold" !
> 
> 
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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