Daniel, I think there is some confusion in your scripts about what is done on
the client side and what is done on the server side.
I'll try to explain it :
- client side you have the Jmol applet embedded in a html page (the html code
may have been created through php, in the end it's always html from the client
perspective). The user through javascripts can interact with the web page, with
the applet and create a view that you may want to save.
To save the view, you want to interact with the server.
- server side : you have a php script that receives different requests (for
example a state script through a form element) and sends an html page (or other
kind of files/texts,etc...)
So, the first thing you have to decide is when and how your user keeps a state
of what he is doing. There are several options there. The simplest might be to
click on a submit button that would trigger your next php page.
But when the user clicks on submit, you want that the value attached to the
submit button or to an invisible input element is updated with the value of the
state script.
For example, your HTML could look like
<form method="put">
<input type="hidden" value="" name="my_script" id="my_hidden_field" />
<input type="submit" value="Submit !"
onclick="document.getElementById('my_hidden_field').value=jmolGetPropertyAsString('stateInfo')"/>
</form>
Then in your php you can access to the state script with $REQUEST['my_script']
An other option might be to use an ajax library to save the different states
the user gets on the first page, before loading the next page. I made something
like that with a kind of snapshot widget that saves states in a webpage that
could be recalled from an other webpage. If you're interested and don't mind
french you can have a look at the following link :
http://librairiedemolecules.education.fr/outils/minuscb/app/minusc.htm If you
click on "Clichés", you activate that snapshot function. Each "Cliché" triggers
the saving of a statescript + image in a database, and can be accessed from the
"export" feature (it's a prototype, I haven't pushed it further). In your case,
you could save the state script in a php session variable to find these back on
your subsequent page.
-Paul
Le 4 août 2011 à 15:41, Daniel Carbajo a écrit :
> I am trying everything I can think of but does not seem to work... my last
> attempt is the following (saving the jmolGetPropertyAsString("stateInfo")
> output into a file):
>
> In the second php:
>
> $ESTADO=$_POST["ESTADO"];
> echo "$ESTADO";//IT IS SAVED CORRECTLY HERE
> $File = "Jmol-12new/test.sptt";
> $f = fopen($File, 'w') or die("Cannot create file $File");
> fwrite($f, $ESTADO);
> fclose($f);
>
>
> $JMOL = "<script type=\"text/javascript\">
> jmolInitialize(\"Jmol-12new\", true);
> jmolSetAppletColor(\"white\");
> var jmolcmds = [
> \"load $ZIPtoUSE|$PREFIX-Models_$code/$PREFIX-$code.pdb\",
> \"set frank off; select all; hbonds off; spin off; wireframe off;
> spacefill off; trace off; set ambient 40; set specpower 40; slab off; ribbons
> off; cartoons off; label off; monitor off\",
> \"set isosurfacePropertySmoothing TRUE\",
> \"set showAxes true\",
> \"set appendNew true\",
> \"frame all\",
> \"display all\",
> \"select 1.1; cartoon; set propertyColorScheme 'bwr'; color atoms
> property temperature ABSOLUTE $range\",
> \"script Jmol-12new/myJMOLfunctions.spt\",
> \"script Jmol-12new/test.spt\"
> ];
> jmolApplet([580,500], jmolcmds.join(\"; \"));
> jmolScriptWait(\"_setState\");
> </script>";
>
>
> Of course this is NOT working... and I'd rather prefer Bob's way with "Jmol
> Embedded Script" but I really don't know how to make it work... by the way,
> should I keep all the specifications when initializing the applet before the
> state script? Thanks a lot to everyone,
> Daniel
>
>
>
>
>
>
>
>
>
>
> 2011/8/4 Daniel Carbajo <[email protected]>
> OK it seems I am able to pass the jmolGetPropertyAsString("stateInfo") value
> to a new php doing the following (in case anyone is interested):
>
> First php:
> $cont0 .= "<form name=\"PASARCOLORS\" action=\"MODshowCOLORS.php\"
> method=\"POST\" onSubmit='var state=jmolGetPropertyAsString(\"stateInfo\");
> document.PASARCOLORS.ESTADO.value=state;'>";
> $cont0 .= "<input type=\"hidden\" name=\"ESTADO\"></form>";
>
> Second php:
> $ESTADO=$_POST["ESTADO"];
> echo "$ESTADO<br>";
>
> So now I have it inside a variable in the second php... Should I do something
> like:
> $ESTADO="/****Jmol Embedded Script ****".$ESTADO."**/";
> JmolScript($ESTADO);
>
>
> Besides, answering to Rolf's previous question, the new files I want to load
> are exactly the same (just the B-factor records change), except for one file,
> that in the first php contains all chains, and in the second only the chain
> under study, but with the same coordinates and everything... (hope this is
> not a problem). In any case I should parse the $ESTADO variable because all
> pdb file names change, and the labels (though refering to the same residues),
> are slightly different...
> Thanks,
> Daniel
>
>
>
> 2011/8/4 Daniel Carbajo <[email protected]>
> Thanks! I start to understand how this works but I have one problem: I cannot
> pass the jmolGetPropertyAsString("stateInfo") information from one php page
> to another... I have tried the following with no success:
>
> First php:
> <input type="hidden" name="STATE\"
> value='jmolGetPropertyAsString("stateInfo")'>
>
> Second php:
> $STATE=$_POST["STATE"];
> echo "$STATE<br>";
>
> But I get just the command, not the value... So how do you send it to the new
> page? I am quite new to all this, sorry. And thanks a lot again!
> Yours,
> Daniel
>
>
>
>
>
> 2011/8/3 Robert Hanson <[email protected]>
> Daniel,
>
> Yes, jmolGetPropertyAsString("stateInfo") returns the exact information to
> use to retrieve the exact state. This is what
> http://chemapps.stolaf.edu/jmol/docs/examples-12/JmolPopup.htm uses. If it
> does not reproduce the EXACT state, I want to know. (The only caveat is that
> labels can move if displayed in an applet that has a different size.) To use
> it, just run it with
>
> script [that filename]
>
> or send it to the new page as part of the page (I like to use <-- /****Jmol
> Embedded Script **** .... **/ --> comments in the HTML and then just send
> the whole page to Jmol with JmolScript (grabbing that with
> document.getElementById(...).innerHTML. That works amazingly well, and you
> don't have to escape anything. The necessary term is
>
> /**** Jmol Embedded Script ****
>
> If Jmol finds that in a file, it reads only the data between that and
>
> **/
>
> and skips everything else in the file.
>
>
>
> On Wed, Aug 3, 2011 at 10:32 AM, Daniel Carbajo <[email protected]>
> wrote:
> The point is that I have a page where I can load many proteins, change them
> from cartoon to spacefill to whatever, highlight residues in wireframe... and
> then I have a button which redirects to another page which is similar, but
> with different proteins, which are actually the same ones but with
> temperature factor records changed with other descriptors... In this second
> page I want to restore all the settings from the previous (proteins loaded,
> whether they are in cartoon, spacefill, etc., residues highlighted,
> orientation...).
> Which do you think would be the best way to do so?
> Does jmolGetPropertyAsString("stateInfo") return all that information? If so,
> I am not so sure where to put it so it can be used by the second page...
> This is my first attempt in php:
> $content .= "<form><button type=\"submit\" onClick='var
> state=jmolGetPropertyAsString(\"stateInfo\");
> alert(state)'>CHECK</button></form>";
> But I do not want a button and an alert... besides the output is cut so I do
> not get to see everything that jmolGetPropertyAsString("stateInfo")
> returns... Any suggestions?
> Thanks again,
> Daniel
>
>
>
>
>
>
>
> 2011/8/3 Rolf Huehne <[email protected]>
> On 08/03/2011 03:04 PM, Daniel Carbajo wrote:
> > Hello everyone,
> > is it possible to save a Jmol session in terms of proteins loaded, their
> > displays (cartoon, spacefill...), residues selected, labels, etc. in one php
> > page so everything is restored in another? Can I save the session
> > specifications into a file that is read by another php page? I am trying
> > with save/restore ORIENTATION saveName, but does not seem to be working.
> The "save state" command does this.
> (see
> http://jena3d.fli-leibniz.de/ImgLibPDB/Jena3D/doc/jmol_scripting/index.htm#save
> )
>
> But you will need the "signed" Jmol applet to be able to write it
> directly into a file.
>
> With the "unsigned" Jmol applet you can open the Jmol console, display
> the state (by clicking on a button) and copy+paste the state into a text
> editor and save it into a file.
> But depending on the combination of Java, browser and operating system
> version there might be copy+paste problems.
>
> With both applet types you could read the state information with
> javascript and then send the data to a server for storage:
>
> state = jmolGetPropertyAsString("stateInfo");
>
> Depending on the location of the other PHP page and the directory
> organization at this site it might be becessary to adapt the state
> script to the new location before it is loaded properly.
>
> Regards,
> Rolf
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> 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
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
>
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1_______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users