3210 |
09 Apr 09 |
olle |
/* Jmol 11.6 script library Jmol.js 11:06 AM 10/10/2008 Bob Hanson |
3210 |
09 Apr 09 |
olle |
2 |
|
3210 |
09 Apr 09 |
olle |
checkbox heirarchy -- see http://chemapps.stolaf.edu/jmol/docs/examples-11/check.htm |
3210 |
09 Apr 09 |
olle |
4 |
|
3210 |
09 Apr 09 |
olle |
based on: |
3210 |
09 Apr 09 |
olle |
6 |
* |
3210 |
09 Apr 09 |
olle |
* Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org |
3210 |
09 Apr 09 |
olle |
8 |
* |
3210 |
09 Apr 09 |
olle |
* Contact: hansonr@stolaf.edu |
3210 |
09 Apr 09 |
olle |
10 |
* |
3210 |
09 Apr 09 |
olle |
* This library is free software; you can redistribute it and/or |
3210 |
09 Apr 09 |
olle |
* modify it under the terms of the GNU Lesser General Public |
3210 |
09 Apr 09 |
olle |
* License as published by the Free Software Foundation; either |
3210 |
09 Apr 09 |
olle |
* version 2.1 of the License, or (at your option) any later version. |
3210 |
09 Apr 09 |
olle |
15 |
* |
3210 |
09 Apr 09 |
olle |
* This library is distributed in the hope that it will be useful, |
3210 |
09 Apr 09 |
olle |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3210 |
09 Apr 09 |
olle |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3210 |
09 Apr 09 |
olle |
* Lesser General Public License for more details. |
3210 |
09 Apr 09 |
olle |
20 |
* |
3210 |
09 Apr 09 |
olle |
* You should have received a copy of the GNU Lesser General Public |
3210 |
09 Apr 09 |
olle |
* License along with this library; if not, write to the Free Software |
3210 |
09 Apr 09 |
olle |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
3210 |
09 Apr 09 |
olle |
* 02111-1307 USA. |
3210 |
09 Apr 09 |
olle |
25 |
*/ |
3210 |
09 Apr 09 |
olle |
26 |
|
3210 |
09 Apr 09 |
olle |
// for documentation see www.jmol.org/jslibrary |
3210 |
09 Apr 09 |
olle |
28 |
|
3210 |
09 Apr 09 |
olle |
try{if(typeof(_jmol)!="undefined")exit() |
3210 |
09 Apr 09 |
olle |
30 |
|
3210 |
09 Apr 09 |
olle |
// place "?NOAPPLET" on your command line to check applet control action with a textarea |
3210 |
09 Apr 09 |
olle |
// place "?JMOLJAR=xxxxx" to use a specific jar file |
3210 |
09 Apr 09 |
olle |
33 |
|
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%) |
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired. |
3210 |
09 Apr 09 |
olle |
// bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006 |
3210 |
09 Apr 09 |
olle |
// bob hanson -- fix for iframes not available for finding applet |
3210 |
09 Apr 09 |
olle |
// bob hanson -- added applet fake ?NOAPPLET URL flag |
3210 |
09 Apr 09 |
olle |
// bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006 |
3210 |
09 Apr 09 |
olle |
// used PRIOR to jmolApplet() or jmolAppletInline() |
3210 |
09 Apr 09 |
olle |
// added 4th array element in jmolRadioGroup -- title |
3210 |
09 Apr 09 |
olle |
// added <span> and id around link, checkbox, radio, menu |
3210 |
09 Apr 09 |
olle |
// fixing AJAX loads for MSIE/Opera-Mozilla incompatibility |
3210 |
09 Apr 09 |
olle |
// -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar |
3210 |
09 Apr 09 |
olle |
// renamed Jmol.js for Jmol 11 distribution |
3210 |
09 Apr 09 |
olle |
// -- modified jmolRestoreOrientation() to be immediate, no 1-second delay |
3210 |
09 Apr 09 |
olle |
// bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006 |
3210 |
09 Apr 09 |
olle |
// bh -- jmolCommandInput() |
3210 |
09 Apr 09 |
olle |
// bh -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues |
3210 |
09 Apr 09 |
olle |
// bh -- minor fixes suggested by Angel |
3210 |
09 Apr 09 |
olle |
// bh -- adds jmolSetSyncId() and jmolGetSyncId() |
3210 |
09 Apr 09 |
olle |
// bh 3/2008 -- adds jmolAppendInlineScript() and jmolAppendInlineArray() |
3210 |
09 Apr 09 |
olle |
// bh 3/2008 -- fixes IE7 bug in relation to jmolLoadInlineArray() |
3210 |
09 Apr 09 |
olle |
// bh 6/2008 -- adds jmolSetAppletWindow() |
3210 |
09 Apr 09 |
olle |
// Angel H. 6/2008 -- added html <label> tags to checkboxes and radio buttons [in jmolCheckbox() and _jmolRadio() functions] |
3210 |
09 Apr 09 |
olle |
// bh 7/2000 -- code fix "for(i..." not "for(var i..." |
3210 |
09 Apr 09 |
olle |
65 |
|
3210 |
09 Apr 09 |
olle |
var defaultdir = "." |
3210 |
09 Apr 09 |
olle |
var defaultjar = "JmolApplet.jar" |
3210 |
09 Apr 09 |
olle |
68 |
|
3210 |
09 Apr 09 |
olle |
69 |
|
3210 |
09 Apr 09 |
olle |
// Note added 12:41 PM 9/21/2008 by Bob Hanson, hansonr@stolaf.edu: |
3210 |
09 Apr 09 |
olle |
71 |
|
3210 |
09 Apr 09 |
olle |
// JMOLJAR=xxxxx.jar on the URL for this page will override |
3210 |
09 Apr 09 |
olle |
// the JAR file specified in the jmolInitialize() call. |
3210 |
09 Apr 09 |
olle |
74 |
|
3210 |
09 Apr 09 |
olle |
// The idea is that it can be very useful to test a web page with different JAR files |
3210 |
09 Apr 09 |
olle |
// Or for an expert user to substitute a signed applet for an unsigned one |
3210 |
09 Apr 09 |
olle |
// so as to use a broader range of models or to create JPEG files, for example. |
3210 |
09 Apr 09 |
olle |
78 |
|
3210 |
09 Apr 09 |
olle |
// If the JAR file is not in the current directory (has any sort of "/" in its name) |
3210 |
09 Apr 09 |
olle |
// then the user is presented with a warning and asked whether it is OK to change Jar files. |
3210 |
09 Apr 09 |
olle |
// The default action, if the user just presses "OK" is to NOT allow the change. |
3210 |
09 Apr 09 |
olle |
// The user must type the word "yes" in the prompt box for the change to be approved. |
3210 |
09 Apr 09 |
olle |
83 |
|
3210 |
09 Apr 09 |
olle |
// If you don't want people to be able to switch in their own JAR file on your page, |
3210 |
09 Apr 09 |
olle |
// simply set this next line to read "var allowJMOLJAR = false". |
3210 |
09 Apr 09 |
olle |
86 |
|
3210 |
09 Apr 09 |
olle |
87 |
|
3210 |
09 Apr 09 |
olle |
var allowJMOLJAR = true |
3210 |
09 Apr 09 |
olle |
89 |
|
3210 |
09 Apr 09 |
olle |
90 |
|
3210 |
09 Apr 09 |
olle |
var undefined; // for IE 5 ... wherein undefined is undefined |
3210 |
09 Apr 09 |
olle |
92 |
|
3210 |
09 Apr 09 |
olle |
93 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
// Basic Scripting infrastruture |
3210 |
09 Apr 09 |
olle |
95 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
96 |
|
3210 |
09 Apr 09 |
olle |
function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) { |
3210 |
09 Apr 09 |
olle |
if(allowJMOLJAR && document.location.search.indexOf("JMOLJAR=")>=0) { |
3210 |
09 Apr 09 |
olle |
var f = document.location.search.split("JMOLJAR=")[1].split("&")[0]; |
3210 |
09 Apr 09 |
olle |
if (f.indexOf("/") >= 0) { |
3210 |
09 Apr 09 |
olle |
alert ("This web page URL is requesting that the applet used be " + f + ". This is a possible security risk, particularly if the applet is signed, because signed applets can read and write files on your local machine or network.") |
3210 |
09 Apr 09 |
olle |
var ok = prompt("Do you want to use applet " + f + "? ","yes or no") |
3210 |
09 Apr 09 |
olle |
if (ok == "yes") { |
3210 |
09 Apr 09 |
olle |
codebaseDirectory = f.substring(0, f.lastIndexOf("/")); |
3210 |
09 Apr 09 |
olle |
fileNameOrUseSignedApplet = f.substring(f.lastIndexOf("/") + 1); |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
_jmolGetJarFilename(fileNameOrUseSignedApplet); |
3210 |
09 Apr 09 |
olle |
alert("The web page URL was ignored. Continuing using " + _jmol.archivePath + ' in directory "' + codebaseDirectory + '"'); |
3210 |
09 Apr 09 |
olle |
109 |
} |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
fileNameOrUseSignedApplet = f; |
3210 |
09 Apr 09 |
olle |
112 |
} |
3210 |
09 Apr 09 |
olle |
113 |
} |
3210 |
09 Apr 09 |
olle |
_jmolSetCodebase(codebaseDirectory); |
3210 |
09 Apr 09 |
olle |
_jmolGetJarFilename(fileNameOrUseSignedApplet); |
3210 |
09 Apr 09 |
olle |
_jmolOnloadResetForms(); |
3210 |
09 Apr 09 |
olle |
_jmol.initialized = true; |
3210 |
09 Apr 09 |
olle |
118 |
} |
3210 |
09 Apr 09 |
olle |
119 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetTranslation(TF) { |
3210 |
09 Apr 09 |
olle |
_jmol.params.doTranslate = ''+TF; |
3210 |
09 Apr 09 |
olle |
122 |
} |
3210 |
09 Apr 09 |
olle |
123 |
|
3210 |
09 Apr 09 |
olle |
function _jmolGetJarFilename(fileNameOrFlag) { |
3210 |
09 Apr 09 |
olle |
_jmol.archivePath = |
3210 |
09 Apr 09 |
olle |
(typeof(fileNameOrFlag) == "string" ? fileNameOrFlag : (fileNameOrFlag ? "JmolAppletSigned" : "JmolApplet") + "0.jar"); |
3210 |
09 Apr 09 |
olle |
127 |
} |
3210 |
09 Apr 09 |
olle |
128 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetDocument(doc) { |
3210 |
09 Apr 09 |
olle |
_jmol.currentDocument = doc; |
3210 |
09 Apr 09 |
olle |
131 |
} |
3210 |
09 Apr 09 |
olle |
132 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
_jmol.params.boxbgcolor = boxbgcolor; |
3210 |
09 Apr 09 |
olle |
if (boxfgcolor) |
3210 |
09 Apr 09 |
olle |
_jmol.params.boxfgcolor = boxfgcolor |
3210 |
09 Apr 09 |
olle |
else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF") |
3210 |
09 Apr 09 |
olle |
_jmol.params.boxfgcolor = "black"; |
3210 |
09 Apr 09 |
olle |
else |
3210 |
09 Apr 09 |
olle |
_jmol.params.boxfgcolor = "white"; |
3210 |
09 Apr 09 |
olle |
if (progresscolor) |
3210 |
09 Apr 09 |
olle |
_jmol.params.progresscolor = progresscolor; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(" boxbgcolor=" + _jmol.params.boxbgcolor + |
3210 |
09 Apr 09 |
olle |
" boxfgcolor=" + _jmol.params.boxfgcolor + |
3210 |
09 Apr 09 |
olle |
" progresscolor=" + _jmol.params.progresscolor); |
3210 |
09 Apr 09 |
olle |
148 |
} |
3210 |
09 Apr 09 |
olle |
149 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetAppletWindow(w) { |
3210 |
09 Apr 09 |
olle |
_jmol.appletWindow = w; |
3210 |
09 Apr 09 |
olle |
152 |
} |
3210 |
09 Apr 09 |
olle |
153 |
|
3210 |
09 Apr 09 |
olle |
function jmolApplet(size, script, nameSuffix) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
return _jmolApplet(size, null, script, nameSuffix); |
3210 |
09 Apr 09 |
olle |
157 |
} |
3210 |
09 Apr 09 |
olle |
158 |
|
3210 |
09 Apr 09 |
olle |
159 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
// Basic controls |
3210 |
09 Apr 09 |
olle |
161 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
162 |
|
3210 |
09 Apr 09 |
olle |
function jmolButton(script, label, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (id == undefined || id == null) |
3210 |
09 Apr 09 |
olle |
id = "jmolButton" + _jmol.buttonCount; |
3210 |
09 Apr 09 |
olle |
if (label == undefined || label == null) |
3210 |
09 Apr 09 |
olle |
label = script.substring(0, 32); |
3210 |
09 Apr 09 |
olle |
++_jmol.buttonCount; |
3210 |
09 Apr 09 |
olle |
var scriptIndex = _jmolAddScript(script); |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id + |
3210 |
09 Apr 09 |
olle |
"' value='" + label + |
3210 |
09 Apr 09 |
olle |
"' onClick='_jmolClick(" + scriptIndex + _jmol.targetText + |
3210 |
09 Apr 09 |
olle |
")' onMouseover='_jmolMouseOver(" + scriptIndex + |
3210 |
09 Apr 09 |
olle |
");return true' onMouseout='_jmolMouseOut()' " + |
3210 |
09 Apr 09 |
olle |
_jmol.buttonCssText + "/></span>"; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
180 |
} |
3210 |
09 Apr 09 |
olle |
181 |
|
3210 |
09 Apr 09 |
olle |
function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked, |
3210 |
09 Apr 09 |
olle |
labelHtml, isChecked, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (id == undefined || id == null) |
3210 |
09 Apr 09 |
olle |
id = "jmolCheckbox" + _jmol.checkboxCount; |
3210 |
09 Apr 09 |
olle |
++_jmol.checkboxCount; |
3210 |
09 Apr 09 |
olle |
if (scriptWhenChecked == undefined || scriptWhenChecked == null || |
3210 |
09 Apr 09 |
olle |
scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) { |
3210 |
09 Apr 09 |
olle |
alert("jmolCheckbox requires two scripts"); |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
192 |
} |
3210 |
09 Apr 09 |
olle |
if (labelHtml == undefined || labelHtml == null) { |
3210 |
09 Apr 09 |
olle |
alert("jmolCheckbox requires a label"); |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
196 |
} |
3210 |
09 Apr 09 |
olle |
var indexChecked = _jmolAddScript(scriptWhenChecked); |
3210 |
09 Apr 09 |
olle |
var indexUnchecked = _jmolAddScript(scriptWhenUnchecked); |
3210 |
09 Apr 09 |
olle |
var eospan = "</span>" |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id + |
3210 |
09 Apr 09 |
olle |
"' onClick='_jmolCbClick(this," + |
3210 |
09 Apr 09 |
olle |
indexChecked + "," + indexUnchecked + _jmol.targetText + |
3210 |
09 Apr 09 |
olle |
")' onMouseover='_jmolCbOver(this," + indexChecked + "," + |
3210 |
09 Apr 09 |
olle |
indexUnchecked + |
3210 |
09 Apr 09 |
olle |
");return true' onMouseout='_jmolMouseOut()' " + |
3210 |
09 Apr 09 |
olle |
(isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" |
3210 |
09 Apr 09 |
olle |
if (labelHtml.toLowerCase().indexOf("<td>")>=0) { |
3210 |
09 Apr 09 |
olle |
t += eospan |
3210 |
09 Apr 09 |
olle |
eospan = ""; |
3210 |
09 Apr 09 |
olle |
210 |
} |
3210 |
09 Apr 09 |
olle |
t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
215 |
} |
3210 |
09 Apr 09 |
olle |
216 |
|
3210 |
09 Apr 09 |
olle |
function jmolStartNewRadioGroup() { |
3210 |
09 Apr 09 |
olle |
++_jmol.radioGroupCount; |
3210 |
09 Apr 09 |
olle |
219 |
} |
3210 |
09 Apr 09 |
olle |
220 |
|
3210 |
09 Apr 09 |
olle |
function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName, id, title) { |
3210 |
09 Apr 09 |
olle |
222 |
/* |
3210 |
09 Apr 09 |
olle |
223 |
|
3210 |
09 Apr 09 |
olle |
array: [radio1,radio2,radio3...] |
3210 |
09 Apr 09 |
olle |
where radioN = ["script","label",isSelected,"id","title"] |
3210 |
09 Apr 09 |
olle |
226 |
|
3210 |
09 Apr 09 |
olle |
227 |
*/ |
3210 |
09 Apr 09 |
olle |
228 |
|
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
var type = typeof arrayOfRadioButtons; |
3210 |
09 Apr 09 |
olle |
if (type != "object" || type == null || ! arrayOfRadioButtons.length) { |
3210 |
09 Apr 09 |
olle |
alert("invalid arrayOfRadioButtons"); |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
234 |
} |
3210 |
09 Apr 09 |
olle |
if (separatorHtml == undefined || separatorHtml == null) |
3210 |
09 Apr 09 |
olle |
separatorHtml = " "; |
3210 |
09 Apr 09 |
olle |
var len = arrayOfRadioButtons.length; |
3210 |
09 Apr 09 |
olle |
jmolStartNewRadioGroup(); |
3210 |
09 Apr 09 |
olle |
if (!groupName) |
3210 |
09 Apr 09 |
olle |
groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1); |
3210 |
09 Apr 09 |
olle |
var t = "<span id='"+(id ? id : groupName)+"'>"; |
3210 |
09 Apr 09 |
olle |
for (var i = 0; i < len; ++i) { |
3210 |
09 Apr 09 |
olle |
if (i == len - 1) |
3210 |
09 Apr 09 |
olle |
separatorHtml = ""; |
3210 |
09 Apr 09 |
olle |
var radio = arrayOfRadioButtons[i]; |
3210 |
09 Apr 09 |
olle |
type = typeof radio; |
3210 |
09 Apr 09 |
olle |
if (type == "object") { |
3210 |
09 Apr 09 |
olle |
t += _jmolRadio(radio[0], radio[1], radio[2], separatorHtml, groupName, (radio.length > 3 ? radio[3]: (id ? id : groupName)+"_"+i), (radio.length > 4 ? radio[4] : 0), title); |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
t += _jmolRadio(radio, null, null, separatorHtml, groupName, (id ? id : groupName)+"_"+i, title); |
3210 |
09 Apr 09 |
olle |
251 |
} |
3210 |
09 Apr 09 |
olle |
252 |
} |
3210 |
09 Apr 09 |
olle |
t+="</span>" |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
257 |
} |
3210 |
09 Apr 09 |
olle |
258 |
|
3210 |
09 Apr 09 |
olle |
259 |
|
3210 |
09 Apr 09 |
olle |
function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (_jmol.radioGroupCount == 0) |
3210 |
09 Apr 09 |
olle |
++_jmol.radioGroupCount; |
3210 |
09 Apr 09 |
olle |
var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, (id ? id : groupName + "_" + _jmol.radioCount), title ? title : 0); |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
268 |
} |
3210 |
09 Apr 09 |
olle |
269 |
|
3210 |
09 Apr 09 |
olle |
function jmolLink(script, label, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (id == undefined || id == null) |
3210 |
09 Apr 09 |
olle |
id = "jmolLink" + _jmol.linkCount; |
3210 |
09 Apr 09 |
olle |
if (label == undefined || label == null) |
3210 |
09 Apr 09 |
olle |
label = script.substring(0, 32); |
3210 |
09 Apr 09 |
olle |
++_jmol.linkCount; |
3210 |
09 Apr 09 |
olle |
var scriptIndex = _jmolAddScript(script); |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><a name='" + id + "' id='" + id + |
3210 |
09 Apr 09 |
olle |
"' href='javascript:_jmolClick(" + scriptIndex + _jmol.targetText + ");' onMouseover='_jmolMouseOver(" + scriptIndex + |
3210 |
09 Apr 09 |
olle |
");return true;' onMouseout='_jmolMouseOut()' " + |
3210 |
09 Apr 09 |
olle |
_jmol.linkCssText + ">" + label + "</a></span>"; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
285 |
} |
3210 |
09 Apr 09 |
olle |
286 |
|
3210 |
09 Apr 09 |
olle |
function jmolCommandInput(label, size, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (id == undefined || id == null) |
3210 |
09 Apr 09 |
olle |
id = "jmolCmd" + _jmol.cmdCount; |
3210 |
09 Apr 09 |
olle |
if (label == undefined || label == null) |
3210 |
09 Apr 09 |
olle |
label = "Execute"; |
3210 |
09 Apr 09 |
olle |
if (size == undefined || isNaN(size)) |
3210 |
09 Apr 09 |
olle |
size = 60; |
3210 |
09 Apr 09 |
olle |
++_jmol.cmdCount; |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" + id + "' id='" + id + |
3210 |
09 Apr 09 |
olle |
"' size='"+size+"'><input type=button value = '"+label+"' onClick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")'/></span>"; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
301 |
} |
3210 |
09 Apr 09 |
olle |
302 |
|
3210 |
09 Apr 09 |
olle |
function jmolMenu(arrayOfMenuItems, size, id, title) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
if (id == undefined || id == null) |
3210 |
09 Apr 09 |
olle |
id = "jmolMenu" + _jmol.menuCount; |
3210 |
09 Apr 09 |
olle |
++_jmol.menuCount; |
3210 |
09 Apr 09 |
olle |
var type = typeof arrayOfMenuItems; |
3210 |
09 Apr 09 |
olle |
if (type != null && type == "object" && arrayOfMenuItems.length) { |
3210 |
09 Apr 09 |
olle |
var len = arrayOfMenuItems.length; |
3210 |
09 Apr 09 |
olle |
if (typeof size != "number" || size == 1) |
3210 |
09 Apr 09 |
olle |
size = null; |
3210 |
09 Apr 09 |
olle |
else if (size < 0) |
3210 |
09 Apr 09 |
olle |
size = len; |
3210 |
09 Apr 09 |
olle |
var sizeText = size ? " size='" + size + "' " : ""; |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><select name='" + id + "' id='" + id + |
3210 |
09 Apr 09 |
olle |
"' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" + |
3210 |
09 Apr 09 |
olle |
sizeText + _jmol.menuCssText + ">"; |
3210 |
09 Apr 09 |
olle |
for (var i = 0; i < len; ++i) { |
3210 |
09 Apr 09 |
olle |
var menuItem = arrayOfMenuItems[i]; |
3210 |
09 Apr 09 |
olle |
type = typeof menuItem; |
3210 |
09 Apr 09 |
olle |
var script, text; |
3210 |
09 Apr 09 |
olle |
var isSelected = undefined; |
3210 |
09 Apr 09 |
olle |
if (type == "object" && menuItem != null) { |
3210 |
09 Apr 09 |
olle |
script = menuItem[0]; |
3210 |
09 Apr 09 |
olle |
text = menuItem[1]; |
3210 |
09 Apr 09 |
olle |
isSelected = menuItem[2]; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
script = text = menuItem; |
3210 |
09 Apr 09 |
olle |
330 |
} |
3210 |
09 Apr 09 |
olle |
if (text == undefined || text == null) |
3210 |
09 Apr 09 |
olle |
text = script; |
3210 |
09 Apr 09 |
olle |
if (script=="#optgroup") { |
3210 |
09 Apr 09 |
olle |
t += "<optgroup label='" + text + "'>"; |
3210 |
09 Apr 09 |
olle |
} else if (script=="#optgroupEnd") { |
3210 |
09 Apr 09 |
olle |
t += "</optgroup>"; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
var scriptIndex = _jmolAddScript(script); |
3210 |
09 Apr 09 |
olle |
var selectedText = isSelected ? "' selected>" : "'>"; |
3210 |
09 Apr 09 |
olle |
t += "<option value='" + scriptIndex + selectedText + text + "</option>"; |
3210 |
09 Apr 09 |
olle |
341 |
} |
3210 |
09 Apr 09 |
olle |
342 |
} |
3210 |
09 Apr 09 |
olle |
t += "</select></span>"; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
347 |
} |
3210 |
09 Apr 09 |
olle |
348 |
} |
3210 |
09 Apr 09 |
olle |
349 |
|
3210 |
09 Apr 09 |
olle |
function jmolHtml(html) { |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(html); |
3210 |
09 Apr 09 |
olle |
352 |
} |
3210 |
09 Apr 09 |
olle |
353 |
|
3210 |
09 Apr 09 |
olle |
function jmolBr() { |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite("<br />"); |
3210 |
09 Apr 09 |
olle |
356 |
} |
3210 |
09 Apr 09 |
olle |
357 |
|
3210 |
09 Apr 09 |
olle |
358 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
// advanced scripting functions |
3210 |
09 Apr 09 |
olle |
360 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
361 |
|
3210 |
09 Apr 09 |
olle |
function jmolDebugAlert(enableAlerts) { |
3210 |
09 Apr 09 |
olle |
_jmol.debugAlert = (enableAlerts == undefined || enableAlerts) |
3210 |
09 Apr 09 |
olle |
364 |
} |
3210 |
09 Apr 09 |
olle |
365 |
|
3210 |
09 Apr 09 |
olle |
function jmolAppletInline(size, inlineModel, script, nameSuffix) { |
3210 |
09 Apr 09 |
olle |
_jmolInitCheck(); |
3210 |
09 Apr 09 |
olle |
return _jmolApplet(size, _jmolSterilizeInline(inlineModel), |
3210 |
09 Apr 09 |
olle |
script, nameSuffix); |
3210 |
09 Apr 09 |
olle |
370 |
} |
3210 |
09 Apr 09 |
olle |
371 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetTarget(targetSuffix) { |
3210 |
09 Apr 09 |
olle |
_jmol.targetSuffix = targetSuffix; |
3210 |
09 Apr 09 |
olle |
_jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : ""; |
3210 |
09 Apr 09 |
olle |
375 |
} |
3210 |
09 Apr 09 |
olle |
376 |
|
3210 |
09 Apr 09 |
olle |
function jmolScript(script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (script) { |
3210 |
09 Apr 09 |
olle |
_jmolCheckBrowser(); |
3210 |
09 Apr 09 |
olle |
if (targetSuffix == "all") { |
3210 |
09 Apr 09 |
olle |
with (_jmol) { |
3210 |
09 Apr 09 |
olle |
for (var i = 0; i < appletSuffixes.length; ++i) { |
3210 |
09 Apr 09 |
olle |
var applet = _jmolGetApplet(appletSuffixes[i]); |
3210 |
09 Apr 09 |
olle |
if (applet) applet.script(script); |
3210 |
09 Apr 09 |
olle |
385 |
} |
3210 |
09 Apr 09 |
olle |
386 |
} |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet) applet.script(script); |
3210 |
09 Apr 09 |
olle |
390 |
} |
3210 |
09 Apr 09 |
olle |
391 |
} |
3210 |
09 Apr 09 |
olle |
392 |
} |
3210 |
09 Apr 09 |
olle |
393 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadInline(model, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (!model)return |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (!applet)return |
3210 |
09 Apr 09 |
olle |
if (typeof(model) == "string") |
3210 |
09 Apr 09 |
olle |
applet.loadInlineString(model, "", false); |
3210 |
09 Apr 09 |
olle |
else |
3210 |
09 Apr 09 |
olle |
applet.loadInlineArray(model, "", false); |
3210 |
09 Apr 09 |
olle |
402 |
} |
3210 |
09 Apr 09 |
olle |
403 |
|
3210 |
09 Apr 09 |
olle |
404 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadInlineScript(model, script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (!model)return |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet)applet.loadInlineString(model, script, false); |
3210 |
09 Apr 09 |
olle |
409 |
} |
3210 |
09 Apr 09 |
olle |
410 |
|
3210 |
09 Apr 09 |
olle |
411 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadInlineArray(ModelArray, script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (!model)return |
3210 |
09 Apr 09 |
olle |
if (!script)script="" |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (!applet)return |
3210 |
09 Apr 09 |
olle |
try { |
3210 |
09 Apr 09 |
olle |
applet.loadInlineArray(ModelArray, script, false); |
3210 |
09 Apr 09 |
olle |
} catch (err) { |
3210 |
09 Apr 09 |
olle |
//IE 7 bug |
3210 |
09 Apr 09 |
olle |
applet.loadInlineString(ModelArray.join("\n"), script, false); |
3210 |
09 Apr 09 |
olle |
422 |
} |
3210 |
09 Apr 09 |
olle |
423 |
} |
3210 |
09 Apr 09 |
olle |
424 |
|
3210 |
09 Apr 09 |
olle |
function jmolAppendInlineArray(ModelArray, script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (!model)return |
3210 |
09 Apr 09 |
olle |
if (!script)script="" |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (!applet)return |
3210 |
09 Apr 09 |
olle |
try { |
3210 |
09 Apr 09 |
olle |
applet.loadInlineArray(ModelArray, script, true); |
3210 |
09 Apr 09 |
olle |
} catch (err) { |
3210 |
09 Apr 09 |
olle |
//IE 7 bug |
3210 |
09 Apr 09 |
olle |
applet.loadInlineString(ModelArray.join("\n"), script, true); |
3210 |
09 Apr 09 |
olle |
435 |
} |
3210 |
09 Apr 09 |
olle |
436 |
} |
3210 |
09 Apr 09 |
olle |
437 |
|
3210 |
09 Apr 09 |
olle |
function jmolAppendInlineScript(model, script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if (!model)return |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet)applet.loadInlineString(model, script, true); |
3210 |
09 Apr 09 |
olle |
442 |
} |
3210 |
09 Apr 09 |
olle |
443 |
|
3210 |
09 Apr 09 |
olle |
function jmolCheckBrowser(action, urlOrMessage, nowOrLater) { |
3210 |
09 Apr 09 |
olle |
if (typeof action == "string") { |
3210 |
09 Apr 09 |
olle |
action = action.toLowerCase(); |
3210 |
09 Apr 09 |
olle |
if (action != "alert" && action != "redirect" && action != "popup") |
3210 |
09 Apr 09 |
olle |
action = null; |
3210 |
09 Apr 09 |
olle |
449 |
} |
3210 |
09 Apr 09 |
olle |
if (typeof action != "string") |
3210 |
09 Apr 09 |
olle |
alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" + |
3210 |
09 Apr 09 |
olle |
"action must be 'alert', 'redirect', or 'popup'"); |
3210 |
09 Apr 09 |
olle |
else { |
3210 |
09 Apr 09 |
olle |
if (typeof urlOrMessage != "string") |
3210 |
09 Apr 09 |
olle |
alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" + |
3210 |
09 Apr 09 |
olle |
"urlOrMessage must be a string"); |
3210 |
09 Apr 09 |
olle |
else { |
3210 |
09 Apr 09 |
olle |
_jmol.checkBrowserAction = action; |
3210 |
09 Apr 09 |
olle |
_jmol.checkBrowserUrlOrMessage = urlOrMessage; |
3210 |
09 Apr 09 |
olle |
460 |
} |
3210 |
09 Apr 09 |
olle |
461 |
} |
3210 |
09 Apr 09 |
olle |
if (typeof nowOrLater == "string" && nowOrLater.toLowerCase() == "now") |
3210 |
09 Apr 09 |
olle |
_jmolCheckBrowser(); |
3210 |
09 Apr 09 |
olle |
464 |
} |
3210 |
09 Apr 09 |
olle |
465 |
|
3210 |
09 Apr 09 |
olle |
466 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
// Cascading Style Sheet Class support |
3210 |
09 Apr 09 |
olle |
468 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
469 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetAppletCssClass(appletCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.appletCssClass = appletCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.appletCssText = appletCssClass ? "class='" + appletCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
474 |
} |
3210 |
09 Apr 09 |
olle |
475 |
} |
3210 |
09 Apr 09 |
olle |
476 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetButtonCssClass(buttonCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.buttonCssClass = buttonCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.buttonCssText = buttonCssClass ? "class='" + buttonCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
481 |
} |
3210 |
09 Apr 09 |
olle |
482 |
} |
3210 |
09 Apr 09 |
olle |
483 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetCheckboxCssClass(checkboxCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.checkboxCssClass = checkboxCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.checkboxCssText = checkboxCssClass ? "class='" + checkboxCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
488 |
} |
3210 |
09 Apr 09 |
olle |
489 |
} |
3210 |
09 Apr 09 |
olle |
490 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetRadioCssClass(radioCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.radioCssClass = radioCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.radioCssText = radioCssClass ? "class='" + radioCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
495 |
} |
3210 |
09 Apr 09 |
olle |
496 |
} |
3210 |
09 Apr 09 |
olle |
497 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetLinkCssClass(linkCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.linkCssClass = linkCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.linkCssText = linkCssClass ? "class='" + linkCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
502 |
} |
3210 |
09 Apr 09 |
olle |
503 |
} |
3210 |
09 Apr 09 |
olle |
504 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetMenuCssClass(menuCssClass) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.hasGetElementById) { |
3210 |
09 Apr 09 |
olle |
_jmol.menuCssClass = menuCssClass; |
3210 |
09 Apr 09 |
olle |
_jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : ""; |
3210 |
09 Apr 09 |
olle |
509 |
} |
3210 |
09 Apr 09 |
olle |
510 |
} |
3210 |
09 Apr 09 |
olle |
511 |
|
3210 |
09 Apr 09 |
olle |
512 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
// functions for INTERNAL USE ONLY which are subject to change |
3210 |
09 Apr 09 |
olle |
// use at your own risk ... you have been WARNED! |
3210 |
09 Apr 09 |
olle |
515 |
//////////////////////////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
var _jmol = { |
3210 |
09 Apr 09 |
olle |
currentDocument: document, |
3210 |
09 Apr 09 |
olle |
518 |
|
3210 |
09 Apr 09 |
olle |
debugAlert: false, |
3210 |
09 Apr 09 |
olle |
520 |
|
3210 |
09 Apr 09 |
olle |
codebase: "", |
3210 |
09 Apr 09 |
olle |
modelbase: ".", |
3210 |
09 Apr 09 |
olle |
523 |
|
3210 |
09 Apr 09 |
olle |
appletCount: 0, |
3210 |
09 Apr 09 |
olle |
appletSuffixes: [], |
3210 |
09 Apr 09 |
olle |
appletWindow: null, |
3210 |
09 Apr 09 |
olle |
527 |
|
3210 |
09 Apr 09 |
olle |
buttonCount: 0, |
3210 |
09 Apr 09 |
olle |
checkboxCount: 0, |
3210 |
09 Apr 09 |
olle |
linkCount: 0, |
3210 |
09 Apr 09 |
olle |
cmdCount: 0, |
3210 |
09 Apr 09 |
olle |
menuCount: 0, |
3210 |
09 Apr 09 |
olle |
radioCount: 0, |
3210 |
09 Apr 09 |
olle |
radioGroupCount: 0, |
3210 |
09 Apr 09 |
olle |
535 |
|
3210 |
09 Apr 09 |
olle |
appletCssClass: null, |
3210 |
09 Apr 09 |
olle |
appletCssText: "", |
3210 |
09 Apr 09 |
olle |
buttonCssClass: null, |
3210 |
09 Apr 09 |
olle |
buttonCssText: "", |
3210 |
09 Apr 09 |
olle |
checkboxCssClass: null, |
3210 |
09 Apr 09 |
olle |
checkboxCssText: "", |
3210 |
09 Apr 09 |
olle |
radioCssClass: null, |
3210 |
09 Apr 09 |
olle |
radioCssText: "", |
3210 |
09 Apr 09 |
olle |
linkCssClass: null, |
3210 |
09 Apr 09 |
olle |
linkCssText: "", |
3210 |
09 Apr 09 |
olle |
menuCssClass: null, |
3210 |
09 Apr 09 |
olle |
menuCssText: "", |
3210 |
09 Apr 09 |
olle |
548 |
|
3210 |
09 Apr 09 |
olle |
targetSuffix: 0, |
3210 |
09 Apr 09 |
olle |
targetText: "", |
3210 |
09 Apr 09 |
olle |
scripts: [""], |
3210 |
09 Apr 09 |
olle |
params: { |
3210 |
09 Apr 09 |
olle |
syncId: ("" + Math.random()).substring(3), |
3210 |
09 Apr 09 |
olle |
progressbar: "true", |
3210 |
09 Apr 09 |
olle |
progresscolor: "blue", |
3210 |
09 Apr 09 |
olle |
boxbgcolor: "black", |
3210 |
09 Apr 09 |
olle |
boxfgcolor: "white", |
3210 |
09 Apr 09 |
olle |
boxmessage: "Downloading JmolApplet ..." |
3210 |
09 Apr 09 |
olle |
559 |
}, |
3210 |
09 Apr 09 |
olle |
ua: navigator.userAgent.toLowerCase(), |
3210 |
09 Apr 09 |
olle |
uaVersion: parseFloat(navigator.appVersion), |
3210 |
09 Apr 09 |
olle |
562 |
|
3210 |
09 Apr 09 |
olle |
os: "unknown", |
3210 |
09 Apr 09 |
olle |
browser: "unknown", |
3210 |
09 Apr 09 |
olle |
browserVersion: 0, |
3210 |
09 Apr 09 |
olle |
hasGetElementById: !!document.getElementById, |
3210 |
09 Apr 09 |
olle |
isJavaEnabled: navigator.javaEnabled(), |
3210 |
09 Apr 09 |
olle |
isNetscape47Win: false, |
3210 |
09 Apr 09 |
olle |
isIEWin: false, |
3210 |
09 Apr 09 |
olle |
useIEObject: false, |
3210 |
09 Apr 09 |
olle |
useHtml4Object: false, |
3210 |
09 Apr 09 |
olle |
572 |
|
3210 |
09 Apr 09 |
olle |
windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93", |
3210 |
09 Apr 09 |
olle |
windowsCabUrl: |
3210 |
09 Apr 09 |
olle |
"http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab", |
3210 |
09 Apr 09 |
olle |
576 |
|
3210 |
09 Apr 09 |
olle |
isBrowserCompliant: false, |
3210 |
09 Apr 09 |
olle |
isJavaCompliant: false, |
3210 |
09 Apr 09 |
olle |
isFullyCompliant: false, |
3210 |
09 Apr 09 |
olle |
580 |
|
3210 |
09 Apr 09 |
olle |
initialized: false, |
3210 |
09 Apr 09 |
olle |
initChecked: false, |
3210 |
09 Apr 09 |
olle |
583 |
|
3210 |
09 Apr 09 |
olle |
browserChecked: false, |
3210 |
09 Apr 09 |
olle |
checkBrowserAction: "alert", |
3210 |
09 Apr 09 |
olle |
checkBrowserUrlOrMessage: null, |
3210 |
09 Apr 09 |
olle |
587 |
|
3210 |
09 Apr 09 |
olle |
archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar |
3210 |
09 Apr 09 |
olle |
589 |
|
3210 |
09 Apr 09 |
olle |
previousOnloadHandler: null, |
3210 |
09 Apr 09 |
olle |
ready: {} |
3210 |
09 Apr 09 |
olle |
592 |
} |
3210 |
09 Apr 09 |
olle |
593 |
|
3210 |
09 Apr 09 |
olle |
with (_jmol) { |
3210 |
09 Apr 09 |
olle |
function _jmolTestUA(candidate) { |
3210 |
09 Apr 09 |
olle |
var ua = _jmol.ua; |
3210 |
09 Apr 09 |
olle |
var index = ua.indexOf(candidate); |
3210 |
09 Apr 09 |
olle |
if (index < 0) |
3210 |
09 Apr 09 |
olle |
return false; |
3210 |
09 Apr 09 |
olle |
_jmol.browser = candidate; |
3210 |
09 Apr 09 |
olle |
_jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1)); |
3210 |
09 Apr 09 |
olle |
return true; |
3210 |
09 Apr 09 |
olle |
603 |
} |
3210 |
09 Apr 09 |
olle |
604 |
|
3210 |
09 Apr 09 |
olle |
function _jmolTestOS(candidate) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.ua.indexOf(candidate) < 0) |
3210 |
09 Apr 09 |
olle |
return false; |
3210 |
09 Apr 09 |
olle |
_jmol.os = candidate; |
3210 |
09 Apr 09 |
olle |
return true; |
3210 |
09 Apr 09 |
olle |
610 |
} |
3210 |
09 Apr 09 |
olle |
611 |
|
3210 |
09 Apr 09 |
olle |
_jmolTestUA("konqueror") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("safari") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("omniweb") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("opera") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("webtv") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("icab") || |
3210 |
09 Apr 09 |
olle |
_jmolTestUA("msie") || |
3210 |
09 Apr 09 |
olle |
(_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla")); |
3210 |
09 Apr 09 |
olle |
620 |
|
3210 |
09 Apr 09 |
olle |
_jmolTestOS("linux") || |
3210 |
09 Apr 09 |
olle |
_jmolTestOS("unix") || |
3210 |
09 Apr 09 |
olle |
_jmolTestOS("mac") || |
3210 |
09 Apr 09 |
olle |
_jmolTestOS("win"); |
3210 |
09 Apr 09 |
olle |
625 |
|
3210 |
09 Apr 09 |
olle |
isNetscape47Win = (os == "win" && browser == "mozilla" && |
3210 |
09 Apr 09 |
olle |
browserVersion >= 4.78 && browserVersion <= 4.8); |
3210 |
09 Apr 09 |
olle |
628 |
|
3210 |
09 Apr 09 |
olle |
if (os == "win") { |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = hasGetElementById; |
3210 |
09 Apr 09 |
olle |
} else if (os == "mac") { // mac is the problem child :-( |
3210 |
09 Apr 09 |
olle |
if (browser == "mozilla" && browserVersion >= 5) { |
3210 |
09 Apr 09 |
olle |
// miguel 2004 11 17 |
3210 |
09 Apr 09 |
olle |
// checking the plugins array does not work because |
3210 |
09 Apr 09 |
olle |
// Netscape 7.2 OS X still has Java 1.3.1 listed even though |
3210 |
09 Apr 09 |
olle |
// javaplugin.sf.net is installed to upgrade to 1.4.2 |
3210 |
09 Apr 09 |
olle |
eval("try {var v = java.lang.System.getProperty('java.version');" + |
3210 |
09 Apr 09 |
olle |
" _jmol.isBrowserCompliant = v >= '1.4.2';" + |
3210 |
09 Apr 09 |
olle |
" } catch (e) { }"); |
3210 |
09 Apr 09 |
olle |
} else if (browser == "opera" && browserVersion <= 7.54) { |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = false; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = hasGetElementById && |
3210 |
09 Apr 09 |
olle |
!((browser == "msie") || |
3210 |
09 Apr 09 |
olle |
(browser == "safari" && browserVersion < 125.12)); |
3210 |
09 Apr 09 |
olle |
646 |
} |
3210 |
09 Apr 09 |
olle |
} else if (os == "linux" || os == "unix") { |
3210 |
09 Apr 09 |
olle |
if (browser == "konqueror" && browserVersion <= 3.3) |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = false; |
3210 |
09 Apr 09 |
olle |
else |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = hasGetElementById; |
3210 |
09 Apr 09 |
olle |
} else { // other OS |
3210 |
09 Apr 09 |
olle |
isBrowserCompliant = hasGetElementById; |
3210 |
09 Apr 09 |
olle |
654 |
} |
3210 |
09 Apr 09 |
olle |
655 |
|
3210 |
09 Apr 09 |
olle |
// possibly more checks in the future for this |
3210 |
09 Apr 09 |
olle |
isJavaCompliant = isJavaEnabled; |
3210 |
09 Apr 09 |
olle |
658 |
|
3210 |
09 Apr 09 |
olle |
isFullyCompliant = isBrowserCompliant && isJavaCompliant; |
3210 |
09 Apr 09 |
olle |
660 |
|
3210 |
09 Apr 09 |
olle |
// IE5.5 works just fine ... but let's push them to Sun Java |
3210 |
09 Apr 09 |
olle |
isIEWin = (os == "win" && browser == "msie" && browserVersion >= 5.5); |
3210 |
09 Apr 09 |
olle |
useIEObject = isIEWin; |
3210 |
09 Apr 09 |
olle |
useHtml4Object = |
3210 |
09 Apr 09 |
olle |
(os != "mac" && browser == "mozilla" && browserVersion >= 5) || |
3210 |
09 Apr 09 |
olle |
(os == "win" && browser == "opera" && browserVersion >= 8) || |
3210 |
09 Apr 09 |
olle |
(os == "mac" && browser == "safari" && browserVersion >= 412.2); |
3210 |
09 Apr 09 |
olle |
668 |
|
3210 |
09 Apr 09 |
olle |
doTranslate = true; |
3210 |
09 Apr 09 |
olle |
haveSetTranslate = false; |
3210 |
09 Apr 09 |
olle |
671 |
} |
3210 |
09 Apr 09 |
olle |
672 |
|
3210 |
09 Apr 09 |
olle |
673 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetCallback(callbackName,funcName) { |
3210 |
09 Apr 09 |
olle |
_jmol.params[callbackName] = funcName |
3210 |
09 Apr 09 |
olle |
676 |
} |
3210 |
09 Apr 09 |
olle |
677 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetSyncId(n) { |
3210 |
09 Apr 09 |
olle |
return _jmol.params["syncId"] = n |
3210 |
09 Apr 09 |
olle |
680 |
} |
3210 |
09 Apr 09 |
olle |
681 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetSyncId() { |
3210 |
09 Apr 09 |
olle |
return _jmol.params["syncId"] |
3210 |
09 Apr 09 |
olle |
684 |
} |
3210 |
09 Apr 09 |
olle |
685 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetLogLevel(n) { |
3210 |
09 Apr 09 |
olle |
_jmol.params.logLevel = ''+n; |
3210 |
09 Apr 09 |
olle |
688 |
} |
3210 |
09 Apr 09 |
olle |
689 |
|
3210 |
09 Apr 09 |
olle |
/* AngelH, mar2007: |
3210 |
09 Apr 09 |
olle |
By (re)setting these variables in the webpage before calling jmolApplet(), |
3210 |
09 Apr 09 |
olle |
a custom message can be provided (e.g. localized for user's language) when no Java is installed. |
3210 |
09 Apr 09 |
olle |
693 |
*/ |
3210 |
09 Apr 09 |
olle |
if (noJavaMsg==undefined) var noJavaMsg = |
3210 |
09 Apr 09 |
olle |
"You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" + |
3210 |
09 Apr 09 |
olle |
"Check the warning message from your browser and/or enable Java applets in<br />\n" + |
3210 |
09 Apr 09 |
olle |
"your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />"; |
3210 |
09 Apr 09 |
olle |
if (noJavaMsg2==undefined) var noJavaMsg2 = |
3210 |
09 Apr 09 |
olle |
"You do not have the<br />\n" + |
3210 |
09 Apr 09 |
olle |
"Java Runtime Environment<br />\n" + |
3210 |
09 Apr 09 |
olle |
"installed for applet support.<br />\n" + |
3210 |
09 Apr 09 |
olle |
"Visit <a href='http://www.java.com'>www.java.com</a>"; |
3210 |
09 Apr 09 |
olle |
function _jmolApplet(size, inlineModel, script, nameSuffix) { |
3210 |
09 Apr 09 |
olle |
/* AngelH, mar2007 |
3210 |
09 Apr 09 |
olle |
Fixed percent / pixel business, to avoid browser errors: |
3210 |
09 Apr 09 |
olle |
put "px" where needed, avoid where not. |
3210 |
09 Apr 09 |
olle |
707 |
*/ |
3210 |
09 Apr 09 |
olle |
with (_jmol) { |
3210 |
09 Apr 09 |
olle |
if (! nameSuffix) |
3210 |
09 Apr 09 |
olle |
nameSuffix = appletCount; |
3210 |
09 Apr 09 |
olle |
appletSuffixes.push(nameSuffix); |
3210 |
09 Apr 09 |
olle |
++appletCount; |
3210 |
09 Apr 09 |
olle |
if (! script) |
3210 |
09 Apr 09 |
olle |
script = "select *"; |
3210 |
09 Apr 09 |
olle |
var sz = _jmolGetAppletSize(size); |
3210 |
09 Apr 09 |
olle |
var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' "; |
3210 |
09 Apr 09 |
olle |
var tHeader, tFooter; |
3210 |
09 Apr 09 |
olle |
if (!codebase) |
3210 |
09 Apr 09 |
olle |
jmolInitialize("."); |
3210 |
09 Apr 09 |
olle |
if (useIEObject || useHtml4Object) { |
3210 |
09 Apr 09 |
olle |
params.name = 'jmolApplet' + nameSuffix; |
3210 |
09 Apr 09 |
olle |
params.archive = archivePath; |
3210 |
09 Apr 09 |
olle |
params.mayscript = 'true'; |
3210 |
09 Apr 09 |
olle |
params.codebase = codebase; |
3210 |
09 Apr 09 |
olle |
725 |
} |
3210 |
09 Apr 09 |
olle |
if (useIEObject) { // use MSFT IE6 object tag with .cab file reference |
3210 |
09 Apr 09 |
olle |
winCodebase = (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : ""); |
3210 |
09 Apr 09 |
olle |
tHeader = |
3210 |
09 Apr 09 |
olle |
"<object name='jmolApplet" + nameSuffix + |
3210 |
09 Apr 09 |
olle |
"' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" + |
3210 |
09 Apr 09 |
olle |
" classid='" + windowsClassId + "'\n" + winCodebase + widthAndHeight + ">\n"; |
3210 |
09 Apr 09 |
olle |
params.code = 'JmolApplet'; |
3210 |
09 Apr 09 |
olle |
tFooter = "</object>"; |
3210 |
09 Apr 09 |
olle |
} else if (useHtml4Object) { // use HTML4 object tag |
3210 |
09 Apr 09 |
olle |
tHeader = |
3210 |
09 Apr 09 |
olle |
"<object name='jmolApplet" + nameSuffix + |
3210 |
09 Apr 09 |
olle |
"' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" + |
3210 |
09 Apr 09 |
olle |
" classid='java:JmolApplet'\n" + |
3210 |
09 Apr 09 |
olle |
" type='application/x-java-applet'\n" + |
3210 |
09 Apr 09 |
olle |
widthAndHeight + ">\n"; |
3210 |
09 Apr 09 |
olle |
tFooter = "</object>"; |
3210 |
09 Apr 09 |
olle |
} else { // use applet tag |
3210 |
09 Apr 09 |
olle |
tHeader = |
3210 |
09 Apr 09 |
olle |
"<applet name='jmolApplet" + nameSuffix + |
3210 |
09 Apr 09 |
olle |
"' id='jmolApplet" + nameSuffix + |
3210 |
09 Apr 09 |
olle |
"' " + appletCssText + |
3210 |
09 Apr 09 |
olle |
" code='JmolApplet'" + |
3210 |
09 Apr 09 |
olle |
" archive='" + archivePath + "' codebase='" + codebase + "'\n" + |
3210 |
09 Apr 09 |
olle |
widthAndHeight + |
3210 |
09 Apr 09 |
olle |
" mayscript='true'>\n"; |
3210 |
09 Apr 09 |
olle |
tFooter = "</applet>"; |
3210 |
09 Apr 09 |
olle |
752 |
} |
3210 |
09 Apr 09 |
olle |
var visitJava; |
3210 |
09 Apr 09 |
olle |
if (isIEWin || useHtml4Object) { |
3210 |
09 Apr 09 |
olle |
var szX = "width:" + sz[0] |
3210 |
09 Apr 09 |
olle |
if ( szX.indexOf("%")==-1 ) szX+="px" |
3210 |
09 Apr 09 |
olle |
var szY = "height:" + sz[1] |
3210 |
09 Apr 09 |
olle |
if ( szY.indexOf("%")==-1 ) szY+="px" |
3210 |
09 Apr 09 |
olle |
visitJava = |
3210 |
09 Apr 09 |
olle |
"<p style='background-color:yellow; color:black; " + |
3210 |
09 Apr 09 |
olle |
szX + ";" + szY + ";" + |
3210 |
09 Apr 09 |
olle |
// why doesn't this vertical-align work? |
3210 |
09 Apr 09 |
olle |
"text-align:center;vertical-align:middle;'>\n" + |
3210 |
09 Apr 09 |
olle |
noJavaMsg + |
3210 |
09 Apr 09 |
olle |
"</p>"; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
visitJava = |
3210 |
09 Apr 09 |
olle |
"<table bgcolor='yellow'><tr>" + |
3210 |
09 Apr 09 |
olle |
"<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" + |
3210 |
09 Apr 09 |
olle |
noJavaMsg2 + |
3210 |
09 Apr 09 |
olle |
"</font></td></tr></table>"; |
3210 |
09 Apr 09 |
olle |
772 |
} |
3210 |
09 Apr 09 |
olle |
params.loadInline = (inlineModel ? inlineModel : ""); |
3210 |
09 Apr 09 |
olle |
params.script = (script ? _jmolSterilizeScript(script) : ""); |
3210 |
09 Apr 09 |
olle |
var t = tHeader + _jmolParams() + visitJava + tFooter; |
3210 |
09 Apr 09 |
olle |
jmolSetTarget(nameSuffix); |
3210 |
09 Apr 09 |
olle |
ready["jmolApplet" + nameSuffix] = false; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(t); |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(t); |
3210 |
09 Apr 09 |
olle |
781 |
} |
3210 |
09 Apr 09 |
olle |
782 |
} |
3210 |
09 Apr 09 |
olle |
783 |
|
3210 |
09 Apr 09 |
olle |
function _jmolParams() { |
3210 |
09 Apr 09 |
olle |
var t = ""; |
3210 |
09 Apr 09 |
olle |
for (i in _jmol.params) |
3210 |
09 Apr 09 |
olle |
if(_jmol.params[i]!="") |
3210 |
09 Apr 09 |
olle |
t+=" <param name='"+i+"' value='"+_jmol.params[i]+"' />\n"; |
3210 |
09 Apr 09 |
olle |
return t |
3210 |
09 Apr 09 |
olle |
790 |
} |
3210 |
09 Apr 09 |
olle |
791 |
|
3210 |
09 Apr 09 |
olle |
function _jmolInitCheck() { |
3210 |
09 Apr 09 |
olle |
if (_jmol.initChecked) |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
_jmol.initChecked = true; |
3210 |
09 Apr 09 |
olle |
if (_jmol.initialized) |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
jmolInitialize(defaultdir, defaultjar) |
3210 |
09 Apr 09 |
olle |
799 |
} |
3210 |
09 Apr 09 |
olle |
800 |
|
3210 |
09 Apr 09 |
olle |
function _jmolCheckBrowser() { |
3210 |
09 Apr 09 |
olle |
with (_jmol) { |
3210 |
09 Apr 09 |
olle |
if (browserChecked) |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
browserChecked = true; |
3210 |
09 Apr 09 |
olle |
806 |
|
3210 |
09 Apr 09 |
olle |
if (isFullyCompliant) |
3210 |
09 Apr 09 |
olle |
return true; |
3210 |
09 Apr 09 |
olle |
809 |
|
3210 |
09 Apr 09 |
olle |
if (checkBrowserAction == "redirect") |
3210 |
09 Apr 09 |
olle |
location.href = checkBrowserUrlOrMessage; |
3210 |
09 Apr 09 |
olle |
else if (checkBrowserAction == "popup") |
3210 |
09 Apr 09 |
olle |
_jmolPopup(checkBrowserUrlOrMessage); |
3210 |
09 Apr 09 |
olle |
else { |
3210 |
09 Apr 09 |
olle |
var msg = checkBrowserUrlOrMessage; |
3210 |
09 Apr 09 |
olle |
if (msg == null) |
3210 |
09 Apr 09 |
olle |
msg = "Your web browser is not fully compatible with Jmol\n\n" + |
3210 |
09 Apr 09 |
olle |
"browser: " + browser + |
3210 |
09 Apr 09 |
olle |
" version: " + browserVersion + |
3210 |
09 Apr 09 |
olle |
" os: " + os + |
3210 |
09 Apr 09 |
olle |
"\n\n" + ua; |
3210 |
09 Apr 09 |
olle |
alert(msg); |
3210 |
09 Apr 09 |
olle |
823 |
} |
3210 |
09 Apr 09 |
olle |
824 |
} |
3210 |
09 Apr 09 |
olle |
return false; |
3210 |
09 Apr 09 |
olle |
826 |
} |
3210 |
09 Apr 09 |
olle |
827 |
|
3210 |
09 Apr 09 |
olle |
function _jmolDocumentWrite(text) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.currentDocument) |
3210 |
09 Apr 09 |
olle |
_jmol.currentDocument.write(text); |
3210 |
09 Apr 09 |
olle |
return text; |
3210 |
09 Apr 09 |
olle |
832 |
} |
3210 |
09 Apr 09 |
olle |
833 |
|
3210 |
09 Apr 09 |
olle |
function _jmolPopup(url) { |
3210 |
09 Apr 09 |
olle |
var popup = window.open(url, "JmolPopup", |
3210 |
09 Apr 09 |
olle |
"left=150,top=150,height=400,width=600," + |
3210 |
09 Apr 09 |
olle |
"directories=yes,location=yes,menubar=yes," + |
3210 |
09 Apr 09 |
olle |
"toolbar=yes," + |
3210 |
09 Apr 09 |
olle |
"resizable=yes,scrollbars=yes,status=yes"); |
3210 |
09 Apr 09 |
olle |
if (popup.focus) |
3210 |
09 Apr 09 |
olle |
poup.focus(); |
3210 |
09 Apr 09 |
olle |
842 |
} |
3210 |
09 Apr 09 |
olle |
843 |
|
3210 |
09 Apr 09 |
olle |
function _jmolReadyCallback(name) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert(name + " is ready"); |
3210 |
09 Apr 09 |
olle |
_jmol.ready["" + name] = true; |
3210 |
09 Apr 09 |
olle |
848 |
} |
3210 |
09 Apr 09 |
olle |
849 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSterilizeScript(script) { |
3210 |
09 Apr 09 |
olle |
var inlineScript = script.replace(/'/g, "'"); |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert("script:\n" + inlineScript); |
3210 |
09 Apr 09 |
olle |
return inlineScript; |
3210 |
09 Apr 09 |
olle |
855 |
} |
3210 |
09 Apr 09 |
olle |
856 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSterilizeInline(model) { |
3210 |
09 Apr 09 |
olle |
var inlineModel = |
3210 |
09 Apr 09 |
olle |
model.replace(/\r|\n|\r\n/g, "|").replace(/'/g, "'"); |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert("inline model:\n" + inlineModel); |
3210 |
09 Apr 09 |
olle |
return inlineModel; |
3210 |
09 Apr 09 |
olle |
863 |
} |
3210 |
09 Apr 09 |
olle |
864 |
|
3210 |
09 Apr 09 |
olle |
/* AngelH, mar2007: |
3210 |
09 Apr 09 |
olle |
By (re)setting this variable in the webpage before calling jmolApplet(), limits for applet size can be overriden. |
3210 |
09 Apr 09 |
olle |
867 |
*/ |
3210 |
09 Apr 09 |
olle |
868 |
|
3210 |
09 Apr 09 |
olle |
/* hansonr, jun2007: |
3210 |
09 Apr 09 |
olle |
2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html) |
3210 |
09 Apr 09 |
olle |
871 |
*/ |
3210 |
09 Apr 09 |
olle |
872 |
|
3210 |
09 Apr 09 |
olle |
if (allowedJmolSize==undefined) var allowedJmolSize = [1, 2048, 300] // min, max, default (pixels) |
3210 |
09 Apr 09 |
olle |
function _jmolGetAppletSize(size) { |
3210 |
09 Apr 09 |
olle |
/* AngelH, mar2007 |
3210 |
09 Apr 09 |
olle |
Accepts single number or 2-value array, each one can be either: |
3210 |
09 Apr 09 |
olle |
percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.) |
3210 |
09 Apr 09 |
olle |
Size is now returned as string or number, no "px". |
3210 |
09 Apr 09 |
olle |
879 |
*/ |
3210 |
09 Apr 09 |
olle |
var width, height; |
3210 |
09 Apr 09 |
olle |
if ( (typeof size) == "object" && size != null ) { |
3210 |
09 Apr 09 |
olle |
width = size[0]; height = size[1]; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
width = height = size; |
3210 |
09 Apr 09 |
olle |
885 |
} |
3210 |
09 Apr 09 |
olle |
// if percent, leave it as it is: |
3210 |
09 Apr 09 |
olle |
if ( width.toString().charAt(width.toString().length-1) != "%" ) { |
3210 |
09 Apr 09 |
olle |
width = parseFloat(width); // convert to nr., or strip text, or make zero |
3210 |
09 Apr 09 |
olle |
if ( width <= 1 && width > 0 ) { width = (width*100)+"%" } // decimal: convert to percent and quit |
3210 |
09 Apr 09 |
olle |
else if ( width >= allowedJmolSize[0] && width <= allowedJmolSize[1] ) { width = parseInt(width) } // accept only that range (pixels) |
3210 |
09 Apr 09 |
olle |
else { width = allowedJmolSize[2] } // default size 300 pixels |
3210 |
09 Apr 09 |
olle |
892 |
} |
3210 |
09 Apr 09 |
olle |
if ( height.toString().charAt(height.toString().length-1) != "%" ) { |
3210 |
09 Apr 09 |
olle |
height = parseFloat(height); |
3210 |
09 Apr 09 |
olle |
if ( height <= 1 && height > 0 ) { height = (height*100)+"%" } |
3210 |
09 Apr 09 |
olle |
else if ( height >= allowedJmolSize[0] && height <= allowedJmolSize[1] ) { height = parseInt(height) } |
3210 |
09 Apr 09 |
olle |
else { height = allowedJmolSize[2] } |
3210 |
09 Apr 09 |
olle |
898 |
} |
3210 |
09 Apr 09 |
olle |
return [width, height]; |
3210 |
09 Apr 09 |
olle |
900 |
} |
3210 |
09 Apr 09 |
olle |
901 |
|
3210 |
09 Apr 09 |
olle |
function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) { |
3210 |
09 Apr 09 |
olle |
++_jmol.radioCount; |
3210 |
09 Apr 09 |
olle |
if (groupName == undefined || groupName == null) |
3210 |
09 Apr 09 |
olle |
groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1); |
3210 |
09 Apr 09 |
olle |
if (!script) |
3210 |
09 Apr 09 |
olle |
return ""; |
3210 |
09 Apr 09 |
olle |
if (labelHtml == undefined || labelHtml == null) |
3210 |
09 Apr 09 |
olle |
labelHtml = script.substring(0, 32); |
3210 |
09 Apr 09 |
olle |
if (! separatorHtml) |
3210 |
09 Apr 09 |
olle |
separatorHtml = ""; |
3210 |
09 Apr 09 |
olle |
var scriptIndex = _jmolAddScript(script); |
3210 |
09 Apr 09 |
olle |
var eospan = "</span>" |
3210 |
09 Apr 09 |
olle |
var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" |
3210 |
09 Apr 09 |
olle |
+ groupName + "' id='"+id+"' type='radio' onClick='_jmolClick(" + |
3210 |
09 Apr 09 |
olle |
scriptIndex + _jmol.targetText + ");return true;' onMouseover='_jmolMouseOver(" + |
3210 |
09 Apr 09 |
olle |
scriptIndex + ");return true;' onMouseout='_jmolMouseOut()' " + |
3210 |
09 Apr 09 |
olle |
(isChecked ? "checked " : "") + _jmol.radioCssText + "/>" |
3210 |
09 Apr 09 |
olle |
if (labelHtml.toLowerCase().indexOf("<td>")>=0) { |
3210 |
09 Apr 09 |
olle |
t += eospan |
3210 |
09 Apr 09 |
olle |
eospan = ""; |
3210 |
09 Apr 09 |
olle |
922 |
} |
3210 |
09 Apr 09 |
olle |
t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan + separatorHtml; |
3210 |
09 Apr 09 |
olle |
924 |
|
3210 |
09 Apr 09 |
olle |
return t; |
3210 |
09 Apr 09 |
olle |
926 |
} |
3210 |
09 Apr 09 |
olle |
927 |
|
3210 |
09 Apr 09 |
olle |
function _jmolFindApplet(target) { |
3210 |
09 Apr 09 |
olle |
// first look for the target in the current window |
3210 |
09 Apr 09 |
olle |
var applet = _jmolFindAppletInWindow(_jmol.appletWindow != null ? _jmol.appletWindow : window, target); |
3210 |
09 Apr 09 |
olle |
// THEN look for the target in child frames |
3210 |
09 Apr 09 |
olle |
if (applet == undefined) |
3210 |
09 Apr 09 |
olle |
applet = _jmolSearchFrames(window, target); |
3210 |
09 Apr 09 |
olle |
// FINALLY look for the target in sibling frames |
3210 |
09 Apr 09 |
olle |
if (applet == undefined) |
3210 |
09 Apr 09 |
olle |
applet = _jmolSearchFrames(top, target); // look starting in top frame |
3210 |
09 Apr 09 |
olle |
return applet; |
3210 |
09 Apr 09 |
olle |
938 |
} |
3210 |
09 Apr 09 |
olle |
939 |
|
3210 |
09 Apr 09 |
olle |
function _jmolGetApplet(targetSuffix){ |
3210 |
09 Apr 09 |
olle |
var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0"); |
3210 |
09 Apr 09 |
olle |
var applet = _jmolFindApplet(target); |
3210 |
09 Apr 09 |
olle |
if (applet) return applet |
3210 |
09 Apr 09 |
olle |
if(!_jmol.alerted)alert("could not find applet " + target); |
3210 |
09 Apr 09 |
olle |
_jmol.alerted = true; |
3210 |
09 Apr 09 |
olle |
return null |
3210 |
09 Apr 09 |
olle |
947 |
} |
3210 |
09 Apr 09 |
olle |
948 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSearchFrames(win, target) { |
3210 |
09 Apr 09 |
olle |
var applet; |
3210 |
09 Apr 09 |
olle |
var frames = win.frames; |
3210 |
09 Apr 09 |
olle |
if (frames && frames.length) { // look in all the frames below this window |
3210 |
09 Apr 09 |
olle |
try{ |
3210 |
09 Apr 09 |
olle |
for (var i = 0; i < frames.length; ++i) { |
3210 |
09 Apr 09 |
olle |
applet = _jmolSearchFrames(frames[i], target); |
3210 |
09 Apr 09 |
olle |
if (applet) |
3210 |
09 Apr 09 |
olle |
return applet; |
3210 |
09 Apr 09 |
olle |
958 |
} |
3210 |
09 Apr 09 |
olle |
}catch(e) { |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert("Jmol.js _jmolSearchFrames cannot access " + win.name + ".frame[" + i + "] consider using jmolSetAppletWindow()") |
3210 |
09 Apr 09 |
olle |
962 |
} |
3210 |
09 Apr 09 |
olle |
963 |
} |
3210 |
09 Apr 09 |
olle |
return applet = _jmolFindAppletInWindow(win, target) |
3210 |
09 Apr 09 |
olle |
965 |
} |
3210 |
09 Apr 09 |
olle |
966 |
|
3210 |
09 Apr 09 |
olle |
function _jmolFindAppletInWindow(win, target) { |
3210 |
09 Apr 09 |
olle |
var doc = win.document; |
3210 |
09 Apr 09 |
olle |
// getElementById fails on MacOSX Safari & Mozilla |
3210 |
09 Apr 09 |
olle |
if (_jmol.useHtml4Object || _jmol.useIEObject) |
3210 |
09 Apr 09 |
olle |
return doc.getElementById(target); |
3210 |
09 Apr 09 |
olle |
else if (doc.applets) |
3210 |
09 Apr 09 |
olle |
return doc.applets[target]; |
3210 |
09 Apr 09 |
olle |
else |
3210 |
09 Apr 09 |
olle |
return doc[target]; |
3210 |
09 Apr 09 |
olle |
976 |
} |
3210 |
09 Apr 09 |
olle |
977 |
|
3210 |
09 Apr 09 |
olle |
function _jmolAddScript(script) { |
3210 |
09 Apr 09 |
olle |
if (! script) |
3210 |
09 Apr 09 |
olle |
return 0; |
3210 |
09 Apr 09 |
olle |
var index = _jmol.scripts.length; |
3210 |
09 Apr 09 |
olle |
_jmol.scripts[index] = script; |
3210 |
09 Apr 09 |
olle |
return index; |
3210 |
09 Apr 09 |
olle |
984 |
} |
3210 |
09 Apr 09 |
olle |
985 |
|
3210 |
09 Apr 09 |
olle |
function _jmolClick(scriptIndex, targetSuffix, elementClicked) { |
3210 |
09 Apr 09 |
olle |
_jmol.element = elementClicked; |
3210 |
09 Apr 09 |
olle |
jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
3210 |
09 Apr 09 |
olle |
989 |
} |
3210 |
09 Apr 09 |
olle |
990 |
|
3210 |
09 Apr 09 |
olle |
function _jmolMenuSelected(menuObject, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
var scriptIndex = menuObject.value; |
3210 |
09 Apr 09 |
olle |
if (scriptIndex != undefined) { |
3210 |
09 Apr 09 |
olle |
jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
996 |
} |
3210 |
09 Apr 09 |
olle |
var len = menuObject.length; |
3210 |
09 Apr 09 |
olle |
if (typeof len == "number") { |
3210 |
09 Apr 09 |
olle |
for (var i = 0; i < len; ++i) { |
3210 |
09 Apr 09 |
olle |
if (menuObject[i].selected) { |
3210 |
09 Apr 09 |
olle |
_jmolClick(menuObject[i].value, targetSuffix); |
3210 |
09 Apr 09 |
olle |
return; |
3210 |
09 Apr 09 |
olle |
1003 |
} |
3210 |
09 Apr 09 |
olle |
1004 |
} |
3210 |
09 Apr 09 |
olle |
1005 |
} |
3210 |
09 Apr 09 |
olle |
alert("?Que? menu selected bug #8734"); |
3210 |
09 Apr 09 |
olle |
1007 |
} |
3210 |
09 Apr 09 |
olle |
1008 |
|
3210 |
09 Apr 09 |
olle |
1009 |
|
3210 |
09 Apr 09 |
olle |
_jmol.checkboxMasters = {}; |
3210 |
09 Apr 09 |
olle |
_jmol.checkboxItems = {}; |
3210 |
09 Apr 09 |
olle |
1012 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetCheckboxGroup(chkMaster,chkBox) { |
3210 |
09 Apr 09 |
olle |
var id = chkMaster; |
3210 |
09 Apr 09 |
olle |
if(typeof(id)=="number")id = "jmolCheckbox" + id; |
3210 |
09 Apr 09 |
olle |
chkMaster = document.getElementById(id); |
3210 |
09 Apr 09 |
olle |
if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id); |
3210 |
09 Apr 09 |
olle |
var m = _jmol.checkboxMasters[id] = {}; |
3210 |
09 Apr 09 |
olle |
m.chkMaster = chkMaster; |
3210 |
09 Apr 09 |
olle |
m.chkGroup = {}; |
3210 |
09 Apr 09 |
olle |
for (var i = 1; i < arguments.length; i++){ |
3210 |
09 Apr 09 |
olle |
var id = arguments[i]; |
3210 |
09 Apr 09 |
olle |
if(typeof(id)=="number")id = "jmolCheckbox" + id; |
3210 |
09 Apr 09 |
olle |
checkboxItem = document.getElementById(id); |
3210 |
09 Apr 09 |
olle |
if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id); |
3210 |
09 Apr 09 |
olle |
m.chkGroup[id] = checkboxItem; |
3210 |
09 Apr 09 |
olle |
_jmol.checkboxItems[id] = m; |
3210 |
09 Apr 09 |
olle |
1028 |
} |
3210 |
09 Apr 09 |
olle |
1029 |
} |
3210 |
09 Apr 09 |
olle |
1030 |
|
3210 |
09 Apr 09 |
olle |
function _jmolNotifyMaster(m){ |
3210 |
09 Apr 09 |
olle |
//called when a group item is checked |
3210 |
09 Apr 09 |
olle |
var allOn = true; |
3210 |
09 Apr 09 |
olle |
var allOff = true; |
3210 |
09 Apr 09 |
olle |
for (var chkBox in m.chkGroup){ |
3210 |
09 Apr 09 |
olle |
if(m.chkGroup[chkBox].checked) |
3210 |
09 Apr 09 |
olle |
allOff = false; |
3210 |
09 Apr 09 |
olle |
else |
3210 |
09 Apr 09 |
olle |
allOn = false; |
3210 |
09 Apr 09 |
olle |
1040 |
} |
3210 |
09 Apr 09 |
olle |
if (allOn)m.chkMaster.checked = true; |
3210 |
09 Apr 09 |
olle |
if (allOff)m.chkMaster.checked = false; |
3210 |
09 Apr 09 |
olle |
if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id]) |
3210 |
09 Apr 09 |
olle |
_jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id]) |
3210 |
09 Apr 09 |
olle |
1045 |
} |
3210 |
09 Apr 09 |
olle |
1046 |
|
3210 |
09 Apr 09 |
olle |
function _jmolNotifyGroup(m, isOn){ |
3210 |
09 Apr 09 |
olle |
//called when a master item is checked |
3210 |
09 Apr 09 |
olle |
for (var chkBox in m.chkGroup){ |
3210 |
09 Apr 09 |
olle |
var item = m.chkGroup[chkBox] |
3210 |
09 Apr 09 |
olle |
item.checked = isOn; |
3210 |
09 Apr 09 |
olle |
if (_jmol.checkboxMasters[item.id]) |
3210 |
09 Apr 09 |
olle |
_jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn) |
3210 |
09 Apr 09 |
olle |
1054 |
} |
3210 |
09 Apr 09 |
olle |
1055 |
} |
3210 |
09 Apr 09 |
olle |
1056 |
|
3210 |
09 Apr 09 |
olle |
function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
_jmol.control = ckbox |
3210 |
09 Apr 09 |
olle |
_jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix); |
3210 |
09 Apr 09 |
olle |
if(_jmol.checkboxMasters[ckbox.id]) |
3210 |
09 Apr 09 |
olle |
_jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked) |
3210 |
09 Apr 09 |
olle |
if(_jmol.checkboxItems[ckbox.id]) |
3210 |
09 Apr 09 |
olle |
_jmolNotifyMaster(_jmol.checkboxItems[ckbox.id]) |
3210 |
09 Apr 09 |
olle |
1064 |
} |
3210 |
09 Apr 09 |
olle |
1065 |
|
3210 |
09 Apr 09 |
olle |
function _jmolCbOver(ckbox, whenChecked, whenUnchecked) { |
3210 |
09 Apr 09 |
olle |
window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked]; |
3210 |
09 Apr 09 |
olle |
1068 |
} |
3210 |
09 Apr 09 |
olle |
1069 |
|
3210 |
09 Apr 09 |
olle |
function _jmolMouseOver(scriptIndex) { |
3210 |
09 Apr 09 |
olle |
window.status = _jmol.scripts[scriptIndex]; |
3210 |
09 Apr 09 |
olle |
1072 |
} |
3210 |
09 Apr 09 |
olle |
1073 |
|
3210 |
09 Apr 09 |
olle |
function _jmolMouseOut() { |
3210 |
09 Apr 09 |
olle |
window.status = " "; |
3210 |
09 Apr 09 |
olle |
return true; |
3210 |
09 Apr 09 |
olle |
1077 |
} |
3210 |
09 Apr 09 |
olle |
1078 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSetCodebase(codebase) { |
3210 |
09 Apr 09 |
olle |
_jmol.codebase = codebase ? codebase : "."; |
3210 |
09 Apr 09 |
olle |
if (_jmol.debugAlert) |
3210 |
09 Apr 09 |
olle |
alert("jmolCodebase=" + _jmol.codebase); |
3210 |
09 Apr 09 |
olle |
1083 |
} |
3210 |
09 Apr 09 |
olle |
1084 |
|
3210 |
09 Apr 09 |
olle |
function _jmolOnloadResetForms() { |
3210 |
09 Apr 09 |
olle |
_jmol.previousOnloadHandler = window.onload; |
3210 |
09 Apr 09 |
olle |
window.onload = |
3210 |
09 Apr 09 |
olle |
function() { |
3210 |
09 Apr 09 |
olle |
with (_jmol) { |
3210 |
09 Apr 09 |
olle |
if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) { |
3210 |
09 Apr 09 |
olle |
var forms = document.forms; |
3210 |
09 Apr 09 |
olle |
for (var i = forms.length; --i >= 0; ) |
3210 |
09 Apr 09 |
olle |
forms[i].reset(); |
3210 |
09 Apr 09 |
olle |
1094 |
} |
3210 |
09 Apr 09 |
olle |
if (previousOnloadHandler) |
3210 |
09 Apr 09 |
olle |
previousOnloadHandler(); |
3210 |
09 Apr 09 |
olle |
1097 |
} |
3210 |
09 Apr 09 |
olle |
1098 |
} |
3210 |
09 Apr 09 |
olle |
1099 |
} |
3210 |
09 Apr 09 |
olle |
1100 |
|
3210 |
09 Apr 09 |
olle |
1101 |
//////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
/////extensions for getProperty///// |
3210 |
09 Apr 09 |
olle |
1103 |
//////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
1104 |
|
3210 |
09 Apr 09 |
olle |
1105 |
|
3210 |
09 Apr 09 |
olle |
function _jmolEvalJSON(s,key){ |
3210 |
09 Apr 09 |
olle |
s=s+"" |
3210 |
09 Apr 09 |
olle |
if(!s)return [] |
3210 |
09 Apr 09 |
olle |
if(s.charAt(0)!="{"){ |
3210 |
09 Apr 09 |
olle |
if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n") |
3210 |
09 Apr 09 |
olle |
return s |
3210 |
09 Apr 09 |
olle |
1112 |
} |
3210 |
09 Apr 09 |
olle |
var A = eval("("+s+")") |
3210 |
09 Apr 09 |
olle |
if(!A)return |
3210 |
09 Apr 09 |
olle |
if(key && A[key])A=A[key] |
3210 |
09 Apr 09 |
olle |
return A |
3210 |
09 Apr 09 |
olle |
1117 |
} |
3210 |
09 Apr 09 |
olle |
1118 |
|
3210 |
09 Apr 09 |
olle |
function _jmolEnumerateObject(A,key){ |
3210 |
09 Apr 09 |
olle |
var sout="" |
3210 |
09 Apr 09 |
olle |
if(typeof(A) == "string" && A!="null"){ |
3210 |
09 Apr 09 |
olle |
sout+="\n"+key+"=\""+A+"\"" |
3210 |
09 Apr 09 |
olle |
}else if(!isNaN(A)||A==null){ |
3210 |
09 Apr 09 |
olle |
sout+="\n"+key+"="+(A+""==""?"null":A) |
3210 |
09 Apr 09 |
olle |
}else if(A.length){ |
3210 |
09 Apr 09 |
olle |
sout+=key+"=[]" |
3210 |
09 Apr 09 |
olle |
for(var i=0;i<A.length;i++){ |
3210 |
09 Apr 09 |
olle |
sout+="\n" |
3210 |
09 Apr 09 |
olle |
if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){ |
3210 |
09 Apr 09 |
olle |
sout+=_jmolEnumerateObject(A[i],key+"["+i+"]") |
3210 |
09 Apr 09 |
olle |
}else{ |
3210 |
09 Apr 09 |
olle |
sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i]) |
3210 |
09 Apr 09 |
olle |
1133 |
} |
3210 |
09 Apr 09 |
olle |
1134 |
} |
3210 |
09 Apr 09 |
olle |
}else{ |
3210 |
09 Apr 09 |
olle |
if(key != ""){ |
3210 |
09 Apr 09 |
olle |
sout+=key+"={}" |
3210 |
09 Apr 09 |
olle |
key+="." |
3210 |
09 Apr 09 |
olle |
1139 |
} |
3210 |
09 Apr 09 |
olle |
1140 |
|
3210 |
09 Apr 09 |
olle |
for(var i in A){ |
3210 |
09 Apr 09 |
olle |
sout+="\n" |
3210 |
09 Apr 09 |
olle |
if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){ |
3210 |
09 Apr 09 |
olle |
sout+=_jmolEnumerateObject(A[i],key+i) |
3210 |
09 Apr 09 |
olle |
}else{ |
3210 |
09 Apr 09 |
olle |
sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i]) |
3210 |
09 Apr 09 |
olle |
1147 |
} |
3210 |
09 Apr 09 |
olle |
1148 |
} |
3210 |
09 Apr 09 |
olle |
1149 |
} |
3210 |
09 Apr 09 |
olle |
return sout |
3210 |
09 Apr 09 |
olle |
1151 |
} |
3210 |
09 Apr 09 |
olle |
1152 |
|
3210 |
09 Apr 09 |
olle |
1153 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSortKey0(a,b){ |
3210 |
09 Apr 09 |
olle |
return (a[0]<b[0]?1:a[0]>b[0]?-1:0) |
3210 |
09 Apr 09 |
olle |
1156 |
} |
3210 |
09 Apr 09 |
olle |
1157 |
|
3210 |
09 Apr 09 |
olle |
function _jmolSortMessages(A){ |
3210 |
09 Apr 09 |
olle |
if(!A || typeof(A)!="object")return [] |
3210 |
09 Apr 09 |
olle |
var B = [] |
3210 |
09 Apr 09 |
olle |
for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j] |
3210 |
09 Apr 09 |
olle |
if(B.length == 0) return |
3210 |
09 Apr 09 |
olle |
B=B.sort(_jmolSortKey0) |
3210 |
09 Apr 09 |
olle |
return B |
3210 |
09 Apr 09 |
olle |
1165 |
} |
3210 |
09 Apr 09 |
olle |
1166 |
|
3210 |
09 Apr 09 |
olle |
/////////additional extensions ////////// |
3210 |
09 Apr 09 |
olle |
1168 |
|
3210 |
09 Apr 09 |
olle |
1169 |
|
3210 |
09 Apr 09 |
olle |
function _jmolDomScriptLoad(URL){ |
3210 |
09 Apr 09 |
olle |
//open(URL) //to debug |
3210 |
09 Apr 09 |
olle |
_jmol.servercall=URL |
3210 |
09 Apr 09 |
olle |
var node = document.getElementById("_jmolScriptNode") |
3210 |
09 Apr 09 |
olle |
if (node && _jmol.browser!="msie"){ |
3210 |
09 Apr 09 |
olle |
document.getElementsByTagName("HEAD")[0].removeChild(node) |
3210 |
09 Apr 09 |
olle |
node=null |
3210 |
09 Apr 09 |
olle |
1177 |
} |
3210 |
09 Apr 09 |
olle |
if (node) { |
3210 |
09 Apr 09 |
olle |
node.setAttribute("src",URL) |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
node=document.createElement("script") |
3210 |
09 Apr 09 |
olle |
node.setAttribute("id","_jmolScriptNode") |
3210 |
09 Apr 09 |
olle |
node.setAttribute("type","text/javascript") |
3210 |
09 Apr 09 |
olle |
node.setAttribute("src",URL) |
3210 |
09 Apr 09 |
olle |
document.getElementsByTagName("HEAD")[0].appendChild(node) |
3210 |
09 Apr 09 |
olle |
1186 |
} |
3210 |
09 Apr 09 |
olle |
1187 |
} |
3210 |
09 Apr 09 |
olle |
1188 |
|
3210 |
09 Apr 09 |
olle |
1189 |
|
3210 |
09 Apr 09 |
olle |
function _jmolExtractPostData(url){ |
3210 |
09 Apr 09 |
olle |
S=url.split("&POST:") |
3210 |
09 Apr 09 |
olle |
var s="" |
3210 |
09 Apr 09 |
olle |
for(var i=1;i<S.length;i++){ |
3210 |
09 Apr 09 |
olle |
KV=S[i].split("=") |
3210 |
09 Apr 09 |
olle |
s+="&POSTKEY"+i+"="+KV[0] |
3210 |
09 Apr 09 |
olle |
s+="&POSTVALUE"+i+"="+KV[1] |
3210 |
09 Apr 09 |
olle |
1197 |
} |
3210 |
09 Apr 09 |
olle |
return "&url="+escape(S[0])+s |
3210 |
09 Apr 09 |
olle |
1199 |
} |
3210 |
09 Apr 09 |
olle |
1200 |
|
3210 |
09 Apr 09 |
olle |
function _jmolLoadModel(targetSuffix,remoteURL,array,isError,errorMessage){ |
3210 |
09 Apr 09 |
olle |
//called by server, but in client |
3210 |
09 Apr 09 |
olle |
//overload this function to customize return |
3210 |
09 Apr 09 |
olle |
_jmol.remoteURL=remoteURL |
3210 |
09 Apr 09 |
olle |
if(isError)alert(errorMessage) |
3210 |
09 Apr 09 |
olle |
jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix) |
3210 |
09 Apr 09 |
olle |
1207 |
} |
3210 |
09 Apr 09 |
olle |
1208 |
|
3210 |
09 Apr 09 |
olle |
//////////user property/status functions///////// |
3210 |
09 Apr 09 |
olle |
1210 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetStatus(strStatus,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
return _jmolSortMessages(jmolGetPropertyAsArray("jmolStatus",strStatus,targetSuffix)) |
3210 |
09 Apr 09 |
olle |
1213 |
} |
3210 |
09 Apr 09 |
olle |
1214 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetPropertyAsArray(sKey,sValue,targetSuffix) { |
3210 |
09 Apr 09 |
olle |
return _jmolEvalJSON(jmolGetPropertyAsJSON(sKey,sValue,targetSuffix),sKey) |
3210 |
09 Apr 09 |
olle |
1217 |
} |
3210 |
09 Apr 09 |
olle |
1218 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetPropertyAsString(sKey,sValue,targetSuffix) { |
3210 |
09 Apr 09 |
olle |
var applet = _jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if(!sValue)sValue="" |
3210 |
09 Apr 09 |
olle |
return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "") |
3210 |
09 Apr 09 |
olle |
1223 |
} |
3210 |
09 Apr 09 |
olle |
1224 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(!sValue)sValue = "" |
3210 |
09 Apr 09 |
olle |
var applet = _jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
try { |
3210 |
09 Apr 09 |
olle |
return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "") |
3210 |
09 Apr 09 |
olle |
} catch(e) { |
3210 |
09 Apr 09 |
olle |
return "" |
3210 |
09 Apr 09 |
olle |
1232 |
} |
3210 |
09 Apr 09 |
olle |
1233 |
} |
3210 |
09 Apr 09 |
olle |
1234 |
|
3210 |
09 Apr 09 |
olle |
function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(!sValue)sValue = "" |
3210 |
09 Apr 09 |
olle |
var applet = _jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
return (applet ? applet.getProperty(sKey,sValue) : null) |
3210 |
09 Apr 09 |
olle |
1239 |
} |
3210 |
09 Apr 09 |
olle |
1240 |
|
3210 |
09 Apr 09 |
olle |
1241 |
|
3210 |
09 Apr 09 |
olle |
function jmolDecodeJSON(s) { |
3210 |
09 Apr 09 |
olle |
return _jmolEnumerateObject(_jmolEvalJSON(s),"") |
3210 |
09 Apr 09 |
olle |
1244 |
} |
3210 |
09 Apr 09 |
olle |
1245 |
|
3210 |
09 Apr 09 |
olle |
1246 |
|
3210 |
09 Apr 09 |
olle |
///////// synchronous scripting //////// |
3210 |
09 Apr 09 |
olle |
1248 |
|
3210 |
09 Apr 09 |
olle |
function jmolScriptWait(script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
3210 |
09 Apr 09 |
olle |
var s = "" |
3210 |
09 Apr 09 |
olle |
for(var i=Ret.length;--i>=0;) |
3210 |
09 Apr 09 |
olle |
for(var j=0;j< Ret[i].length;j++) |
3210 |
09 Apr 09 |
olle |
s+=Ret[i][j]+"\n" |
3210 |
09 Apr 09 |
olle |
return s |
3210 |
09 Apr 09 |
olle |
1257 |
} |
3210 |
09 Apr 09 |
olle |
1258 |
|
3210 |
09 Apr 09 |
olle |
function jmolEvaluate(molecularMath, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
1260 |
|
3210 |
09 Apr 09 |
olle |
//carries out molecular math on a model |
3210 |
09 Apr 09 |
olle |
1262 |
|
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix); |
3210 |
09 Apr 09 |
olle |
var s = result.replace(/\-*\d+/,"") |
3210 |
09 Apr 09 |
olle |
if (s == "" && !isNaN(parseInt(result)))return parseInt(result); |
3210 |
09 Apr 09 |
olle |
var s = result.replace(/\-*\d*\.\d*/,"") |
3210 |
09 Apr 09 |
olle |
if (s == "" && !isNaN(parseFloat(result)))return parseFloat(result); |
3210 |
09 Apr 09 |
olle |
return result; |
3210 |
09 Apr 09 |
olle |
1270 |
} |
3210 |
09 Apr 09 |
olle |
1271 |
|
3210 |
09 Apr 09 |
olle |
function jmolScriptEcho(script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
// returns a newline-separated list of all echos from a script |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
3210 |
09 Apr 09 |
olle |
var s = "" |
3210 |
09 Apr 09 |
olle |
for(var i=Ret.length;--i>=0;) |
3210 |
09 Apr 09 |
olle |
for(var j=Ret[i].length;--j>=0;) |
3210 |
09 Apr 09 |
olle |
if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n" |
3210 |
09 Apr 09 |
olle |
return s.replace(/ \| /g, "\n") |
3210 |
09 Apr 09 |
olle |
1281 |
} |
3210 |
09 Apr 09 |
olle |
1282 |
|
3210 |
09 Apr 09 |
olle |
1283 |
|
3210 |
09 Apr 09 |
olle |
function jmolScriptMessage(script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
// returns a newline-separated list of all messages from a script, ending with "script completed\n" |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
3210 |
09 Apr 09 |
olle |
var s = "" |
3210 |
09 Apr 09 |
olle |
for(var i=Ret.length;--i>=0;) |
3210 |
09 Apr 09 |
olle |
for(var j=Ret[i].length;--j>=0;) |
3210 |
09 Apr 09 |
olle |
if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n" |
3210 |
09 Apr 09 |
olle |
return s.replace(/ \| /g, "\n") |
3210 |
09 Apr 09 |
olle |
1293 |
} |
3210 |
09 Apr 09 |
olle |
1294 |
|
3210 |
09 Apr 09 |
olle |
1295 |
|
3210 |
09 Apr 09 |
olle |
function jmolScriptWaitAsArray(script, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
var ret = "" |
3210 |
09 Apr 09 |
olle |
try{ |
3210 |
09 Apr 09 |
olle |
jmolGetStatus("scriptEcho,scriptMessage,scriptStatus,scriptError",targetSuffix) |
3210 |
09 Apr 09 |
olle |
if (script) { |
3210 |
09 Apr 09 |
olle |
_jmolCheckBrowser(); |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet) ret += applet.scriptWait(script); |
3210 |
09 Apr 09 |
olle |
ret = _jmolEvalJSON(ret,"jmolStatus") |
3210 |
09 Apr 09 |
olle |
if(typeof ret == "object") |
3210 |
09 Apr 09 |
olle |
return ret |
3210 |
09 Apr 09 |
olle |
1307 |
} |
3210 |
09 Apr 09 |
olle |
}catch(e){ |
3210 |
09 Apr 09 |
olle |
1309 |
} |
3210 |
09 Apr 09 |
olle |
return [[ret]] |
3210 |
09 Apr 09 |
olle |
1311 |
} |
3210 |
09 Apr 09 |
olle |
1312 |
|
3210 |
09 Apr 09 |
olle |
1313 |
|
3210 |
09 Apr 09 |
olle |
1314 |
|
3210 |
09 Apr 09 |
olle |
//////////// save/restore orientation ///////////// |
3210 |
09 Apr 09 |
olle |
1316 |
|
3210 |
09 Apr 09 |
olle |
function jmolSaveOrientation(id, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo |
3210 |
09 Apr 09 |
olle |
1320 |
} |
3210 |
09 Apr 09 |
olle |
1321 |
|
3210 |
09 Apr 09 |
olle |
function jmolRestoreOrientation(id, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var s=_jmol["savedOrientation"+id] |
3210 |
09 Apr 09 |
olle |
if (!s || s == "")return |
3210 |
09 Apr 09 |
olle |
s=s.replace(/1\.0/,"0") |
3210 |
09 Apr 09 |
olle |
return jmolScriptWait(s,targetSuffix) |
3210 |
09 Apr 09 |
olle |
1328 |
} |
3210 |
09 Apr 09 |
olle |
1329 |
|
3210 |
09 Apr 09 |
olle |
function jmolRestoreOrientationDelayed(id, delay, targetSuffix) { |
3210 |
09 Apr 09 |
olle |
if(arguments.length < 2)delay=1; |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
var s=_jmol["savedOrientation"+id] |
3210 |
09 Apr 09 |
olle |
if (!s || s == "")return |
3210 |
09 Apr 09 |
olle |
s=s.replace(/1\.0/,delay) |
3210 |
09 Apr 09 |
olle |
return jmolScriptWait(s,targetSuffix) |
3210 |
09 Apr 09 |
olle |
1337 |
} |
3210 |
09 Apr 09 |
olle |
1338 |
|
3210 |
09 Apr 09 |
olle |
//////////// add parameter ///////////// |
3210 |
09 Apr 09 |
olle |
1340 |
/* |
3210 |
09 Apr 09 |
olle |
* for adding callbacks or other parameters. Use: |
3210 |
09 Apr 09 |
olle |
1342 |
|
3210 |
09 Apr 09 |
olle |
jmolSetDocument(0) |
3210 |
09 Apr 09 |
olle |
var s= jmolApplet(....) |
3210 |
09 Apr 09 |
olle |
s = jmolAppletAddParam(s,"messageCallback", "myFunctionName") |
3210 |
09 Apr 09 |
olle |
document.write(s) |
3210 |
09 Apr 09 |
olle |
jmolSetDocument(document) // if you want to then write buttons and such normally |
3210 |
09 Apr 09 |
olle |
1348 |
|
3210 |
09 Apr 09 |
olle |
1349 |
*/ |
3210 |
09 Apr 09 |
olle |
1350 |
|
3210 |
09 Apr 09 |
olle |
function jmolAppletAddParam(appletCode,name,value){ |
3210 |
09 Apr 09 |
olle |
if(value == "")return appletCode |
3210 |
09 Apr 09 |
olle |
return appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param") |
3210 |
09 Apr 09 |
olle |
1354 |
} |
3210 |
09 Apr 09 |
olle |
1355 |
|
3210 |
09 Apr 09 |
olle |
///////////////auto load Research Consortium for Structural Biology (RCSB) data /////////// |
3210 |
09 Apr 09 |
olle |
1357 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
1359 |
|
3210 |
09 Apr 09 |
olle |
if(!_jmol.thismodel)_jmol.thismodel = "1crn" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.serverURL)_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.RCSBserver)_jmol.RCSBserver="http://www.rcsb.org" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.defaultURL_RCSB)_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF" |
3210 |
09 Apr 09 |
olle |
if(!fileformat)fileformat="PDB" |
3210 |
09 Apr 09 |
olle |
if(!pdbid)pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel) |
3210 |
09 Apr 09 |
olle |
if(!pdbid || pdbid.length != 4)return "" |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
if(!optionalscript)optionalscript="" |
3210 |
09 Apr 09 |
olle |
var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase()) |
3210 |
09 Apr 09 |
olle |
if(fileformat!="CIF")url=url.replace(/CIF/,fileformat) |
3210 |
09 Apr 09 |
olle |
_jmol.optionalscript=optionalscript |
3210 |
09 Apr 09 |
olle |
_jmol.thismodel=pdbid |
3210 |
09 Apr 09 |
olle |
_jmol.thistargetsuffix=targetSuffix |
3210 |
09 Apr 09 |
olle |
_jmol.thisurl=url |
3210 |
09 Apr 09 |
olle |
_jmol.modelArray = [] |
3210 |
09 Apr 09 |
olle |
url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) |
3210 |
09 Apr 09 |
olle |
_jmolDomScriptLoad(url) |
3210 |
09 Apr 09 |
olle |
return url |
3210 |
09 Apr 09 |
olle |
1379 |
} |
3210 |
09 Apr 09 |
olle |
1380 |
|
3210 |
09 Apr 09 |
olle |
/////////////// St. Olaf College AJAX server -- ANY URL /////////// |
3210 |
09 Apr 09 |
olle |
1382 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.thisurlANY)_jmol.thisurlANY = "http://www.stolaf.edu/depts/chemistry/mo/struc/data/ycp3-1.mol" |
3210 |
09 Apr 09 |
olle |
if(!url)url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY) |
3210 |
09 Apr 09 |
olle |
if(!userid)userid="0" |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
if(!optionalscript)optionalscript="" |
3210 |
09 Apr 09 |
olle |
_jmol.optionalscript=optionalscript |
3210 |
09 Apr 09 |
olle |
_jmol.thistargetsuffix=targetSuffix |
3210 |
09 Apr 09 |
olle |
_jmol.modelArray = [] |
3210 |
09 Apr 09 |
olle |
_jmol.thisurl = url |
3210 |
09 Apr 09 |
olle |
url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) |
3210 |
09 Apr 09 |
olle |
_jmolDomScriptLoad(url) |
3210 |
09 Apr 09 |
olle |
1396 |
} |
3210 |
09 Apr 09 |
olle |
1397 |
|
3210 |
09 Apr 09 |
olle |
1398 |
|
3210 |
09 Apr 09 |
olle |
/////////////// Mineralogical Society of America (MSA) data ///////// |
3210 |
09 Apr 09 |
olle |
1400 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
1402 |
|
3210 |
09 Apr 09 |
olle |
if(!_jmol.thiskeyMSA)_jmol.thiskeyMSA = "mineral" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.thismodelMSA)_jmol.thismodelMSA = "quartz" |
3210 |
09 Apr 09 |
olle |
if(!_jmol.ajaxURL_MSA)_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs" |
3210 |
09 Apr 09 |
olle |
if(!key)key=prompt("Enter a field:", _jmol.thiskeyMSA) |
3210 |
09 Apr 09 |
olle |
if(!key)return "" |
3210 |
09 Apr 09 |
olle |
if(!value)value=prompt("Enter a "+key+":", _jmol.thismodelMSA) |
3210 |
09 Apr 09 |
olle |
if(!value)return "" |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
if(!optionalscript)optionalscript="" |
3210 |
09 Apr 09 |
olle |
if(optionalscript == 1)optionalscript='load "" {1 1 1}' |
3210 |
09 Apr 09 |
olle |
var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value) |
3210 |
09 Apr 09 |
olle |
_jmol.optionalscript=optionalscript |
3210 |
09 Apr 09 |
olle |
_jmol.thiskeyMSA=key |
3210 |
09 Apr 09 |
olle |
_jmol.thismodelMSA=value |
3210 |
09 Apr 09 |
olle |
_jmol.thistargetsuffix=targetSuffix |
3210 |
09 Apr 09 |
olle |
_jmol.thisurl=url |
3210 |
09 Apr 09 |
olle |
_jmol.modelArray = [] |
3210 |
09 Apr 09 |
olle |
loadModel=_jmolLoadModel |
3210 |
09 Apr 09 |
olle |
_jmolDomScriptLoad(url) |
3210 |
09 Apr 09 |
olle |
return url |
3210 |
09 Apr 09 |
olle |
1423 |
} |
3210 |
09 Apr 09 |
olle |
1424 |
|
3210 |
09 Apr 09 |
olle |
1425 |
|
3210 |
09 Apr 09 |
olle |
1426 |
|
3210 |
09 Apr 09 |
olle |
function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
if(!userid)userid="0" |
3210 |
09 Apr 09 |
olle |
if(!targetSuffix)targetSuffix="0" |
3210 |
09 Apr 09 |
olle |
if(!optionalscript)optionalscript="" |
3210 |
09 Apr 09 |
olle |
_jmol.optionalscript=optionalscript |
3210 |
09 Apr 09 |
olle |
_jmol.thismodel=userid |
3210 |
09 Apr 09 |
olle |
_jmol.thistargetsuffix=targetSuffix |
3210 |
09 Apr 09 |
olle |
_jmol.modelArray = [] |
3210 |
09 Apr 09 |
olle |
_jmol.thisurl = url |
3210 |
09 Apr 09 |
olle |
url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix |
3210 |
09 Apr 09 |
olle |
_jmolDomScriptLoad(url) |
3210 |
09 Apr 09 |
olle |
1438 |
} |
3210 |
09 Apr 09 |
olle |
1439 |
|
3210 |
09 Apr 09 |
olle |
1440 |
|
3210 |
09 Apr 09 |
olle |
//// in case Jmol library has already been loaded: |
3210 |
09 Apr 09 |
olle |
1442 |
|
3210 |
09 Apr 09 |
olle |
}catch(e){} |
3210 |
09 Apr 09 |
olle |
1444 |
|
3210 |
09 Apr 09 |
olle |
///////////////moving atoms ////////////// |
3210 |
09 Apr 09 |
olle |
1446 |
|
3210 |
09 Apr 09 |
olle |
// HIGHLY experimental!! |
3210 |
09 Apr 09 |
olle |
1448 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetAtomCoord(i,x,y,z,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
_jmolCheckBrowser(); |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet) applet.getProperty('jmolViewer').setAtomCoord(i,x,y,z) |
3210 |
09 Apr 09 |
olle |
1453 |
} |
3210 |
09 Apr 09 |
olle |
1454 |
|
3210 |
09 Apr 09 |
olle |
function jmolSetAtomCoordRelative(i,x,y,z,targetSuffix){ |
3210 |
09 Apr 09 |
olle |
_jmolCheckBrowser(); |
3210 |
09 Apr 09 |
olle |
var applet=_jmolGetApplet(targetSuffix); |
3210 |
09 Apr 09 |
olle |
if (applet) applet.getProperty('jmolViewer').setAtomCoordRelative(i,x,y,z) |
3210 |
09 Apr 09 |
olle |
1459 |
} |
3210 |
09 Apr 09 |
olle |
1460 |
|
3210 |
09 Apr 09 |
olle |
1461 |
|
3210 |
09 Apr 09 |
olle |
///////////////applet fake for testing buttons///////////// |
3210 |
09 Apr 09 |
olle |
1463 |
|
3210 |
09 Apr 09 |
olle |
1464 |
|
3210 |
09 Apr 09 |
olle |
if(document.location.search.indexOf("NOAPPLET")>=0){ |
3210 |
09 Apr 09 |
olle |
jmolApplet = function(w){ |
3210 |
09 Apr 09 |
olle |
var s="<table style='background-color:black' width="+w+"><tr height="+w+">" |
3210 |
09 Apr 09 |
olle |
+"<td align=center valign=center style='background-color:white'>" |
3210 |
09 Apr 09 |
olle |
+"Applet would be here" |
3210 |
09 Apr 09 |
olle |
+"<p><textarea id=fakeApplet rows=5 cols=50></textarea>" |
3210 |
09 Apr 09 |
olle |
+"</td></tr></table>" |
3210 |
09 Apr 09 |
olle |
return _jmolDocumentWrite(s) |
3210 |
09 Apr 09 |
olle |
1473 |
} |
3210 |
09 Apr 09 |
olle |
1474 |
|
3210 |
09 Apr 09 |
olle |
_jmolFindApplet = function(){return jmolApplet0} |
3210 |
09 Apr 09 |
olle |
1476 |
|
3210 |
09 Apr 09 |
olle |
jmolApplet0 = { |
3210 |
09 Apr 09 |
olle |
script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script} |
3210 |
09 Apr 09 |
olle |
,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\n"+script} |
3210 |
09 Apr 09 |
olle |
,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script} |
3210 |
09 Apr 09 |
olle |
1481 |
} |
3210 |
09 Apr 09 |
olle |
1482 |
} |
3210 |
09 Apr 09 |
olle |
1483 |
|
3210 |
09 Apr 09 |
olle |
1484 |
|
3210 |
09 Apr 09 |
olle |
1485 |
/////////////////////////////////////////// |
3210 |
09 Apr 09 |
olle |
1486 |
|
3210 |
09 Apr 09 |
olle |
//new 9:49 AM 3/6/2007: |
3210 |
09 Apr 09 |
olle |
1488 |
|
3210 |
09 Apr 09 |
olle |
//both w and h are optional. |
3210 |
09 Apr 09 |
olle |
//if either is between 0 and 1, then it is taken as percent/100. |
3210 |
09 Apr 09 |
olle |
//if either is greater than 1, then it is taken as a size. |
3210 |
09 Apr 09 |
olle |
function jmolResize(w,h) { |
3210 |
09 Apr 09 |
olle |
_jmol.alerted = true; |
3210 |
09 Apr 09 |
olle |
var percentW = (!w ? 100 : w <= 1 && w > 0 ? w * 100 : 0) |
3210 |
09 Apr 09 |
olle |
var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0) |
3210 |
09 Apr 09 |
olle |
if (_jmol.browser=="msie") { |
3210 |
09 Apr 09 |
olle |
var width=document.body.clientWidth; |
3210 |
09 Apr 09 |
olle |
var height=document.body.clientHeight; |
3210 |
09 Apr 09 |
olle |
} else { |
3210 |
09 Apr 09 |
olle |
var netscapeScrollWidth=15; |
3210 |
09 Apr 09 |
olle |
var width=window.innerWidth - netscapeScrollWidth; |
3210 |
09 Apr 09 |
olle |
var height=window.innerHeight-netscapeScrollWidth; |
3210 |
09 Apr 09 |
olle |
1503 |
} |
3210 |
09 Apr 09 |
olle |
var applet = _jmolGetApplet(0); |
3210 |
09 Apr 09 |
olle |
if(!applet)return; |
3210 |
09 Apr 09 |
olle |
applet.style.width = (percentW ? width * percentW/100 : w)+"px" |
3210 |
09 Apr 09 |
olle |
applet.style.height = (percentH ? height * percentH/100 : h)+"px" |
3210 |
09 Apr 09 |
olle |
title=width + " " + height + " " + (new Date()) |
3210 |
09 Apr 09 |
olle |
1509 |
} |
3210 |
09 Apr 09 |
olle |
1510 |
|