Difference between revisions of "Loading Notice"

From Jmol
Jump to navigation Jump to search
m ((formatting))
Line 50: Line 50:
  
 
=== Trick nr. 1 ===
 
=== Trick nr. 1 ===
 +
([[User:Ceroni|Sérgio Ceroni da Silva]])
  
 
jmolApplet("100%", "script pre.txt; load file.pdb; script post.txt")
 
jmolApplet("100%", "script pre.txt; load file.pdb; script post.txt")

Revision as of 00:24, 30 July 2008

How to provide a 'please wait' notice while JmolApplet is loading

Please, feel free to share here your tricks for showing a "please, wait" kind of notice so that users get some feedback that the JmolApplet is loading.


While Java and Jmol are loading

This is not easy, as you cannot put anything in the place of the applet; the browser draws the applet (even before it is loaded) on top of anything else in the page.

Trick nr. 1

(AngelHerraez)

Here I choose to put a small JmolApplet in the homepage (here flushed top left, but could go anywhere else), so while the user reads the introduction to the site, Java and Jmol can go on loading, and when the user jumps to the content pages, Jmol will be cached and load quickly with the contents.

I insert a small DIV with a "please wait" warning and the applet; this latter does not load any molecule, just displays a "done" message using the echo command. I use matching colors for the DIV and applet backgrounds and texts, so the applet is not too apparent as such. The Java and Jmol logos will show up temporarily, but that is not a bad thing, as it proves that something is indeed going on.

<html>
<head>
<script src="Jmol.js" type="text/javascript"></script>
<style type="text/css">
#JmolPreload 
{ 
  float:left; width:160px; 
  border:1px inset #333333; padding:4px; margin-right:2ex;
  background-color:#FFFF80;
  font-family:Arial, Helvetica, sans-serif; text-align:center; 
  font-size:16px; 
  color:#AA0000; 
}
</style>
</head>

<body>
<div id="JmolPreload">
  Please wait until Jmol has loaded
  <script type="text/javascript">
    jmolInitialize("./");
    jmolSetAppletColor("#FFFF80");
    jmolApplet([150,100], 'set disablePopupMenu on; set frank off; set echo middle center; font echo 19 sans; color echo [xAA0000]; echo Jmol is ready; ');
  </script>
</div>
</body>
</html>


While the model is loading (after Jmol has finished loading)

Trick nr. 1

(Sérgio Ceroni da Silva)

jmolApplet("100%", "script pre.txt; load file.pdb; script post.txt")

pre.txt

zap;
set echo middle center;
font echo 18 sanserif bold;
color echo navy;
echo Molecule loading||It will take a few seconds,|depending on molecule complexity|and your connection speed||Please wait...;
delay 0.1;


post.txt

wireframe off;
spacefill off;
set hoverDelay 0.1;
set echo middle center;
font echo 14 sanserif bold;
color echo background [xA6CAF0];
color echo navy;
echo Molecule loaded||Click here to turn off this warning|and then use the available controls|to select parts of the molecule|and change its visualization;
set echo middle script "set echo off";


simpler post.txt

set echo middle center;
font echo 16 sanserif bold;
color echo navy;
echo Use the available controls|to select a molecule|and change its visualization;

Trick nr. 2

While Jmol is busy (e.g. loading a file or calculating an isosurface), the display is not updated. Therefore, it is important that if you put a "please wait" message using echo, you follow it with a refresh command; that way, the message will be shown and stay there until Jmol finishes its task (often, you will need to remove the message then).

Example:

echo "Molecule is loading";
refresh;
load myMolecule.xyz;
echo;

Example:

echo "Calculating surface..."; 
refresh;
isosurface mySurface molecular;
echo;

Contributors

Ted, AngelHerraez, Ceroni