// JmolCore.js -- Jmol core capability 7/22/2012 2:00:15 PM
// see JmolApi.js for public user-interface. All these are private functions
// 9/13/2012 BH: JmolCore.js changes for JSmol doAjax() method -- _getFileData()
// 6/12/2012 BH: JmolApi.js: adds Jmol.setInfo(applet, info, isShown) -- third parameter optional
// 6/12/2012 BH: JmolApi.js: adds Jmol.getInfo(applet)
// 6/12/2012 BH: JmolApplet.js: Fixes for MSIE 8
// 6/10/2012 BH: Info.useChemDoodleOnly --> Info.useNoApplet (expanding possibilities beyond just ChemDoodle)
// 6/5/2012 BH: fixes problem with Jmol "javascript" command not working and getPropertyAsArray not working
// 6/4/2012 BH: corrects problem with MSIE requiring mouse-hover to activate applet
// 5/31/2012 BH: added JSpecView interface and api -- see JmolJSV.js
// also changed "jmolJarPath" to just "jarPath"
// jmolJarFile->jarFile, jmolIsSigned->isSigned, jmolReadyFunction->readyFunction
// also corrects a double-loading issue
// 5/14/2012 BH: added AJAX queue for ChemDoodle option with multiple canvases
// 8/12/2012 BH: adds support for MSIE xdr cross-domain request (jQuery.iecors.js)
// allows Jmol applets to be created on a page with more flexibility and extendability
// provides an object-oriented interface for JSpecView and syncing of Jmol/JSpecView
// optional use of infrastructure of ChemDoodle for multiplatform doodlable structures
// required/optional libraries (preferably in the following order):
// jQuery.min.js -- required for ChemDoodle or any server-based options
// jQuery.iecors.js -- optional; allows MSIE to use direct cross-domain AJAX requests like other browsers
// gl-matrix-min.js -- required for ChemDoodle option
// mousewheel.js -- required for ChemDoodle option
// ChemDoodleWeb.js -- required for ChemDoodle option; must be after jQuery, gl-matrix-min, and mousewheel
// JmolCore.js -- required;
// JmolApplet.js -- required; internal functions for _Applet and _Image; must be after JmolCore
// JmolControls.js -- optional; internal functions for buttons, links, menus, etc.; must be after JmolCore
// JmolApi.js -- required; all user functions; must be after JmolCore
// JmolJSV.js -- optional; for creating and interacting with a JSpecView applet
// (requires JSpecViewApplet.jar or JSpecViewAppletSigned.jar
// JmolCD.js -- optional; for ChemDoodle option; must be after JmolApplet
// Allows Jmol-like objects to be displayed on Java-challenged (iPad/iPhone)
// or applet-challenged (Android/iPhone) platforms, with automatic switching to
// whatever is appropriate. You can specify "ChemDoodle-only", "Jmol-only", "Image-only"
// or some combination of those -- and of course, you are free to rewrite the logic at the top of JmolApi.js!
// Allows ChemDoodle-like 3D and 3D-faked 2D canvases that can load files via a privately hosted
// server that delivers raw data files rather than specialized JSON mol data.
// Access to iChemLabs server is not required for simple file-reading operations and
// database access. PubChem and image services are provided by a server-side PHP program
// running JmolData.jar with flags -iR (at St. Olaf College).
// For your installation, you should consider putting JmolData.jar and jmolcd.php
// on your own server. Nothing more than these two files is needed on the server.
// The NCI and RCSB databases are accessed via direct AJAX if available (xhr2).
if(typeof(jQuery)=="undefined") jQuery = null;
Jmol = (function(document) {
return {
_jmolInfo: {
userAgent:navigator.userAgent,
version: version = 'Jmol-JSO 13.0'
},
_serverUrl: "http://chemapps.stolaf.edu/jmol/jmolcd2.php",
_asynchronous: true,
_document: document,
_debugAlert: false,
_isMsie: (navigator.userAgent.toLowerCase().indexOf("msie") >= 0),
_isXHTML: false,
_XhtmlElement: null,
_XhtmlAppendChild: false,
_applets: {},
_lastAppletID: null,
_ajaxQueue: [],
db: {
_databasePrefixes: "$=:",
_fileLoadScript: ";if (_loadScript = '' && defaultLoadScript == '' && _filetype == 'Pdb') { select protein or nucleic;cartoons Only;color structure; select * };",
_nciLoadScript: ";n = ({molecule=1}.length < {molecule=2}.length ? 2 : 1); select molecule=n;display selected;center selected;",
_pubChemLoadScript: "",
_DirectDatabaseCalls:{
"cactus.nci.nih.gov": "%URL",
"www.rcsb.org": "%URL",
"pubchem.ncbi.nlm.nih.gov":"%URL",
"$": "http://cactus.nci.nih.gov/chemical/structure/%FILE/file?format=sdf&get3d=True",
"$$": "http://cactus.nci.nih.gov/chemical/structure/%FILE/file?format=sdf",
"=": "http://www.rcsb.org/pdb/files/%FILE.pdb",
"==": "http://www.rcsb.org/pdb/files/ligand/%FILE.cif",
":": "http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/%FILE/SDF?record_type=3d"
},
_restQueryUrl: "http://www.rcsb.org/pdb/rest/search",
_restQueryXml: "org.pdb.query.simple.AdvancedKeywordQueryText SearchQUERY",
_restReportUrl: "http://www.pdb.org/pdb/rest/customReport?pdbids=IDLIST&customReportColumns=structureId,structureTitle"
},
_getCanvas: function(){ /* only in JmolCD.js or JmolGLmol.js */ return null },
_allowedJmolSize: [25, 2048, 300] // min, max, default (pixels)
/* By setting the Jmol.allowedJmolSize[] variable in the webpage
before calling Jmol.getApplet(), limits for applet size can be overriden.
2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html)
*/
}
})(document);
(function (Jmol) {
// Jmol core functionality
Jmol._registerApplet = function(id, applet) {
return Jmol._applets[id] = Jmol._applets[applet] = applet;
}
Jmol._readyCallback = function (a,b,c,d) {
var app = a.split("_object")[0];
// necessary for MSIE in strict mode -- apparently, we can't call
// jmol._readyCallback, but we can call Jmol._readyCallback. Go figure...
Jmol._applets[app]._readyCallback(a,b,c,d);
}
Jmol._ajax = function(info) {
if (!info.async) {
return jQuery.ajax(info).responseText;
}
Jmol._ajaxQueue.push(info)
if (Jmol._ajaxQueue.length == 1)
Jmol._ajaxDone()
}
Jmol._ajaxDone = function() {
var info = Jmol._ajaxQueue.shift();
info && jQuery.ajax(info);
}
Jmol._grabberOptions = [
["$", "NCI(small molecules)"],
[":", "PubChem(small molecules)"],
["=", "RCSB(macromolecules)"]
];
Jmol._getGrabberOptions = function(applet, note) {
// feel free to adjust this look to anything you want
if (!jQuery || Jmol._grabberOptions.length == 0)
return ""
var s = '';
var b = ''
if (Jmol._grabberOptions.length == 1) {
s = '' + s + '';
b = '' + b;
} else {
s += ' '
}
s += '' + b).replace(/ID/g, applet._id) + (note ? note : "");
return ' ' + s;
}
Jmol._getWrapper = function(applet, isHeader) {
var height = applet._height;
var width = applet._width;
if (typeof height !== "string" || height.indexOf("%") < 0)
height += "px";
if (typeof width !== "string" || width.indexOf("%") < 0)
width += "px";
// id_appletinfotablediv
// id_appletdiv
// id_infotablediv
// id_infoheaderdiv
// id_infoheaderspan
// id_infocheckboxspan
// id_infodiv
// for whatever reason, without DOCTYPE, with MSIE, "height:auto" does not work,
// and the text scrolls off the page.
// So I'm using height:95% here.
// The table was a fix for MSIE with no DOCTYPE tag to fix the miscalculation
// in height of the div when using 95% for height.
// But it turns out the table has problems with DOCTYPE tags, so that's out.
// The 95% is a compromise that we need until the no-DOCTYPE MSIE solution is found.
// (100% does not work with the JME linked applet)
var s = (isHeader ? "