UNPKG

biojs-vis-pdbviewer

Version:

A BioJS 2.0 component to view protein structures

106 lines 53.1 kB
(function(a){function h(a){try{return a?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest}catch(c){}}a.ajaxSettings.xhr=void 0===window.ActiveXObject?h:function(){return(this.url==document.location||0==this.url.indexOf("http")||!this.isLocal)&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&h()||h(1)};a.extend(a.support,{iecors:!!window.XDomainRequest});a.support.iecors?a.ajaxTransport(function(a){return{send:function(c,g){var l=new window.XDomainRequest;l.onload=function(){g(200,
"OK",{text:l.responseText},{"Content-Type":l.contentType})};a.xhrFields&&(l.onerror=a.xhrFields.error,l.ontimeout=a.xhrFields.timeout);l.open(a.type,a.url);l.send(a.hasContent&&a.data||null)},abort:function(){xdr.abort()}}}):(a.ajaxSetup({accepts:{binary:"text/plain; charset=x-user-defined"},responseFields:{binary:"response"}}),a.ajaxTransport("binary",function(a){var c;return{send:function(g,l){var h=a.xhr();h.open(a.type,a.url,a.async);var k=!1;try{h.hasOwnProperty("responseType")&&(h.responseType=
"arraybuffer",k=!0)}catch(b){}try{!k&&h.overrideMimeType&&h.overrideMimeType("text/plain; charset=x-user-defined")}catch(d){}!a.crossDomain&&!g["X-Requested-With"]&&(g["X-Requested-With"]="XMLHttpRequest");try{for(var e in g)h.setRequestHeader(e,g[e])}catch(m){}h.send(a.hasContent&&a.data||null);c=function(){var b=h.status,d="",e=h.getAllResponseHeaders(),m={};try{if(c&&4===h.readyState){c=void 0;try{m.text="string"===typeof h.responseText?h.responseText:null}catch(g){}try{m.binary=h.response}catch(k){}try{d=
h.statusText}catch(s){d=""}!b&&a.isLocal&&!a.crossDomain?b=m.text?200:404:1223===b&&(b=204);l(b,d,m,e)}}catch(r){alert(r),l(-1,r)}};a.async?4===h.readyState?setTimeout(c):h.onreadystatechange=c:c()},abort:function(){}}}))})(jQuery);
(function(a,h,f,c){function g(f,g){function k(d){a(b).each(function(){self.Jmol&&(0<=g.indexOf("mouseup")||0<=g.indexOf("touchend"))&&Jmol._setMouseOwner(null);var b=a(this);this!==d.target&&!b.has(d.target).length&&b.triggerHandler(g,[d.target,d])})}g=g||f+c;var b=a(),d=f+"."+g+"-special-event";a.event.special[g]={setup:function(){b=b.add(this);1===b.length&&a(h).bind(d,k)},teardown:function(){self.Jmol&&Jmol._setMouseOwner(null);b=b.not(this);0===b.length&&a(h).unbind(d)},add:function(b){var a=
b.handler;b.handler=function(b,d){b.target=d;a.apply(this,arguments)}}}}a.map(f.split(" "),function(a){g(a)});g("focusin","focus"+c);g("focusout","blur"+c)})(jQuery,document,"click mousemove mouseup touchmove touchend","outjsmol");"undefined"==typeof jQuery&&alert("Note -- JSmoljQuery is required for JSmol, but it's not defined.");self.Jmol||(Jmol={});
Jmol._version||(Jmol=function(a){var h=function(a){return{header:a++,rear:a++,main:a++,image:a++,front:a++,fileOpener:a++,coverImage:a++,dialog:a++,menu:a+9E4,console:a+91E3,monitorZIndex:a+99999}},h={_version:"JSmol 14.2.3 July 23, 2014",_alertNoBinary:!0,_allowedJmolSize:[25,2048,300],_fileCache:null,_jarFile:null,_j2sPath:null,_use:null,_j2sLoadMonitorOpacity:90,_applets:{},_asynchronous:!0,_ajaxQueue:[],_getZOrders:h,_z:h(Jmol.z||9E3),_debugCode:!0,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","pdbe.org":"%URL","www.ebi.ac.uk":"%URL","wwwdev.ebi.ac.uk":"%URL","pubchem.ncbi.nlm.nih.gov":"%URL","http://www.nmrdb.org/tools/jmol/predict.php":"%URL",$:"http://cactus.nci.nih.gov/chemical/structure/%FILENCI/file?format=sdf&get3d=True",$$:"http://cactus.nci.nih.gov/chemical/structure/%FILENCI/file?format=sdf",
"=":"http://www.rcsb.org/pdb/files/%FILE.pdb","*":"http://www.ebi.ac.uk/pdbe/entry-files/download/%FILE.cif","==":"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:"<orgPdbQuery><queryType>org.pdb.query.simple.AdvancedKeywordQuery</queryType><description>Text Search</description><keywords>QUERY</keywords></orgPdbQuery>",_restReportUrl:"http://www.pdb.org/pdb/rest/customReport?pdbids=IDLIST&customReportColumns=structureId,structureTitle"},
_debugAlert:!1,_document:a,_isXHTML:!1,_lastAppletID:null,_mousePageX:null,_mouseOwner:null,_serverUrl:"http://your.server.here/jsmol.php",_syncId:(""+Math.random()).substring(3),_touching:!1,_XhtmlElement:null,_XhtmlAppendChild:!1};a=a.location.href.toLowerCase();h._httpProto=0==a.indexOf("https")?"https://":"http://";h._isFile=0==a.indexOf("file:");h._ajaxTestSite=h._httpProto+"google.com";a=h._isFile||0==a.indexOf("http://localhost")||0==a.indexOf("http://127.");h._tracker="http://"==h._httpProto&&
!a&&"http://chemapps.stolaf.edu/jmol/JmolTracker.htm?id=UA-45940799-1";h._isChrome=0<=navigator.userAgent.toLowerCase().indexOf("chrome");h._isSafari=!h._isChrome&&0<=navigator.userAgent.toLowerCase().indexOf("safari");h._isMsie=void 0!==window.ActiveXObject;h._useDataURI=!h._isSafari&&!h._isMsie;for(var f in Jmol)h[f]=Jmol[f];return h}(document,Jmol));
(function(a,h){a.$=function(b,a){null==b&&alert(a+arguments.callee.caller.toString());return h(a?"#"+b._id+"_"+a:b)};a._$=function(b){return"string"==typeof b?h("#"+b):b};a.$ajax=function(b){a._ajaxCall=b.url;b.cache="NO"!=b.cache;0==b.url.indexOf("http://pubchem.ncbi.nlm.nih")&&(b.url="https://"+b.url.substring(7));return h.ajax(b)};a._getNCIInfo=function(b,d){"name"==d&&(d="names");url="http://cactus.nci.nih.gov/chemical/structure/"+b+"/"+d;return a._getFileData(url)};a.$appEvent=function(b,d,e,
f){b=a.$(b,d);b.off(e)&&f&&b.on(e,f)};a.$resize=function(b){return h(window).resize(b)};a.$after=function(b,a){return h(b).after(a)};a.$bind=function(b,a,e){return e?h(b).bind(a,e):h(b).unbind(a)};a.$closest=function(b,a){return h(b).closest(a)};a.$get=function(b,a){return h(b).get(a)};a.$documentOff=function(b,a){return h(document).off(b,"#"+a)};a.$documentOn=function(b,a,e){return h(document).on(b,"#"+a,e)};a.$getAncestorDiv=function(b,a){return h("div."+a+":has(#"+b+")")[0]};a.$supportsIECrossDomainScripting=
function(){return h.support.iecors};a.$attr=function(b,d,e){return a._$(b).attr(d,e)};a.$css=function(b,d){return a._$(b).css(d)};a.$find=function(b,d){return a._$(b).find(d)};a.$focus=function(b){return a._$(b).focus()};a.$html=function(b,d){return a._$(b).html(d)};a.$offset=function(b){return a._$(b).offset()};a.$windowOn=function(b,a){return h(window).on(b,a)};a.$prop=function(b,d,e){var f=a._$(b);return 3==arguments.length?f.prop(d,e):f.prop(d)};a.$remove=function(b){return a._$(b).remove()};
a.$scrollTo=function(b,d){var e=a._$(b);return e.scrollTop(0>d?e[0].scrollHeight:d)};a.$setEnabled=function(b,d){return a._$(b).attr("disabled",d?null:"disabled")};a.$setSize=function(b,d,e){return a._$(b).width(d).height(e)};a.$setVisible=function(b,d){var e=a._$(b);return d?e.show():e.hide()};a.$submit=function(b){return a._$(b).submit()};a.$val=function(b,d){var e=a._$(b);return 1==arguments.length?e.val():e.val(d)};a._clearVars=function(){delete jQuery;delete h;delete a;delete SwingController;
delete J;delete JM;delete JS;delete JSV;delete JU;delete JV;delete java;delete javajs;delete Clazz;delete c$};var f=document,c=window,g={};g.ua=navigator.userAgent.toLowerCase();var l;a:{l=["linux","unix","mac","win"];for(var j=l.length;j--;)if(-1!=g.ua.indexOf(l[j])){l=l[j];break a}l="unknown"}g.os=l;g.browser=function(){for(var b=g.ua,a="konqueror webkit omniweb opera webtv icab msie mozilla".split(" "),e=0;e<a.length;e++)if(0<=b.indexOf(a[e]))return a[e];return"unknown"};g.browserName=g.browser();
g.browserVersion=parseFloat(g.ua.substring(g.ua.indexOf(g.browserName)+g.browserName.length+1));g.supportsXhr2=function(){return h.support.cors||h.support.iecors};g.allowDestroy="msie"!=g.browserName;g.allowHTML5="msie"!=g.browserName||0>navigator.appVersion.indexOf("MSIE 8");g.getDefaultLanguage=function(){return navigator.language||navigator.userLanguage||"en-US"};g._webGLtest=0;g.supportsWebGL=function(){if(!a.featureDetection._webGLtest){var b;a.featureDetection._webGLtest=c.WebGLRenderingContext&&
((b=f.createElement("canvas")).getContext("webgl")||b.getContext("experimental-webgl"))?1:-1}return 0<a.featureDetection._webGLtest};g.supportsLocalization=function(){for(var b=f.getElementsByTagName("meta"),a=b.length;0<=--a;)if(0<=b[a].outerHTML.toLowerCase().indexOf("utf-8"))return!0;return!1};g.supportsJava=function(){a.featureDetection._javaEnabled||(a.featureDetection._javaEnabled=a._isMsie?navigator.javaEnabled()?1:-1:navigator.javaEnabled()&&(!navigator.mimeTypes||navigator.mimeTypes["application/x-java-applet"])?
1:-1);return 0<a.featureDetection._javaEnabled};g.compliantBrowser=function(){var b=!!f.getElementById,a=g.os;if("opera"==g.browserName&&7.54>=g.browserVersion&&"mac"==a||"webkit"==g.browserName&&125.12>g.browserVersion||"msie"==g.browserName&&"mac"==a||"konqueror"==g.browserName&&3.3>=g.browserVersion)b=!1;return b};g.isFullyCompliant=function(){return g.compliantBrowser()&&g.supportsJava()};g.useIEObject="win"==g.os&&"msie"==g.browserName&&5.5<=g.browserVersion;g.useHtml4Object="mozilla"==g.browserName&&
5<=g.browserVersion||"opera"==g.browserName&&8<=g.browserVersion||"webkit"==g.browserName;g.hasFileReader=c.File&&c.FileReader;a.featureDetection=g;a._ajax=function(b){if(!b.async)return a.$ajax(b).responseText;a._ajaxQueue.push(b);1==a._ajaxQueue.length&&a._ajaxDone()};a._ajaxDone=function(){var b=a._ajaxQueue.shift();b&&a.$ajax(b)};a._grabberOptions=[["$","NCI(small molecules)"],[":","PubChem(small molecules)"],["=","RCSB(macromolecules)"],["*","PDBe(macromolecules)"]];a._getGrabberOptions=function(b){if(0==
a._grabberOptions.length)return"";var d='<input type="text" id="ID_query" onfocus="jQuery(this).select()" onkeypress="if(13==event.which){Jmol._applets[\'ID\']._search();return false}" size="32" value="" />',e='<button id="ID_submit" onclick="Jmol._applets[\'ID\']._search()">Search</button></nobr>';1==a._grabberOptions.length?(d="<nobr>"+d+'<span style="display:none">',e="</span>"+e):d+="<br /><nobr>";for(var d=d+'<select id="ID_select">',f=0;f<a._grabberOptions.length;f++)var c=a._grabberOptions[f],
d=d+('<option value="'+c[0]+'" '+(0==f?"selected":"")+">"+c[1]+"</option>");d=(d+"</select>"+e).replace(/ID/g,b._id);return"<br />"+d};a._getScriptForDatabase=function(b){return"$"==b?a.db._nciLoadScript:":"==b?a.db._pubChemLoadScript:a.db._fileLoadScript};a._setInfo=function(b,a,e){var f=[],c="";if(0==e.indexOf("ERROR"))c=e;else switch(a){case "=":a=e.split("<dimStructure.structureId>");f=["<table>"];for(e=1;e<a.length;e++)f.push('<tr><td valign=top><a href="javascript:Jmol.search('+b._id+",'="+
a[e].substring(0,4)+"')\">"+a[e].substring(0,4)+"</a></td>"),f.push("<td>"+a[e].split("Title>")[1].split("</")[0]+"</td></tr>");f.push("</table>");c=a.length-1+" matches";break;case "$":case ":":break;default:return}b._infoHeader=c;b._info=f.join("");b._showInfo(!0)};a._loadSuccess=function(b,d){d&&(a._ajaxDone(),d(b))};a._loadError=function(b){a._ajaxDone();a.say("Error connecting to server: "+a._ajaxCall);null!=b&&b()};a._isDatabaseCall=function(b){return 0<=a.db._databasePrefixes.indexOf(b.substring(0,
1))};a._getDirectDatabaseCall=function(b,d){if(d&&!a.featureDetection.supportsXhr2())return b;var e=2,f,c=a.db._DirectDatabaseCalls[b.substring(0,e)];c||(c=a.db._DirectDatabaseCalls[f=b.substring(0,--e)]);c&&(":"==f?(f=b.toLowerCase(),isNaN(parseInt(b.substring(1)))?0==f.indexOf(":smiles:")?(c+="?POST?smiles="+b.substring(8),b="smiles"):0==f.indexOf(":cid:")?b="cid/"+b.substring(5):(0==f.indexOf(":name:")?b=b.substring(5):0==f.indexOf(":cas:")&&(b=b.substring(4)),b="name/"+encodeURIComponent(b.substring(e))):
b="cid/"+b.substring(1)):b=encodeURIComponent(b.substring(e)),0<=c.indexOf("FILENCI")?(b=b.replace(/\%2F/g,"/"),b=c.replace(/\%FILENCI/,b)):b=c.replace(/\%FILE/,b));return b};a._getRawDataFromServer=function(b,d,e,f,c,g){b="?call=getRawDataFromDatabase&database="+b+(0<=d.indexOf("?POST?")?"?POST?":"")+"&query="+encodeURIComponent(d)+(c?"&encoding=base64":"")+(g?"":"&script="+encodeURIComponent(a._getScriptForDatabase(b)));return a._contactServer(b,e,f)};a._checkFileName=function(b,d,e){a._isDatabaseCall(d)&&
(e&&a._setQueryTerm(b,d),d=a._getDirectDatabaseCall(d,!0),a._isDatabaseCall(d)&&(d=a._getDirectDatabaseCall(d,!1),e&&(e[0]=!0)));return d};a._checkCache=function(b,d,e){if(b._cacheFiles&&a._fileCache&&!d.endsWith(".js")){if(b=a._fileCache[d])return System.out.println("using "+b.length+" bytes of cached data for "+d),e(b),null;e=function(b,d){e(a._fileCache[b]=d)}}return e};a._loadFileData=function(b,d,e,f){var c=[];d=a._checkFileName(b,d,c);e=a._checkCache(b,d,e);c[0]?a._getRawDataFromServer("_",
d,e,f):(b={type:"GET",dataType:"text",url:d,async:a._asynchronous,success:function(b){a._loadSuccess(b,e)},error:function(){a._loadError(f)}},a._checkAjaxPost(b),a._ajax(b))};a._getInfoFromDatabase=function(b,d,e){if("===="==d){var f=a.db._restQueryXml.replace(/QUERY/,e),f={dataType:"text",type:"POST",contentType:"application/x-www-form-urlencoded",url:a.db._restQueryUrl,data:encodeURIComponent(f)+"&req=browser",success:function(f){a._ajaxDone();a._extractInfoFromRCSB(b,d,e,f)},error:function(){a._loadError(null)},
async:a._asynchronous};return a._ajax(f)}e="?call=getInfoFromDatabase&database="+d+"&query="+encodeURIComponent(e);return a._contactServer(e,function(e){a._setInfo(b,d,e)})};a._extractInfoFromRCSB=function(b,d,e,f){var c=f.length/5;if(0!=c&&4==e.length&&1!=c){e=e.toUpperCase();var g=f.indexOf(e);0<g&&0<="123456789".indexOf(e.substring(0,1))&&(f=e+","+f.substring(0,g)+f.substring(g+5));50<c&&(f=f.substring(0,250));f=f.replace(/\n/g,",");f=a._restReportUrl.replace(/IDLIST/,f);a._loadFileData(b,f,function(e){a._setInfo(b,
d,e)})}};a._checkAjaxPost=function(b){var a=b.url.indexOf("?POST?");0<a&&(b.data=b.url.substring(a+6),b.url=b.url.substring(0,a),b.type="POST",b.contentType="application/x-www-form-urlencoded")};a._contactServer=function(b,d,e){b={dataType:"text",type:"GET",url:a._serverUrl+b,success:function(b){a._loadSuccess(b,d)},error:function(){a._loadError(e)},async:d?a._asynchronous:!1};a._checkAjaxPost(b);return a._ajax(b)};a._setQueryTerm=function(b,d){if(d&&b._hasOptions&&"http://"!=d.substring(0,7)){if(a._isDatabaseCall(d)){var e=
d.substring(0,1);d=d.substring(1);d.substring(0,1)==e&&0<="=$".indexOf(e)&&(d=d.substring(1));var f=a._getElement(b,"select");if(f&&f.options)for(var c=0;c<f.options.length;c++)f[c].value==e&&(f[c].selected=!0)}a.$val(a.$(b,"query"),d)}};a._search=function(b,d,e){1<arguments.length||(d=null);a._setQueryTerm(b,d);d||(d=a.$val(a.$(b,"query")));0==d.indexOf("!")?b._script(d.substring(1)):(d&&(d=d.replace(/\"/g,"")),b._showInfo(!1),a._searchMol(b,d,e,!0))};a._searchMol=function(b,d,e,f){var c;a._isDatabaseCall(d)?
(c=d.substring(0,1),d=d.substring(1)):c=b._hasOptions?a.$val(a.$(b,"select")):"$";"="==c&&3==d.length&&(d="="+d);var g=c+d;if(d&&!(0>g.indexOf("?")&&g==b._thisJmolModel)){b._thisJmolModel=g;var h;f&&null!=b._viewSet&&null!=(h=a.View.__findView(b._viewSet,{chemID:g}))?a.View.__setView(h,b,!1):("$"==c||":"==c?b._jmolFileType="MOL":"="==c&&(b._jmolFileType="PDB"),b._searchDatabase(d,c,e))}};a._searchDatabase=function(b,d,e,f){b._showInfo(!1);return 0<=d.indexOf("?")?(a._getInfoFromDatabase(b,e,d.split("?")[0]),
!0):a.db._DirectDatabaseCalls[e]?(b._loadFile(e+d,f),!0):!1};a._syncBinaryOK="?";a._canSyncBinary=function(b){if(self.VBArray)return a._syncBinaryOK=!1;if("?"!=a._syncBinaryOK)return a._syncBinaryOK;a._syncBinaryOK=!0;try{var d=new window.XMLHttpRequest;d.open("text",a._ajaxTestSite,!1);d.hasOwnProperty("responseType")?d.responseType="arraybuffer":d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined")}catch(e){return System.out.println("JSmolCore.js: synchronous binary file transfer is requested but not available"),
a._alertNoBinary&&!b&&alert("JSmolCore.js: synchronous binary file transfer is requested but not available"),a._syncBinaryOK=!1}return!0};a._binaryTypes=".gz .jpg .png .zip .jmol .bin .smol .spartan .mrc .pse .map .omap".split(" ");a._isBinaryUrl=function(b){for(var d=a._binaryTypes.length;0<=--d;)if(0<=b.indexOf(a._binaryTypes[d]))return!0;return!1};a._getFileData=function(b,d){var e=a._isBinaryUrl(b)?"binary":"text",f=0<=b.indexOf("pdb.gz")&&0==b.indexOf("http://www.rcsb.org/pdb/files/"),c="binary"==
e&&!a._canSyncBinary(f);c&&f&&(b=b.replace(/pdb\.gz/,"pdb"),c=!1,e="text");f=0<=b.indexOf("?POST?");0==b.indexOf("file:/")&&0!=b.indexOf("file:///")&&(b="file://"+b.substring(5));var g=0>b.indexOf("://")||0==b.indexOf(document.location.protocol)&&0<=b.indexOf(document.location.host),h=a._isDirectCall(b),l=!g&&a.$supportsIECrossDomainScripting();if(!d||c)if(l||c||!g&&!h)return a._getRawDataFromServer("_",b,d,d,c,!0);b=b.replace(/file:\/\/\/\//,"file://");var j={dataType:e,async:!!d};f?(j.type="POST",
j.url=b.split("?POST?")[0],j.data=b.split("?POST?")[1]):(j.type="GET",j.url=b);d&&(j.success=function(){d(a._xhrReturn(j.xhr))},j.error=function(){d(xhr.statusText)});j.xhr=a.$ajax(j);if(!d)return a._xhrReturn(j.xhr)};a._xhrReturn=function(b){return!b.responseText||self.Clazz&&Clazz.instanceOf(b.response,self.ArrayBuffer)?b.response||b.statusText:b.responseText};a._isDirectCall=function(b){for(var d in a.db._DirectDatabaseCalls)if(0<=d.indexOf(".")&&0<=b.indexOf(d))return!0;return!1};a._cleanFileData=
function(b){return 0<=b.indexOf("\r")&&0<=b.indexOf("\n")?b.replace(/\r\n/g,"\n"):0<=b.indexOf("\r")?b.replace(/\r/g,"\n"):b};a._getFileType=function(b){var a=b.substring(0,1);if("$"==a||":"==a)return"MOL";if("="==a)return"="==b.substring(1,2)?"LCIF":"PDB";b=b.split(".").pop().toUpperCase();return b.substring(0,Math.min(b.length,3))};a._getZ=function(b,d){return b&&b._z&&b._z[d]||a._z[d]};a._incrZ=function(b,d){return b&&b._z&&++b._z[d]||++a._z[d]};a._loadFileAsynchronously=function(b,d,e,f){if(0!=
e.indexOf("?")){e=a._checkFileName(d,e);var c=function(d){a._setData(b,e,d,f)},c=a._checkCache(d,e,c);return null==c?null:a._getFileData(e,c)}if(!a.featureDetection.hasFileReader)return b.setData("Local file reading is not enabled in your browser",null,f);d._localReader||(c='<div id="ID" style="z-index:'+a._getZ(d,"fileOpener")+';position:absolute;background:#E0E0E0;left:10px;top:10px"><div style="margin:5px 5px 5px 5px;"><input type="file" id="ID_files" /><button id="ID_loadfile">load</button><button id="ID_cancel">cancel</button></div><div>',
a.$after("#"+d._id+"_appletdiv",c.replace(/ID/g,d._id+"_localReader")),d._localReader=a.$(d,"localReader"));a.$appEvent(d,"localReader_loadfile","click");a.$appEvent(d,"localReader_loadfile","click",function(){var e=a.$(d,"localReader_files")[0].files[0],c=new FileReader;c.onloadend=function(c){c.target.readyState==FileReader.DONE&&(a.$css(a.$(d,"localReader"),{display:"none"}),a._setData(b,e.name,c.target.result,f))};c.readAsArrayBuffer(e)});a.$appEvent(d,"localReader_cancel","click");a.$appEvent(d,
"localReader_cancel","click",function(){a.$css(a.$(d,"localReader"),{display:"none"});b.setData(null,f)});a.$css(a.$(d,"localReader"),{display:"block"})};a._setData=function(b,d,e,f){e=a._strToBytes(e);0<=d.indexOf(".jdx")&&a.Cache.put("cache://"+d,e);b.setData(d,e,f)};a._toBytes=function(b){if("string"==typeof b)return b.getBytes();b=new Uint8Array(b);for(var a=Clazz.newByteArray(b.length,0),e=b.length;0<=--e;)a[e]=b[e];return a};a._doAjax=function(b,d,e){b=b.toString();if(null!=e)return a._saveFile(b,
e);d&&(b+="?POST?"+d);d=a._getFileData(b);return a._processData(d,a._isBinaryUrl(b))};a._saveFile=function(b,d,e,f){if(a._localFileSaveFunction&&a._localFileSaveFunction(b,d))return"OK";b=b.substring(b.lastIndexOf("/")+1);e||(e=0<=b.indexOf(".pdf")?"application/pdf":0<=b.indexOf(".png")?"image/png":0<=b.indexOf(".jpg")?"image/jpg":"");var c="string"==typeof d;c||(d=(JU?JU:J.util).Base64.getBase64(d).toString());f||(f=c?"":"base64");(c=a._serverUrl)&&0<=c.indexOf("your.server")&&(c="");a._useDataURI||
!c?(f||(d=btoa(d)),f=document.createElement("a"),f.href="data:"+e+";base64,"+d,f.type=e||"text/plain",f.download=b,f.target="_blank",h("body").append(f),f.click(),f.remove()):(a._formdiv||(a.$after("body",'<div id="__jsmolformdiv__" style="display:none">\t\t\t\t\t\t<form id="__jsmolform__" method="post" target="_blank" action="">\t\t\t\t\t\t<input name="call" value="saveFile"/>\t\t\t\t\t\t<input id="__jsmolmimetype__" name="mimetype" value=""/>\t\t\t\t\t\t<input id="__jsmolencoding__" name="encoding" value=""/>\t\t\t\t\t\t<input id="__jsmolfilename__" name="filename" value=""/>\t\t\t\t\t\t<textarea id="__jsmoldata__" name="data"></textarea>\t\t\t\t\t\t</form>\t\t\t\t\t\t</div>'),
a._formdiv="__jsmolform__"),a.$attr(a._formdiv,"action",c+"?"+(new Date).getMilliseconds()),a.$val("__jsmoldata__",d),a.$val("__jsmolfilename__",b),a.$val("__jsmolmimetype__",e),a.$val("__jsmolencoding__",f),a.$submit("__jsmolform__"),a.$val("__jsmoldata__",""),a.$val("__jsmolfilename__",""));return"OK"};a._processData=function(b,d){"undefined"==typeof b&&(b="",d=!1);d&&(d=a._canSyncBinary());return d?a._strToBytes(b):JU.SB.newS(b)};a._strToBytes=function(b){if(Clazz.instanceOf(b,self.ArrayBuffer))return a._toBytes(b);
for(var d=Clazz.newByteArray(b.length,0),e=b.length;0<=--e;)d[e]=b.charCodeAt(e)&255;return d};a._setConsoleDiv=function(b){self.Clazz&&Clazz.setConsoleDiv(b)};a._registerApplet=function(b,d){return window[b]=a._applets[b]=a._applets[d]=a._applets[b+"__"+a._syncId+"__"]=d};a._readyCallback=function(b,d,e,f){b=b.split("_object")[0];e=e.booleanValue?e.booleanValue():e;a._track(a._applets[b])._readyCallback(b,d,e,f)};a._getWrapper=function(b,d){var e;if(d){var f="";b._coverImage&&(e=' onclick="Jmol.coverApplet(ID, false)" title="'+
b._coverTitle+'"',f='<image id="ID_coverclickgo" src="'+b._j2sPath+'/img/play_make_live.jpg" style="width:25px;height:25px;position:absolute;bottom:10px;left:10px;z-index:'+a._getZ(b,"coverImage")+';opacity:0.5;"'+e+" />",f='<div id="ID_coverdiv" style="background-color:red;z-index:'+a._getZ(b,"coverImage")+';width:100%;height:100%;display:inline;position:absolute;top:0px;left:0px"><image id="ID_coverimage" src="'+b._coverImage+'" style="width:100%;height:100%"'+e+"/>"+f+"</div>");e='...<div id="ID_appletinfotablediv" style="width:Wpx;height:Hpx;position:relative;font-size:14px;text-align:left">IMG......<div id="ID_appletdiv" style="z-index:'+
a._getZ(b,"header")+';width:100%;height:100%;position:absolute;top:0px;left:0px;">';var c=b._height,g=b._width;if("string"!==typeof c||0>c.indexOf("%"))c+="px";if("string"!==typeof g||0>g.indexOf("%"))g+="px";e=e.replace(/IMG/,f).replace(/Hpx/g,c).replace(/Wpx/g,g)}else e='......</div>......<div id="ID_2dappletdiv" style="position:absolute;width:100%;height:100%;overflow:hidden;display:none"></div>......<div id="ID_infotablediv" style="width:100%;height:100%;position:absolute;top:0px;left:0px">.........<div id="ID_infoheaderdiv" style="height:20px;width:100%;background:yellow;display:none"><span id="ID_infoheaderspan"></span><span id="ID_infocheckboxspan" style="position:absolute;text-align:right;right:1px;"><a href="javascript:Jmol.showInfo(ID,false)">[x]</a></span></div>.........<div id="ID_infodiv" style="position:absolute;top:20px;bottom:0px;width:100%;height:100%;overflow:auto"></div>......</div>...</div>';
return e.replace(/\.\.\./g,"").replace(/[\n\r]/g,"").replace(/ID/g,b._id)};a._documentWrite=function(b){if(a._document){if(a._isXHTML&&!a._XhtmlElement){var d=document.getElementsByTagName("script");a._XhtmlElement=d.item(d.length-1);a._XhtmlAppendChild=!1}a._XhtmlElement?a._domWrite(b):a._document.write(b)}return b};a._domWrite=function(b){for(var d=[0];d[0]<b.length;){var e=a._getDomElement(b,d);if(!e)break;a._XhtmlAppendChild?a._XhtmlElement.appendChild(e):a._XhtmlElement.parentNode.insertBefore(e,
_jmol.XhtmlElement)}};a._getDomElement=function(b,a){var e=document.createElement("span");e.innerHTML=b;a[0]=b.length;return e};a._setObject=function(b,d,e){b._id=d;b.__Info={};e.z&&e.zIndexBase&&(a._z=a._getZOrders(e.zIndexBase));for(var f in e)b.__Info[f]=e[f];(b._z=e.z)||e.zIndexBase&&(b._z=b.__Info.z=a._getZOrders(e.zIndexBase));b._width=e.width;b._height=e.height;b._noscript=!b._isJava&&e.noscript;b._console=e.console;b._cacheFiles=!!e.cacheFiles;b._viewSet=null==e.viewSet||b._isJava?null:"Set"+
e.viewSet;null!=b._viewSet&&(a.View.__init(b),b._currentView=null);!a._fileCache&&b._cacheFiles&&(a._fileCache={});b._console||(b._console=b._id+"_infodiv");"none"==b._console&&(b._console=null);b._color=e.color?e.color.replace(/0x/,"#"):"#FFFFFF";b._disableInitialConsole=e.disableInitialConsole;b._noMonitor=e.disableJ2SLoadMonitor;a._j2sPath&&(e.j2sPath=a._j2sPath);b._j2sPath=e.j2sPath;b._deferApplet=e.deferApplet;b._deferUncover=e.deferUncover;b._coverImage=!b._isJava&&e.coverImage;b._isCovered=
!!b._coverImage;b._coverScript=e.coverScript;b._coverTitle=e.coverTitle;b._coverTitle||(b._coverTitle=b._deferApplet?"activate 3D model":"3D model is loading...");b._containerWidth=b._width+(b._width==parseFloat(b._width)?"px":"");b._containerHeight=b._height+(b._height==parseFloat(b._height)?"px":"");b._info="";b._infoHeader=b._jmolType+' "'+b._id+'"';b._hasOptions=e.addSelectionOptions;b._defaultModel=e.defaultModel;b._readyScript=e.script?e.script:"";b._readyFunction=e.readyFunction;b._coverImage&&
!b._deferApplet&&(b._readyScript+=";javascript "+d+"._displayCoverImage(false)");b._src=e.src};a._addDefaultInfo=function(b,d){for(var e in d)"undefined"==typeof b[e]&&(b[e]=d[e]);a._use&&(b.use=a._use);0<=b.use.indexOf("SIGNED")&&(0>b.jarFile.indexOf("Signed")&&(b.jarFile=b.jarFile.replace(/Applet/,"AppletSigned")),b.use=b.use.replace(/SIGNED/,"JAVA"),b.isSigned=!0)};a._syncedApplets=[];a._syncedCommands=[];a._syncedReady=[];a._syncReady=!1;a._isJmolJSVSync=!1;a._setReady=function(b){a._syncedReady[b]=
1;for(var d=0,e=0;e<a._syncedApplets.length;e++){if(a._syncedApplets[e]==b._id)a._syncedApplets[e]=b,a._syncedReady[e]=1;else if(!a._syncedReady[e])continue;d++}d==a._syncedApplets.length&&a._setSyncReady()};a._setDestroy=function(b){a.featureDetection.allowDestroy&&a.$windowOn("beforeunload",function(){a._destroy(b)})};a._destroy=function(b){try{b._applet&&b._applet.destroy();b._applet=null;a._unsetMouse(b._canvas);b._canvas=null;for(var d=0,e=0;e<a._syncedApplets.length;e++)a._syncedApplets[e]==
b&&(a._syncedApplets[e]=null),a._syncedApplets[e]&&d++;0<d||a._clearVars()}catch(f){}};a._setSyncReady=function(){a._syncReady=!0;for(var b="",d=0;d<a._syncedApplets.length;d++)a._syncedCommands[d]&&(b+="Jmol.script(Jmol._syncedApplets["+d+"], Jmol._syncedCommands["+d+"]);");setTimeout(b,50)};a._mySyncCallback=function(b,d){app=a._applets[b];if(app._viewSet)a.View.updateFromSync(app,d);else{if(!a._syncReady||!a._isJmolJSVSync)return 1;for(var e=0;e<a._syncedApplets.length;e++)0<=d.indexOf(a._syncedApplets[e]._syncKeyword)&&
a._syncedApplets[e]._syncScript(d);return 0}};a._getElement=function(b,a){return document.getElementById(b._id+"_"+a)||{}};a._evalJSON=function(b,a){b+="";if(!b)return[];if("{"!=b.charAt(0))return 0<=b.indexOf(" | ")&&(b=b.replace(/\ \|\ /g,"\n")),b;var e=(new Function("return "+b))();return!e?null:a&&void 0!=e[a]?e[a]:e};a._sortMessages=function(b){function a(b,d){return b[0]<d[0]?1:b[0]>d[0]?-1:0}if(!b||"object"!=typeof b)return[];for(var e=[],f=b.length-1;0<=f;f--)for(var c=0,g=b[f].length;c<g;c++)e[e.length]=
b[f][c];if(0!=e.length)return e=e.sort(a)};a._setMouseOwner=function(b,d){null==b||d?a._mouseOwner=b:a._mouseOwner==b&&(a._mouseOwner=null)};a._jsGetMouseModifiers=function(b){var a=0;switch(b.button){case 0:a=16;break;case 1:a=8;break;case 2:a=4}b.shiftKey&&(a+=1);b.altKey&&(a+=8);b.ctrlKey&&(a+=2);return a};a._jsGetXY=function(b,d){if(!b.applet._ready||a._touching&&0>d.type.indexOf("touch"))return!1;d.preventDefault();var e=a.$offset(b.id),f,c=d.originalEvent;d.pageX||(d.pageX=c.pageX);d.pageY||
(d.pageY=c.pageY);a._mousePageX=d.pageX;a._mousePageY=d.pageY;c.targetTouches&&c.targetTouches[0]?(f=c.targetTouches[0].pageX-e.left,e=c.targetTouches[0].pageY-e.top):c.changedTouches?(f=c.changedTouches[0].pageX-e.left,e=c.changedTouches[0].pageY-e.top):(f=d.pageX-e.left,e=d.pageY-e.top);return void 0==f?null:[Math.round(f),Math.round(e),a._jsGetMouseModifiers(d)]};a._gestureUpdate=function(b,d){d.stopPropagation();d.preventDefault();var e=d.originalEvent;switch(d.type){case "touchstart":a._touching=
!0;break;case "touchend":a._touching=!1}if(!e.touches||2!=e.touches.length)return!1;switch(d.type){case "touchstart":b._touches=[[],[]];break;case "touchmove":var f=a.$offset(b.id),c=b._touches[0],g=b._touches[1];c.push([e.touches[0].pageX-f.left,e.touches[0].pageY-f.top]);g.push([e.touches[1].pageX-f.left,e.touches[1].pageY-f.top]);e=c.length;3<e&&(c.shift(),g.shift());2<=e&&b.applet._processGesture(b._touches)}return!0};a._jsSetMouse=function(b){a.$bind(b,"mousedown touchstart",function(d){a._setMouseOwner(b,
!0);d.stopPropagation();d.preventDefault();b.isDragging=!0;if("touchstart"==d.type&&a._gestureUpdate(b,d))return!1;a._setConsoleDiv(b.applet._console);var e=a._jsGetXY(b,d);if(!e)return!1;2!=d.button&&a.Swing.hideMenus(b.applet);b.applet._processEvent(501,e);return!1});a.$bind(b,"mouseup touchend",function(d){a._setMouseOwner(null);d.stopPropagation();d.preventDefault();b.isDragging=!1;if("touchend"==d.type&&a._gestureUpdate(b,d))return!1;d=a._jsGetXY(b,d);if(!d)return!1;b.applet._processEvent(502,
d);return!1});a.$bind(b,"mousemove touchmove",function(d){return a._mouseOwner&&a._mouseOwner!=b&&a._mouseOwner.isDragging?(a._mouseOwner.mouseMove(d),!1):a._drag(b,d)});a._drag=function(b,e){e.stopPropagation();e.preventDefault();if("touchmove"==e.type&&a._gestureUpdate(b,e))return!1;var f=a._jsGetXY(b,e);if(!f)return!1;b.isDragging||(f[2]=0);b.applet._processEvent(b.isDragging?506:503,f);return!1};a.$bind(b,"DOMMouseScroll mousewheel",function(d){d.stopPropagation();d.preventDefault();b.isDragging=
!1;var f=d.originalEvent,f=f.detail?f.detail:("mac"==a.featureDetection.os?1:-1)*f.wheelDelta;d=a._jsGetMouseModifiers(d);b.applet._processEvent(-1,[0>f?-1:1,0,d]);return!1});a.$bind(b,"contextmenu",function(){return!1});a.$bind(b,"mouseout",function(d){b.applet._applet&&b.applet._applet.startHoverWatcher(!1);a._jsGetXY(b,d);return!1});a.$bind(b,"mouseenter",function(d){b.applet._applet&&b.applet._applet.startHoverWatcher(!0);if(0===d.buttons||0===d.which){b.isDragging=!1;d=a._jsGetXY(b,d);if(!d)return!1;
b.applet._processEvent(504,d);b.applet._processEvent(502,d);return!1}});a.$bind(b,"mousemoveoutjsmol",function(d,f,c){if(b==a._mouseOwner&&b.isDragging)return a._drag(b,c)});b.applet._is2D&&a.$resize(function(){b.applet&&b.applet._resize()});a.$bind("body","mouseup touchend",function(){b.applet&&(b.isDragging=!1);a._setMouseOwner(null)})};a._jsUnsetMouse=function(b){b.applet=null;a.$bind(b,"mousedown touchstart mousemove touchmove mouseup touchend DOMMouseScroll mousewheel contextmenu mouseout mouseenter",
null);a._setMouseOwner(null)};a.Swing={count:0,menuInitialized:0,menuCounter:0,htDialogs:{}};var k=a.Swing;SwingController=k;k.setDraggable=function(b){b=b.prototype;b.setContainer||(b.setContainer=function(b){this.container=b;b.obj=this;this.ignoreMouse=this.isDragging=!1;var f=this;b.bind("mousedown touchstart",function(b){if(f.ignoreMouse)return f.ignoreMouse=!1,!0;a._setMouseOwner(f,!0);f.isDragging=!0;f.pageX=b.pageX;f.pageY=b.pageY;return!1});b.bind("mousemove touchmove",function(b){if(f.isDragging&&
a._mouseOwner==f)return f.mouseMove(b),!1});b.bind("mouseup touchend",function(b){f.mouseUp(b);a._setMouseOwner(null)})},b.mouseUp=function(b){if(this.isDragging&&a._mouseOwner==this)return this.pageX0+=b.pageX-this.pageX,this.pageY0+=b.pageY-this.pageY,this.isDragging=!1;a._setMouseOwner(null)},b.setPosition=function(){if(null===a._mousePageX){var b=a.$offset(this.applet._id+"_"+(this.applet._is2D?"canvas2d":"canvas"));a._mousePageX=b.left;a._mousePageY=b.top}this.pageX0=a._mousePageX;this.pageY0=
a._mousePageY;this.container.css({top:a._mousePageY+"px",left:a._mousePageX+"px"})},b.mouseMove=function(b){this.isDragging&&a._mouseOwner==this&&(this.timestamp=System.currentTimeMillis(),this.container.css({top:this.pageY0+(b.pageY-this.pageY)+"px",left:this.pageX0+(b.pageX-this.pageX)+"px"}))},b.dragBind=function(b){this.applet._ignoreMouse=!b;this.container.unbind("mousemoveoutjsmol");this.container.unbind("touchmoveoutjsmol");this.container.unbind("mouseupoutjsmol");this.container.unbind("touchendoutjsmol");
a._setMouseOwner(null);if(b){var f=this;this.container.bind("mousemoveoutjsmol touchmoveoutjsmol",function(b,a,d){f.mouseMove(d)});this.container.bind("mouseupoutjsmol touchendoutjsmol",function(b,a,d){f.mouseUp(d)})}})};k.JSDialog=function(){};k.setDraggable(k.JSDialog);k.getScreenDimensions=function(b){b.width=h(window).width();b.height=h(window).height()};k.dispose=function(b){a.$remove(b.id+"_mover");delete k.htDialogs[b.id];b.container.obj.dragBind(!1)};k.register=function(b,a){b.id=a+ ++k.count;
k.htDialogs[b.id]=b};k.setDialog=function(b){a._setMouseOwner(null);a.$remove(b.id);var d=b.id+"_mover",f=a._$(d),c;f[0]?(f.html(b.html),c=f[0].jd):(a.$after("body","<div id='"+d+"' style='position:absolute;left:0px;top:0px;'>"+b.html+"</div>"),c=new k.JSDialog,f=a._$(d),b.container=f,c.applet=b.manager.vwr.html5Applet,c.setContainer(f),c.dialog=b,c.setPosition(),c.dragBind(!0),f[0].jd=c);a.$bind("#"+b.id+" .JButton","mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JComboBox",
"mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JCheckBox","mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JTextField","mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JTable","mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JScrollPane","mousedown touchstart",function(){c.ignoreMouse=!0});a.$bind("#"+b.id+" .JEditorPane","mousedown touchstart",function(){c.ignoreMouse=!0})};k.setSelected=function(b){a.$prop(b.id,
"checked",!!b.selected)};k.setSelectedIndex=function(b){a.$prop(b.id,"selectedIndex",b.selectedIndex)};k.setText=function(b){a.$prop(b.id,"value",b.text)};k.setVisible=function(b){a.$setVisible(b.id,b.visible)};k.setEnabled=function(b){a.$setEnabled(b.id,b.enabled)};k.click=function(b,d){var f=k.htDialogs[b.id];if(f){var c=f.toString();if(0<=c.indexOf("JCheck"))f.selected=b.checked;else if(0<=c.indexOf("JCombo"))f.selectedIndex=b.selectedIndex;else if(null!=f.text&&(f.text=b.value,d&&13!=(d.charCode||
d.keyCode)))return}c=k.htDialogs[a.$getAncestorDiv(b.id,"JDialog").id];c.manager.actionPerformed(f?f.name:c.registryKey+"/"+b.id)};k.setFront=function(b){var f=b.manager.vwr.html5Applet;b.zIndex!=a._getZ(f,"dialog")&&(b.zIndex=a._incrZ(f,"dialog"));b.container&&((b.container[0]||b.container).style.zIndex=b.zIndex)};k.hideMenus=function(b){if(b=b._menus)for(var a in b)b[a].visible&&k.hideMenu(b[a])};k.windowClosing=function(b){b=k.htDialogs[a.$getAncestorDiv(b.id,"JDialog").id];b.registryKey?b.manager.processWindowClosing(b.registryKey):
b.dispose()};a._track=function(b){if(a._tracker){try{var f='<iframe style="display:none" width="0" height="0" frameborder="0" tabindex="-1" src="'+(a._tracker+"&applet="+b._jmolType+"&version="+a._version+"&appver="+self.___JmolVersion+"&url="+encodeURIComponent(document.location.href))+'"></iframe>';a.$after("body",f)}catch(e){}delete a._tracker}return b};a.getProfile=function(){window["j2s.doProfile"]=!0;if(self.Clazz&&self.JSON)return Clazz._profile||(Clazz._profile={}),Clazz.getProfile()};a._getInChIKey=
function(b,a){0<=a.indexOf("MOL=")&&a.split("MOL=")[1].split('"')};a._getAttr=function(b,a){var f=b.indexOf(a+"=");return 0<=f&&0<=(f=b.indexOf('"',f))?b.substring(f+1,b.indexOf('"',f+1)):null};a.User={viewUpdatedCallback:null};a.View={count:0,applets:{},sets:{}};(function(b){b.updateView=function(f,e){if(null!=f._viewSet){e.chemID||(f._searchQuery=null);e.data||(e.data="N/A");e.type=f._viewType;if(null==(f._currentView=b.__findView(f._viewSet,e)))f._currentView=b.__createViewSet(f._viewSet,e.chemID,
e.viewID||e.chemID);f._currentView[e.type].data=e.data;f._currentView[e.type].smiles=f._getSmiles();a.User.viewUpdatedCallback&&a.User.viewUpdatedCallback(f,"updateView");b.__setView(f._currentView,f,!1)}};b.updateFromSync=function(f,e){f._updateMsg=e;var c=a._getAttr(e,"sourceID")||a._getAttr(e,"file");if(c){var g=b.__findView(f._viewSet,{viewID:c});if(null==g)return a.updateView(f,e);g!=f._currentView&&b.__setView(g,f,!0);var h=(c=a._getAttr(e,"atoms"))&&0<=e.indexOf("selectionhalos ON")?eval("["+
c+"]"):[];setTimeout(function(){f._currentView==g&&b.updateAtomPick(f,h)},10);a.User.viewUpdatedCallback&&a.User.viewUpdatedCallback(f,"updateFromSync")}};b.updateAtomPick=function(b,f){var c=b._currentView;if(null!=c){for(var g in c)"info"!=g&&c[g].applet!=b&&c[g].applet._updateAtomPick(f);a.User.viewUpdatedCallback&&a.User.viewUpdatedCallback(b,"updateAtomPick")}};b.dumpViews=function(a){var f=b.sets[a];if(f){var c="View set "+a+":\n";a=b.applets[a];for(var g in a)c+="\napplet "+a[g]._id+" currentView="+
(a[g]._currentView?a[g]._currentView.info.viewID:null);for(g=f.length;0<=--g;){a=f[g];var c=c+("\n\n<b>view="+g+" viewID="+a.info.viewID+" chemID="+a.info.chemID+"</b>\n"),h,l;for(l in a)"info"!=l&&(c+="\nview="+g+" type="+l+" applet="+((h=a[l]).applet?h.applet._id:null)+" SMILES="+h.smiles+"\n atomMap="+JSON.stringify(h.atomMap)+"\n data=\n"+h.data+"\n")}return c}};b.__init=function(a){var f=a._viewSet,c=b.applets;c[f]||(c[f]={});c[f][a._viewType]=a};b.__findView=function(a,f){var c=b.sets[a];null==
c&&(c=b.sets[a]=[]);for(var g=c.length;0<=--g;){var h=c[g];if(f.viewID){if(h.info.viewID==f.viewID)return h}else{if(null!=f.chemID&&f.chemID==h.info.chemID)return h;for(var l in h)if("info"!=l&&(null!=f.data&&null!=h[l].data?f.data==h[l].data:f.type==l))return h}}return null};b.__createViewSet=function(f,c,g){b.count++;c={info:{chemID:c,viewID:g||"model_"+b.count}};for(var h in a._applets)g=a._applets[h],g._viewSet==f&&(c[g._viewType]={applet:g,data:null});b.sets[f].push(c);return c};b.__setView=
function(b,a,f){for(var c in b)if("info"!=c){var g=b[c],h=g.applet,l=f||null!=h&&"<modified>"==h._molData;if(!(null==h||h==a&&!l)){var j=null==g.data,k=null!=h._currentView;h._currentView=b;if(!k||!(b[c].data==g.data&&!j&!l))if(h._loadModelFromView(b),j)break}}}})(a.View);a.Cache={fileCache:{}};a.Cache.get=function(b){return a.Cache.fileCache[b]};a.Cache.put=function(b,f){a.Cache.fileCache[b]=f};a.Cache.setDragDrop=function(b){a.$appEvent(b,"appletdiv","dragover",function(b){b=b.originalEvent;b.stopPropagation();
b.preventDefault();b.dataTransfer.dropEffect="copy"});a.$appEvent(b,"appletdiv","drop",function(f){var c=f.originalEvent;c.stopPropagation();c.preventDefault();var g=c.dataTransfer.files[0];if(null==g)try{g=""+c.dataTransfer.getData("text"),(0==g.indexOf("file:/")||0==g.indexOf("http:/"))&&b._scriptLoad(g)}catch(h){}else c=new FileReader,c.onloadend=function(c){if(c.target.readyState==FileReader.DONE){var e="cache://DROP_"+g.name;c=a._toBytes(c.target.result);b._applet.cacheFileByName("cache://DROP_*",
!1);"JSV"==b._viewType||e.endsWith(".jdx")?a.Cache.put(e,c):b._applet.cachePut(e,c);(c=a._jsGetXY(b._canvas,f))&&(!b._applet.setStatusDragDropped||b._applet.setStatusDragDropped(0,c[0],c[1],e))&&b._applet.openFileAsyncSpecial(e,1)}},c.readAsArrayBuffer(g)})}})(Jmol,jQuery);Jmol._debugCode=!1;Jmol._grabberOptions=[["$","NCI(small molecules)"],[":","PubChem(small molecules)"]];Jmol.say=function(a){alert(a)};
Jmol._TMApplet=function(a,h,f){this._uniqueId=(""+Math.random()).substring(3);this._id=a;this._is2D=!0;this._isJava=!1;this._ready=!0;this._mouseDown=!1;this._jmolType="Jmol._Canvas2D (TwirlyMol)";if(f)return this;this._createCanvas(a,h);return this};
Jmol._TMApplet._getApplet=function(a,h,f){if(!Jmol.featureDetection.allowHTML5)return null;f||(f=!1);h||(h={});Jmol._addDefaultInfo(h,{color:"#FFFFFF",width:300,height:300,addSelectionOptions:!1,serverURL:"http://your.server.here/jsmol.php",defaultModel:"",readyFunction:null,use:"HTML5",bondWidth:5,shadeAtoms:!1,zoomScaling:1.5,pinchScaling:2,mouseDragFactor:0.5,touchDragFactor:0.15,multipleBondSpacing:4,spinRateX:0,spinRateY:0.5,spinFPS:20,spin:!1,noscript:!0,debug:!1});h=new Jmol._TMApplet(a,h,
f);return f?h:Jmol._registerApplet(a,h)};Jmol.getTMApplet=Jmol._TMApplet._getApplet;
(function(a){a._CPK="#FF1493 #FFFFFF #D9FFFF #CC80FF #C2FF00 #FFB5B5 #909090 #3050F8 #FF0D0D #90E050 #B3E3F5 #AB5CF2 #8AFF00 #BFA6A6 #F0C8A0 #FF8000 #FFFF30 #1FF01F #80D1E3 #8F40D4 #3DFF00 #E6E6E6 #BFC2C7 #A6A6AB #8A99C7 #9C7AC7 #E06633 #F090A0 #50D050 #C88033 #7D80B0 #C28F8F #668F8F #BD80E3 #FFA100 #A62929 #5CB8D1 #702EB0 #00FF00 #94FFFF #94E0E0 #73C2C9 #54B5B5 #3B9E9E #248F8F #0A7D8C #006985 #C0C0C0 #FFD98F #A67573 #668080 #9E63B5 #D47A00 #940094 #429EB0 #57178F #00C900".split(" ");a._elem="X H He Li Be B C N O F Ne Na Mg Al Si P S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U Np Pu Am Cm Bk Cf Es".split(" ");
a._elemNo={};var h=a.prototype;h.spin=function(a){this.__Info.spin=a;this._spin(a)};h._spin=function(a){this._spinThread&&clearTimeout(this._spinThread);if(0==this.spinFPS||0==this.spinRateX&&0==this.spinRateY)a=!1;if(a){var c=this;a=1E3/this.spinFPS;this._mouseDown||(this._rotate(this.spinRateY,this.spinRateX),this._draw());this._spinThread=setTimeout(function(){c._spin(!0)},a)}};h._initParams=function(){this.zoom=this.__Info.defaultZoom||100;this.doSpin=this.__Info.spin||!1;this.center2D=[this._canvas.width/
2,this._canvas.height/2,0];this._getCenterAndRadius();this.rotation=new a.M3;this.shadeAtoms=!1;this._setParams()};h._setParams=function(){this.bondWidth=this.__Info.bondWidth||5;this.zoomScaling=this.__Info.zoomScaling||1.5;this.pinchScaling=this.__Info.pinchScaling||1;this.mouseDragFactor=this.__Info.mouseDragFactor||0.5;this.touchDragFactor=this.__Info.touchDragFactor||0.15;this.multipleBondSpacing=this.__Info.multipleBondSpacing||4;this.spinRateX=this.__Info.spinRateX||0;this.spinRateY=this.__Info.spinRateY||
0;this.spinFPS=this.__Info.spinFPS||0;var a=this.shadeAtoms;(this.shadeAtoms=this.__Info.shadeAtoms||!1)&&!a&&this._setAtomShades()};h._setAtomShades=function(){if(this.atoms)for(var a=this.atoms.length;0<=--a;)this.atoms[a].color50=this._getColor(this.atoms[a].color,0.5)};h._createCanvas=function(a,c){Jmol._setObject(this,a,c);this._color=this._color.replace(/0x/,"#");var g=Jmol._getWrapper(this,!0);Jmol._document?(Jmol._documentWrite(g),this._createCanvas2d(!1),g=""):g+='<script type="text/javascript">'+
a+"._createCanvas2d(false)\x3c/script>";g+=Jmol._getWrapper(this,!1);c.addSelectionOptions&&(g+=Jmol._getGrabberOptions(this,""));Jmol._debugAlert&&!Jmol._document&&alert(g);this._code=Jmol._documentWrite(g)};h._readyCallback=function(a,c,g,h){g&&(Jmol._setDestroy(this),this._ready=!0,a=this._readyScript,this._applet=h,this._defaultModel?this._search(this._defaultModel,a?";"+a:""):this._src&&this._loadFile(this._src),this._showInfo(!0),this._showInfo(!1),this._readyFunction&&this._readyFunction(this),
Jmol._setReady(this))};h._createCanvas2d=function(a){var c=document.createElement("canvas"),g=Jmol.$(this,"appletdiv");a&&(g[0].removeChild(this._canvas),Jmol._jsUnsetMouse(this._canvas));a=Math.round(g.width());var h=Math.round(g.height());c.applet=this;this._canvas=c;c.style.width="100%";c.style.height="100%";c.width=a;c.height=h;c.id=this._id+"_canvas2d";g.append(c);setTimeout(this._id+"._start()",10)};h._start=function(){Jmol._jsSetMouse(this._canvas);this._defaultModel?Jmol._search(this,this._defaultModel):
this._src&&this._loadFile(this._src);this._showInfo(!0);this._showInfo(!1)};h._search=function(a,c){Jmol._search(this,a,c)};h._searchDatabase=function(a,c,g){this._showInfo(!1);0<=a.indexOf("?")?Jmol._getInfoFromDatabase(this,c,a.split("?")[0]):this._loadFile(c+a,g)};h.__loadModel=function(a){this._spin(!1);"''"==a&&(a=this._mol);a?(this._parse(a),this._initParams(),this._draw(),this._showInfo(!1),this.doSpin&&this._spin(!0)):alert("No model data.")};h._showInfo=function(a){Jmol.$html(Jmol.$(this,
"infoheaderspan"),this._infoHeader);this._info&&Jmol.$html(Jmol.$(this,"infodiv"),this._info);!this._isInfoVisible!=!a&&(this._isInfoVisible=a,Jmol.$setVisible(Jmol.$(this,"infotablediv"),a),Jmol.$setVisible(Jmol.$(this,"infoheaderdiv"),a),this._show(!a))};h._show=function(a){Jmol.$setVisible(Jmol.$(this,"appletdiv"),a);a&&this._draw()};h._resize=function(){var a="__resizeTimeout_"+this._id;Jmol[a]&&clearTimeout(Jmol[a]);var c=this;Jmol[a]=setTimeout(function(){c._draw();Jmol[a]=null},100)};h._canScript=
function(){return!1};h._loadFile=function(a){this._showInfo(!1);this._thisJmolModel=a;var c=this;Jmol._loadFileData(this,a,function(a){c.__loadModel(a)})};h._processEvent=function(a,c){switch(a){case 502:case 503:this._mouseDown=!1;default:return;case 501:this._mouseX=c[0];this._mouseY=c[1];this._mouseDown=!0;return;case 506:var g=c[0]-this._mouseX,h=c[1]-this._mouseY,g=0>g?-1:0<g?1:0,h=0>h?-1:0<h?1:0;switch(c[2]){case 17:this._zoomBy(h);break;case 24:this.center2D[0]+=g;this.center2D[1]+=h;break;
default:this._rotate(g,h)}this._mouseX=c[0];this._mouseY=c[1];break;case -1:this._zoomBy(c[1])}this._draw()};h._processGesture=function(f){if(!(2>f[0].length)){var c=f[0],g=f[1],h=c[0],j=c[g.length-1];f=h[0];var k=j[0],h=h[1],j=j[1],b=[k-f,j-h,0],d=a._length(b),e=g[0],m=g[g.length-1],g=e[0],p=m[0],e=e[1],m=m[1],n=[p-g,m-e,0],q=a._length(n);3>d||3>q||(a._scale(b,1/d),a._scale(n,1/q),b=a._dot(b,n),0.8<b?(f=Math.round(k-c[c.length-2][0]),c=Math.round(j-c[c.length-2][1]),this.center2D[0]+=f,this.center2D[1]+=
c):-0.8>b&&(b=[g-f,e-h,0],n=[p-k,m-j,0],c=a._length(n)-a._length(b),this.zoom+=(0>c?-1:1)*this.pinchScaling),this._draw())}};h._zoomBy=function(a){this.zoom+=a*this.zoomScaling;5>this.zoom&&(this.zoom=5);500<this.zoom&&(this.zoom=500)};h._getRotationScaling=function(){return[1/Math.max(this._canvas.width,500)*this.mouseDragFactor*a.deg_per_radian,1/Math.max(this._canvas.height,500)*this.mouseDragFactor*a.deg_per_radian]};h._rotate=function(f,c){var g=this._getRotationScaling();c&&(a._m3.rotX(c*g[1]),
this.rotation.mul(a._m3));f&&(a._m3.rotY(f*g[0]),this.rotation.mul(a._m3))};h._getCenterAndRadius=function(){Math.min(this._canvas.width,this._canvas.height);for(var f=[999999,999999,999999],c=[-999999,-999999,-999999],g=this.atoms.length;0<=--g;)for(var h=3;0<=--h;){var j=this.atoms[g].xyz[h];j<f[h]&&(f[h]=j);j>c[h]&&(c[h]=j)}j=[0,0,0];for(h=3;0<=--h;)j[h]=(c[h]+f[h])/2;f=0;for(g=this.atoms.length;0<=--g;)c=this.atoms[g],c=a._distance(c.xyz,j)+(1==c.elemNo?1:1.5),c>f&&(f=c);this.center=j;this.modelRadius=
0==f?10:f};h._setScreenCoords=function(){for(var a=this.center,c=this.rotation,g=this.center2D,h=Math.min(this._canvas.width,this._canvas.height)/2/this.modelRadius*this.zoom/100,j=this.atoms.length;0<=--j;){var k=this.atoms[j];this._transform(k.xyz,k.sxyz,a,c,h,g);k.srad=h*k.radius}for(j=this.bonds.length;0<=--j;)k=this.bonds[j],this._transform(k.xyz,k.sxyz,a,c,h,g),this._transform(k.pts[0],k.spts[0],a,c,h,g),this._transform(k.pts[1],k.spts[1],a,c,h,g)};h._transform=function(f,c,g,h,j,k){for(var b=
a._temp1,d=a._temp2,e=3;0<=--e;)b[e]=(f[e]-g[e])*j;h.transform(b,d);d[1]=-d[1];d[2]=-d[2];for(e=3;0<=--e;)c[e]=d[e]+k[e]};h._parse=function(a){this._parseSDF(a)};h._parseSDF=function(f){this._mol=f;if(!a._elemNo.H)for(var c=a._elem.length;0<=--c;)a._elemNo[a._elem[c]]=c;f=f.split("\n");var g=3,h=f[g++];this.nAtoms=parseFloat(h.substring(0,3));this.nBonds=parseFloat(h.substring(3,6));this.atoms=Array(this.nAtoms);this.bonds=Array(this.nBonds);this.elements=Array(this.nAtoms+this.nBonds);for(var j=
0,k,b,d,c=0;c<this.nAtoms;c++){h=f[g++];k=parseFloat(h.substring(0,10));b=parseFloat(h.substring(10,20));d=parseFloat(h.substring(20,30));var h=h.substring(31,34).replace(/\s+/g,""),h=a._elemNo[h]||0,e=1==h?0.23:0.35,m=a._CPK[h]||a._CPK[0];this.elements[j++]=this.atoms[c]={type:0,elemNo:h,xyz:[k,b,d],sxyz:[0,0,0],radius:e,color:m,color50:m}}for(c=0;c<this.nBonds;c++){h=f[g++];k=this.atoms[parseFloat(h.substring(0,3))-1];b=this.atoms[parseFloat(h.substring(3,6))-1];d=Math.abs(parseFloat(h.substring(6,
9)));switch(d){case 4:case 5:case 6:case 8:d=1;break;case 7:d=2}h=a._getPointAlong(k.xyz,b.xyz,0.5);m=a._distance(k.xyz,h);e=k.radius<m?a._getPointAlong(k.xyz,h,k.radius/m):[0,0,99999];m=b.radius<m?a._getPointAlong(b.xyz,h,b.radius/m):[0,0,99999];this.elements[j++]=this.bonds[c]={type:1,atoms:[k,b],xyz:h,pts:[e,m],sxyz:[0,0,0],spts:[[0,0,0],[0,0,0]],order:d,color:0}}};h._getColor=function(a,c){"#FFFFFF"==a&&(a="#D0D0D0");var g=parseInt("0x"+a.substring(1),16),h=g>>16&255,j=g>>8&255,g=g&255;255!=h&&
(h+=Math.floor((255-h)*c));255!=j&&(j+=Math.floor((255-j)*c));255!=g&&(g+=Math.floor((255-g)*c));h="000000"+(h<<16|j<<8|g).toString(16);return"#"+h.substring(h.length-6,h.length)};h._draw=function(){if(this.atoms){this._setParams();this._setScreenCoords();var f=this.elements;f.sort(a._zorder);var c=this._canvas.getContext("2d");c.fillStyle=this._color;c.fillRect(0,0,this._canvas.width,this._canvas.height);for(var g=f.length;0<=--g;){var h=f[g];0==h.type?this._drawAtom(c,h):this._drawBond(c,h)}}};
h._drawAtom=function(f,c){f.beginPath();if(this.shadeAtoms){var g=c.srad/4,g=f.createRadialGradient(c.sxyz[0]-g,c.sxyz[1]-g,g,c.sxyz[0],c.sxyz[1],c.srad);g.addColorStop(0,c.color50);g.addColorStop(1,"#FFFFFF"==c.color?"#D0D0D0":c.color);f.fillStyle=g;f.arc(c.sxyz[0],c.sxyz[1],c.srad,0,a._pi2);f.fill()}else f.fillStyle=c.color,f.arc(c.sxyz[0],c.sxyz[1],c.srad,0,a._pi2),f.fill(),f.strokeStyle="#000000",f.lineWidth=1,f.stroke()};h._drawBond=function(a,c){99999!=c.pts[0][2]&&this._drawBondLines(a,c,c.spts[0],
c.atoms[0].color);99999!=c.pts[1][2]&&this._drawBondLines(a,c,c.spts[1],c.atoms[1].color)};h._drawBondLines=function(f,c,g,h){var j=a._temp;j.width=this.bondWidth;j.color=c.color?c.color:h;if(1==c.order)j.pt1=g,j.pt2=c.sxyz,this._drawLine(f,j);else{j.pt1=a._temp1;j.pt2=a._temp2;j.pta=g;j.ptb=c.sxyz;j.dx=j.ptb[0]-j.pta[0];j.dy=j.ptb[1]-j.pta[1];j.mag2d=Math.round(Math.sqrt(j.dx*j.dx+j.dy*j.dy));j.bondOrder=c.order;for(this._resetAxisCoordinates(j);0<j.bondOrder;)this._drawLine(f,j),j.bondOrder--,this._stepAxisCoordinates(j)}};
h._drawLine=function(a,c){a.beginPath();a.strokeStyle=c.color;a.moveTo(c.pt1[0],c.pt1[1]);a.lineTo(c.pt2[0],c.pt2[1]);a.lineWidth=c.width;a.stroke()};h._resetAxisCoordinates=function(a){var c=a.mag2d>>3;1!=this.multipleBondSpacing&&(c*=this.multipleBondSpacing);c=a.width+c;a.dxStep=Math.round(c*a.dy/a.mag2d);a.dyStep=Math.round(c*-a.dx/a.mag2d);a.pt1[0]=a.pta[0];a.pt1[1]=a.pta[1];a.pt2[0]=a.ptb[0];a.pt2[1]=a.ptb[1];c=a.bondOrder-1;a.pt1[0]-=Math.round(a.dxStep*c/2);a.pt1[1]-=Math.round(a.dyStep*c/
2);a.pt2[0]-=Math.round(a.dxStep*c/2);a.pt2[1]-=Math.round(a.dyStep*c/2)};h._stepAxisCoordinates=function(a){a.pt1[0]+=a.dxStep;a.pt1[1]+=a.dyStep;a.pt2[0]+=a.dxStep;a.pt2[1]+=a.dyStep};a._distance=function(a,c){for(var g=0,h=3;0<=--h;)var j=a[h]-c[h],g=g+j*j;return Math.sqrt(g)};a._dot=function(a,c){for(var g=0,h=3;0<=--h;)g+=a[h]*c[h];return g};a._setPt=function(a,c){for(var g=3;0<=--g;)c[g]=a[g];return c};a._scale=function(a,c){for(var g=3;0<=--g;)a[g]*=c};a._length=function(a){for(var c=0,g=3;0<=
--g;)c+=a[g]*a[g];return Math.sqrt(c)};a._getPointAlong=function(a,c,g){return[(c[0]-a[0])*g+a[0],(c[1]-a[1])*g+a[1],(c[2]-a[2])*g+a[2]]};a._zorder=function(a,c){var g=a.sxyz[2],h=c.sxyz[2];return g<h?-1:g>h?1:0};a.M3=function(){this.m00=1;this.m10=this.m02=this.m01=0;this.m11=1;this.m21=this.m20=this.m12=0;this.m22=1};a.M3.prototype.set=function(a,c,g,h,j,k,b,d,e){this.m00=a;this.m01=c;this.m02=g;this.m10=h;this.m11=j;this.m12=k;this.m20=b;this.m21=d;this.m22=e};a.M3.prototype.transform=function(a,
c){c[0]=this.m00*a[0]+this.m01*a[1]+this.m02*a[2];c[1]=this.m10*a[0]+this.m11*a[1]+this.m12*a[2];c[2]=this.m20*a[0]+this.m21*a[1]+this.m22*a[2]};a.M3.prototype.rotX=function(a){var c=Math.cos(a);a=Math.sin(a);this.m00=1;this.m10=this.m02=this.m01=0;this.m11=c;this.m12=-a;this.m20=0;this.m21=a;this.m22=c};a.M3.prototype.rotY=function(a){var c=Math.cos(a);a=Math.sin(a);this.m00=c;this.m01=0;this.m02=a;this.m10=0;this.m11=1;this.m12=0;this.m20=-a;this.m21=0;this.m22=c};a.M3.prototype.mul=function(a){this.set(a.m00*
this.m00+a.m01*this.m10+a.m02*this.m20,a.m00*this.m01+a.m01*this.m11+a.m02*this.m21,a.m00*this.m02+a.m01*this.m12+a.m02*this.m22,a.m10*this.m00+a.m11*this.m10+a.m12*this.m20,a.m10*this.m01+a.m11*this.m11+a.m12*this.m21,a.m10*this.m02+a.m11*this.m12+a.m12*this.m22,a.m20*this.m00+a.m21*this.m10+a.m22*this.m20,a.m20*this.m01+a.m21*this.m11+a.m22*this.m21,a.m20*this.m02+a.m21*this.m12+a.m22*this.m22)};a._pi2=2*Math.PI;a.deg_per_radian=180/Math.PI;a._z3=[0,0,0];a._temp1=[0,0,0];a._temp2=[0,0,0];a._temp=
{};a._m3=new a.M3})(Jmol._TMApplet);