Listing of showjmol.php

<!-- This script is used to show any of the Jmol models in this directory -->
<?php

//Put route from this working directory to the root of the Jmol library into this php variable:
 $Jmolroot="../../JmolFolder"; 

// Use php to set up defaults for local php variables $use and $filestem
 if (isset($_GET["use"]))
  {
   $use=$_GET["use"];
  }
 else
  {
   $use="HTML5";
  };
 if (isset($_GET["filestem"]))
  {
   $filestem=$_GET["filestem"];
   if (! is_file($filestem.".spt"))
    {
     unset($filestem);
    };
  }
 else
  {
   unset($filestem);
  };
// $filestem will be used in making the browser tab title, in the <title> section below,
//  as well as for setting the javascript variable filestem used to make up the script load command
?>
<html>
<head>
 <title><?php echo $filestem; ?> Model</title>
<!-- The next little script sets the Jmol system up -->
       <script type="text/javascript" src="<?php echo $Jmolroot; ?>/JSmol.min.js"></script> 
<!--  then the running conditions are set in this one  --> 
       <script type="text/javascript">
        var acted=0;
        function readyfunc()
         {
          Jmol.script(JmolApplet0, "select all ; zoom 60;");
         };
        var Info = {
// Let the applet fill the whole width of the popup, but leave some space at the
//  bottom of the window for any html output
// By using %s, the applet will be resized if the window is resized
        height: "80%",
        width: "100%",
// php sets the Jmol variable Info.use
        use: "<?php echo $use; ?>",
// The next line assumes that the .jar files in the Jmol distribution have been moved
//  to the top level of the Jmol library directory
        jarPath: "<?php echo $Jmolroot; ?>",
        j2sPath: "<?php echo $Jmolroot; ?>/j2s",
// The signed applet will be used
        jarFile: "JmolAppletSigned0.jar",
        isSigned: true,
        console: "JmolApplet0_infodiv",
        readyFunction: readyfunc
        };
       </script>
</head>
<!-- Begin the working part of the html script -->
<body>
<!--
In the next script, a Jmol applet is opened with the properties set up in the head section
-->
       <script type="text/javascript">
        var filestem="<?php echo $filestem; ?>";      
        JmolApplet0 = Jmol.getApplet("JmolApplet0", Info);
// Now the applet exists, set up some Jmol parameters and load a Rasmol-style .spt script file
//  which in turn loads the model from an .xyz coordinates file.
// Because the .xyz format does not contain connectivity information, the bondTolerance
//  parameter is set so as to make Jmol show bonds where chemists consider them to be.
//  This is best found by trial and error for the molecules concerned,
//   using the Jmol.jar stand-alone Java application.
        Jmol.script(JmolApplet0, "axesOrientationRasmol=true; set measurementUnits angstroms; set bondTolerance 1.0; load "+filestem+".spt");
       </script>
<!-- A table is used to place useful Jmol buttons neatly along a row -->
<table><tr>
 <td>
<script type="text/javascript">
        Jmol.jmolButton(JmolApplet0, "select all ; spacefill on; zoom 60", "Spacefill");
  </script>
 </td>
 <td>
<script type="text/javascript">
        Jmol.jmolButton(JmolApplet0, "select all ; spacefill 140; wireframe 60; zoom 60", "Ball and Stick");
  </script>
 </td>
 <td>
<script type="text/javascript">
        Jmol.jmolButton(JmolApplet0, "set LoadStructCallback 'readyfunc'; select all ; load "+filestem+".spt", "Reload Script");
  </script>
 </td>
</tr></table>
(To measure, double click first and last atom of measurement)
</body>
</html>