/*
ChimeToJmol.js
hansonr@stolaf.edu 8:07 AM 4/21/2010
# last update 10/18/2010 7:24:31 AM
A set of functions that will (when fully developed)
allow just about any Chime page to be converted automatically
from Chime EMBED tags to Jmol applets and buttons.
Also changes older Jmol "applet" code to use Jmol.js
1) Set jmolDirectory (below) to the desired directory to contain
the standard Jmol files (Jmol.js, JmolApplet*.jar)
as well as this file, ChimeToJmol.js
and add those files to it.
2) add these lines to your page's
section (with the appropriate directory, if needed):
3) If you are using a BODY onload="funcName()" attribute already,
then add
checkJmol()
to it.
4) If you want to test your page, add "?NOJMOL" to the page URL
TODO: more script conversions needed for Chime
*/
// set this as desired
var jmolDirectory = "."
var useSignedApplet = false // still, always uses signed applet for LOCAL testing
//jmolDebugAlert()
// You will probably have to adjust this next function
// to include more cases. These are just an example of the sort
// of fixes that need to be done to convert Chime scripts to Jmol scripts
function __jmolFixChimeScript(script) {
script = "set defaultLoadScript 'wireframe only;rotate x 180;';" +
script
//.replace(/\*\./g,"_") // as in *.C, *.H, for some small-molecular installations
.replace(/stick on/g,"wireframe 0.15;")
.replace(/ball\&\;stick off/g,"wireframe off;spacefill off")
.replace(/select startanim\=false/g,"animation off")
.replace(/select startanim\=true/g,"animation play")
.replace(/set cartoon/g,"#set cartoon")
.replace(/reset/g,"reset;rotate x 180")
.replace(/rotate z\s+/g,"rotate z -")
.replace(/ --/g," ")
.replace(/set shadow/g,"#set shadow")
return script
}
function __jmolGenericCallback(a, b, c, d, e) {
b || (b = "")
c || (c = "")
d || (d = "")
e || (e = "")
alert([a, b, c, d, e].join("\n\n"))
}
/////////Jmol section //////////
function checkJmol() {
if (top.location.search.indexOf("NOJMOL") >= 0)return
var body = document.body.innerHTML
if (body.indexOf("JmolApplet") >= 0) {
if(body.indexOf("JmolAppletControl") >= 0)__fixJmol()
return
}
if (body.indexOf("