Listing of muchiral.php
<?php
$filesdir="muchiral"; //Put relative location of model files (.xyz and .spt) here
// If model files are in the same directory as this file, use $filesdir=".";
//
// Use php to set up defaults for local php variables $outputype and $filestem
if (isset($_POST["outputype"]))
{
$outputype=$_POST["outputype"];
}
else
{
$outputype="HTML5.0_JSmol";
};
if (isset($_POST["filestem"]))
{
$filestem=$_POST["filestem"];
}
else
{
unset($filestem);
};
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Jmol Molecular Models">
<meta name="author" content="Bruce Tattershall">
<!-- Replace the next line with the window title for the web page -->
<title>P-N Rotamers of P4S3 imides</title>
</head>
<body>
<h3>Select the format in which molecular structures are to be shown:</h3>
<ul>
<li>JSmol requires HTML 5.0, and can be slow</li>
<li>Jmol requires Java to be installed on the client machine, but is usually much faster</li>
<!-- There could be more options in here -->
</ul>
<br>
<!--
When the following form is used, it calls the beginning of the same page again,
but sends a new value of the php variable $outputype invisibly by the 'post' method
-->
<form action="" method=post>
<input type=submit name=outputype value="HTML5.0_JSmol">
<input type=submit name=outputype value="Java_Jmol">
<!-- If there are more options, put them here -->
</form>
<br>
<!-- php fills the current value of $outputype into the following line -->
Format currently selected: <?php echo $outputype; ?>
<hr>
<!--
The next form selects the model to be displayed, by sending back to the page
a value of the php variable $filestem
It also sends back the current value of $outputype
-->
<form action="" method=post>
<input type=hidden name=outputype value="<?php echo $outputype;?>">
<!-- Specific page content starts here
Each <a> tag which would have referenced a structure file directly,
needs to be replaced by a <input> tag -->
<h3>
Assignment of Phosphorus NMR Parameters to Absolute Configurations in
Chiral Phosphorus Sulfide Cage Compounds, using Ab Initio Methods
</h3>
<p>
Bruce W. Tattershall
<br>
Z. Anorg. Allg. Chem. 2005, 631, 1627-1632
<p>
<p><b>This web page has been severely truncated for demonstration purposes.<br>
To view the whole page, please go to
<a href="https://www.staff.ncl.ac.uk/bruce.tattershall/structs/muchiral.php">
https://www.staff.ncl.ac.uk/bruce.tattershall/structs/muchiral.php</a></b></p>
<h4>
Rotatable 3D molecular structure diagrams for α-P<sub>4</sub>S<sub>3</sub>(μ-NCH(Me)Ph)
(Compound <b>4</b>)</h4>
<table BORDER width=100%>
<!-- Headings row -->
<tr>
<td>
<center>Diastereomer</center>
</td>
<td>
<center>Rotamer</center>
</td>
<td>
<center>RHF/3-21G*</center>
</td>
<td>
<center>MPW1PW91/DZVP</center>
</td>
</tr>
<!-- Rows offering models start here -->
<!-- Each table cell containing an input element is given an id
which is the same as the value of the submit button
-->
<tr>
<td>
<center><b>4(RR)S</b></center>
</td>
<td>
<center><b>r1</b>
<img SRC="muchiral/ax1df.jpg" width=191 align="center"></center>
</td>
<td id="ax1hf">
<center> <input type=submit name=filestem value="ax1hf"></center>
</td>
<td id="ax1df">
<center> <input type=submit name=filestem value="ax1df"></center>
</td>
</tr>
</table>
<!-- Here I stop this table,
put in a heading, and start another with a different layout -->
<h4>
Rotatable 3D molecular structure diagrams for β-P<sub>4</sub>S<sub>3</sub>(μ-NCH(Me)Ph)
(Compound <b>5(RS)S</b>)</h4>
<table BORDER WIDTH="100%" >
<tr>
<td>
<center>Rotamer</center>
</td>
<td>
<center>RHF/3-21G*</center>
</td>
<td>
<center>MPW1PW91/DZVP</center>
</td>
</tr>
<tr>
<td>
<center><b>r1</b>
<img SRC="muchiral/b1df.jpg" width=191 align="center"></center>
</td>
<td id="b1hf">
<center> <input type=submit name=filestem value="b1hf"></center>
</td>
<td id="b1df">
<center> <input type=submit name=filestem value="b1df"></center>
</td>
</tr>
</table>
<!-- Specific page content ends here -->
</form>
<?php
// Having $filestem set is the trigger for generating the model window
// The following works once, then $filestem is unset again,
// leaving the page ready for selection of another model
if ($filestem)
{
$winname=$filestem;
switch ($outputype)
{
case "HTML5.0_JSmol":
$filename=$filesdir."/showjmol.php?use=HTML5&filestem=".$filestem;
$suffix=false;
break;
case "Java_Jmol":
$filename=$filesdir."/showjmol.php?use=Java&filestem=".$filestem;
$suffix=false;
break;
// If there are more options, put them here
};
// The following is for any options which do not use Jmol
if ($suffix)
{
$filename=$filesdir."/".$filestem.".".$suffix;
};
// Now $filename is the URL of the window to be opened, complete with any query string,
// and $winname is the name of the new window, as seen from this script.
// The name of its browser tab will be set by its <title> in the head section
// generated by showjmol.php
?>
<!-- Open the window for the selected model -->
<script type="text/javascript">
// Functions for opening a model window, or for replacing contents of present window
//
// Function for opening a popup
function opennewwin(winhref,winobject,winname)
{
winobject=window.open(winhref,winname);
if (winobject)
{
winobject.window.focus();
return true;
}
else
{
return false;
};
};
//
// Function which opens a popup, or, if that fails, replaces current window
function neworreplace(winhref,winobject,winname)
{
var ifopen=false;
// Try to open popup window now
ifopen=opennewwin(winhref,winobject,winname);
if (! ifopen)
{
// Popup failed, so replace current page with new page
window.location.assign(winhref);
};
// Return false even if successful, so that button cannot cause form submission
return false;
};
//
// Script to show a model, by some means
var filename="<?php echo $filename;?>";
var windname="<?php echo $winname;?>";
var structwin;
var ifopen=false;
// Try to open a popup window directly from html page
ifopen=opennewwin(filename,structwin,windname);
if (! ifopen)
{
// Popup failed, so provide a button to click to show user intent
// This version is for use with form submit buttons in table cells
// When the page is called (again) as a result of clicking the submit button,
// this script will add a Continue button, below the submit button which called for it,
// and focus to bring that cell of the table into view
//
// Create a <br> to put the new button below the present one
var brk=document.createElement("br");
// Create a <center> element into which button can be put
// - this is an 'obsolete' HTML element, but still seems to work
var centr=document.createElement("center");
// Create the button itself
var buttn=document.createElement("button");
// Make the label to go on it
var buttnlabel=document.createTextNode("Continue");
// and attach the label to the button
buttn.appendChild(buttnlabel);
// The styles of the button label belong to the button, not to its label
buttn.style.fontSize="x-large";
buttn.style.backgroundColor="green";
buttn.style.color="white";
// Add the onclick attribute to the button
// This will call a function already defined on the current page in this JavaScript
buttn.setAttribute("onclick","done=neworreplace(filename,structwin,windname); return done;");
// Because the function returns false, returning its value will prevent
// the form from being resubmitted instead of the desired action of the button
// Button is ready, so put it into the center element
centr.appendChild(buttn);
// Put first the break element, then the center element into the table cell
// The id of this is the same as the value of the submit button, so when
// the page was called, the .php script knew what value to put into
// this id to be looked for
document.getElementById("<?php echo $filestem;?>").appendChild(brk);
document.getElementById("<?php echo $filestem;?>").appendChild(centr);
// Not all browsers can focus on table cell elements, but setting the tabIndex
// of the cell seems to fix this
document.getElementById("<?php echo $filestem;?>").tabIndex="1";
// Finally focus on the table cell containing the new Continue button, scrolling the
// browser window if necessary, ready for the user to click the button
document.getElementById("<?php echo $filestem;?>").focus();
};
</script>
<?php
unset($filestem);
}
?>
</body>
</html>