Rev 17 | Rev 2876 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 17 | Rev 1365 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* Jmol 11.7 script library Jmol.js 15:32 06.12.2008 Bob Hanson |
2 | * $Author: migueljmol $ |
- | |
- | 2 | ||
3 | |
3 | checkbox heirarchy -- see http://chemapps.stolaf.edu/jmol/docs/examples-11/check.htm |
- | 4 | ||
4 | |
5 | based on: |
5 | * |
6 | * |
6 | * Copyright (C) 2004 |
7 | * Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org |
7 | * |
8 | * |
8 | * Contact: |
9 | * Contact: hansonr@stolaf.edu |
9 | * |
10 | * |
10 | * This library is free software; you can redistribute it and/or |
11 | * This library is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU Lesser General Public |
12 | * modify it under the terms of the GNU Lesser General Public |
12 | * License as published by the Free Software Foundation; either |
13 | * License as published by the Free Software Foundation; either |
13 | * version 2.1 of the License, or (at your option) any later version. |
14 | * version 2.1 of the License, or (at your option) any later version. |
Line 22... | Line 23... | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
23 | * 02111-1307 USA. |
24 | * 02111-1307 USA. |
24 | */ |
25 | */ |
25 | 26 | ||
26 | // for documentation see www.jmol.org/jslibrary |
27 | // for documentation see www.jmol.org/jslibrary |
- | 28 | ||
- | 29 | try{if(typeof(_jmol)!="undefined")exit() |
|
- | 30 | ||
- | 31 | // place "?NOAPPLET" on your command line to check applet control action with a textarea |
|
- | 32 | // place "?JMOLJAR=xxxxx" to use a specific jar file |
|
- | 33 | ||
- | 34 | // bob hanson -- jmolResize(w,h) -- resizes absolutely or by percent (w or h 0.5 means 50%) |
|
- | 35 | // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007 |
|
- | 36 | // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007 |
|
- | 37 | // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007 |
|
- | 38 | // bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006 |
|
- | 39 | // bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006 |
|
- | 40 | // bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006 |
|
- | 41 | // bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006 |
|
- | 42 | // bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired. |
|
- | 43 | // bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006 |
|
- | 44 | // bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006 |
|
- | 45 | // bob hanson -- fix for iframes not available for finding applet |
|
- | 46 | // bob hanson -- added applet fake ?NOAPPLET URL flag |
|
- | 47 | // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006 |
|
- | 48 | // used PRIOR to jmolApplet() or jmolAppletInline() |
|
- | 49 | // added 4th array element in jmolRadioGroup -- title |
|
- | 50 | // added <span> and id around link, checkbox, radio, menu |
|
- | 51 | // fixing AJAX loads for MSIE/Opera-Mozilla incompatibility |
|
- | 52 | // -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar |
|
- | 53 | // renamed Jmol.js for Jmol 11 distribution |
|
- | 54 | // -- modified jmolRestoreOrientation() to be immediate, no 1-second delay |
|
- | 55 | // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006 |
|
- | 56 | // bh -- jmolCommandInput() |
|
- | 57 | // bh -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues |
|
- | 58 | // bh -- minor fixes suggested by Angel |
|
- | 59 | // bh -- adds jmolSetSyncId() and jmolGetSyncId() |
|
- | 60 | // bh 3/2008 -- adds jmolAppendInlineScript() and jmolAppendInlineArray() |
|
- | 61 | // bh 3/2008 -- fixes IE7 bug in relation to jmolLoadInlineArray() |
|
- | 62 | // bh 6/2008 -- adds jmolSetAppletWindow() |
|
- | 63 | // Angel H. 6/2008 -- added html <label> tags to checkboxes and radio buttons [in jmolCheckbox() and _jmolRadio() functions] |
|
- | 64 | // bh 7/2008 -- code fix "for(i..." not "for(var i..." |
|
- | 65 | // bh 12/2008 -- jmolLoadInline, jmolLoadInlineArray, jmolLoadInlineScript, jmolAppendInlineScript, jmolAppendInlineArray all return error message or null (Jmol 11.7.16) |
|
- | 66 | // bh 12/2008 -- jmolScriptWaitOutput() -- waits for script to complete and delivers output normally sent to console |
|
- | 67 | ||
- | 68 | var defaultdir = "." |
|
- | 69 | var defaultjar = "JmolApplet.jar" |
|
- | 70 | ||
- | 71 | ||
- | 72 | // Note added 12:41 PM 9/21/2008 by Bob Hanson, hansonr@stolaf.edu: |
|
- | 73 | ||
- | 74 | // JMOLJAR=xxxxx.jar on the URL for this page will override |
|
- | 75 | // the JAR file specified in the jmolInitialize() call. |
|
- | 76 | ||
- | 77 | // The idea is that it can be very useful to test a web page with different JAR files |
|
- | 78 | // Or for an expert user to substitute a signed applet for an unsigned one |
|
- | 79 | // so as to use a broader range of models or to create JPEG files, for example. |
|
- | 80 | ||
- | 81 | // If the JAR file is not in the current directory (has any sort of "/" in its name) |
|
- | 82 | // then the user is presented with a warning and asked whether it is OK to change Jar files. |
|
- | 83 | // The default action, if the user just presses "OK" is to NOT allow the change. |
|
- | 84 | // The user must type the word "yes" in the prompt box for the change to be approved. |
|
- | 85 | ||
- | 86 | // If you don't want people to be able to switch in their own JAR file on your page, |
|
- | 87 | // simply set this next line to read "var allowJMOLJAR = false". |
|
- | 88 | ||
- | 89 | ||
- | 90 | var allowJMOLJAR = true |
|
- | 91 | ||
27 | 92 | ||
28 | var undefined; // for IE 5 ... wherein undefined is undefined |
93 | var undefined; // for IE 5 ... wherein undefined is undefined |
29 | 94 | ||
30 | //////////////////////////////////////////////////////////////// |
95 | //////////////////////////////////////////////////////////////// |
31 | // Basic Scripting infrastruture |
96 | // Basic Scripting infrastruture |
32 | //////////////////////////////////////////////////////////////// |
97 | //////////////////////////////////////////////////////////////// |
33 | 98 | ||
34 | function jmolInitialize(codebaseDirectory) { |
99 | function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) { |
35 | if (_jmol.initialized) |
100 | if (_jmol.initialized) |
36 | alert("jmolInitialize() should only be called *ONCE* within a page"); |
- | |
37 | return; |
101 | return; |
- | 102 | _jmol.initialized = true; |
|
- | 103 | if(allowJMOLJAR && document.location.search.indexOf("JMOLJAR=")>=0) { |
|
- | 104 | var f = document.location.search.split("JMOLJAR=")[1].split("&")[0]; |
|
- | 105 | if (f.indexOf("/") >= 0) { |
|
- | 106 | 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.") |
|
- | 107 | var ok = prompt("Do you want to use applet " + f + "? ","yes or no") |
|
- | 108 | if (ok == "yes") { |
|
- | 109 | codebaseDirectory = f.substring(0, f.lastIndexOf("/")); |
|
- | 110 | fileNameOrUseSignedApplet = f.substring(f.lastIndexOf("/") + 1); |
|
- | 111 | } else { |
|
- | 112 | _jmolGetJarFilename(fileNameOrUseSignedApplet); |
|
- | 113 | alert("The web page URL was ignored. Continuing using " + _jmol.archivePath + ' in directory "' + codebaseDirectory + '"'); |
|
- | 114 | } |
|
- | 115 | } else { |
|
- | 116 | fileNameOrUseSignedApplet = f; |
|
- | 117 | } |
|
38 | } |
118 | } |
39 | if (! codebaseDirectory) { |
- | |
40 | alert("codebaseDirectory is a required parameter to jmolInitialize"); |
- | |
41 | codebaseDirectory = "."; |
- | |
42 | } |
- | |
43 | if (codebaseDirectory.indexOf("http://") == 0 || |
- | |
44 | codebaseDirectory.indexOf("https://") == 0) |
- | |
45 | alert("codebaseDirectory should be directory relative,\n" + |
- | |
46 | "not be an absolute URL : " + codebaseDirectory); |
- | |
47 | else if (codebaseDirectory.charAt(0) == '/') |
- | |
48 | alert("codebaseDirectory should be directory relative,\n" + |
- | |
49 | "not relative to the root of the web server : " + codebaseDirectory); |
- | |
50 | _jmolSetCodebase(codebaseDirectory); |
119 | _jmolSetCodebase(codebaseDirectory); |
- | 120 | _jmolGetJarFilename(fileNameOrUseSignedApplet); |
|
51 | _jmolOnloadResetForms(); |
121 | _jmolOnloadResetForms(); |
- | 122 | } |
|
- | 123 | ||
- | 124 | function jmolSetTranslation(TF) { |
|
- | 125 | _jmol.params.doTranslate = ''+TF; |
|
- | 126 | } |
|
- | 127 | ||
- | 128 | function _jmolGetJarFilename(fileNameOrFlag) { |
|
- | 129 | _jmol.archivePath = |
|
- | 130 | (typeof(fileNameOrFlag) == "string" ? fileNameOrFlag : (fileNameOrFlag ? "JmolAppletSigned" : "JmolApplet") + "0.jar"); |
|
- | 131 | } |
|
- | 132 | ||
- | 133 | function jmolSetDocument(doc) { |
|
52 | _jmol. |
134 | _jmol.currentDocument = doc; |
53 | } |
135 | } |
54 | 136 | ||
55 | function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) { |
137 | function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) { |
56 | _jmolInitCheck(); |
138 | _jmolInitCheck(); |
57 | _jmol.boxbgcolor = boxbgcolor; |
139 | _jmol.params.boxbgcolor = boxbgcolor; |
58 | if (boxfgcolor) |
140 | if (boxfgcolor) |
59 | _jmol.boxfgcolor = boxfgcolor |
141 | _jmol.params.boxfgcolor = boxfgcolor |
60 | else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF") |
142 | else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF") |
61 | _jmol.boxfgcolor = "black"; |
143 | _jmol.params.boxfgcolor = "black"; |
62 | else |
144 | else |
63 | _jmol.boxfgcolor = "white"; |
145 | _jmol.params.boxfgcolor = "white"; |
64 | if (progresscolor) |
146 | if (progresscolor) |
65 | _jmol.progresscolor = progresscolor; |
147 | _jmol.params.progresscolor = progresscolor; |
66 | if (_jmol.debugAlert) |
148 | if (_jmol.debugAlert) |
67 | alert(" boxbgcolor=" + _jmol.boxbgcolor + |
149 | alert(" boxbgcolor=" + _jmol.params.boxbgcolor + |
68 | " boxfgcolor=" + _jmol.boxfgcolor + |
150 | " boxfgcolor=" + _jmol.params.boxfgcolor + |
69 | " progresscolor=" + _jmol.progresscolor); |
151 | " progresscolor=" + _jmol.params.progresscolor); |
- | 152 | } |
|
- | 153 | ||
- | 154 | function jmolSetAppletWindow(w) { |
|
- | 155 | _jmol.appletWindow = w; |
|
70 | } |
156 | } |
71 | 157 | ||
72 | function jmolApplet(size, script, nameSuffix) { |
158 | function jmolApplet(size, script, nameSuffix) { |
73 | _jmolInitCheck(); |
159 | _jmolInitCheck(); |
74 | _jmolApplet(size, null, script, nameSuffix); |
160 | return _jmolApplet(size, null, script, nameSuffix); |
75 | } |
161 | } |
76 | 162 | ||
77 | //////////////////////////////////////////////////////////////// |
163 | //////////////////////////////////////////////////////////////// |
78 | // Basic controls |
164 | // Basic controls |
79 | //////////////////////////////////////////////////////////////// |
165 | //////////////////////////////////////////////////////////////// |
80 | 166 | ||
81 | function jmolButton(script, label, id) { |
167 | function jmolButton(script, label, id, title) { |
82 | _jmolInitCheck(); |
168 | _jmolInitCheck(); |
83 | var scriptIndex = _jmolAddScript(script); |
- | |
84 | if (label == undefined || label == null) |
- | |
85 | label = script.substring(0, 32); |
- | |
86 | if (id == undefined || id == null) |
169 | if (id == undefined || id == null) |
87 | id = "jmolButton" + _jmol.buttonCount; |
170 | id = "jmolButton" + _jmol.buttonCount; |
- | 171 | if (label == undefined || label == null) |
|
- | 172 | label = script.substring(0, 32); |
|
88 | ++_jmol.buttonCount; |
173 | ++_jmol.buttonCount; |
- | 174 | var scriptIndex = _jmolAddScript(script); |
|
89 | var t = "<input type='button' name='" + id + "' id='" + id + |
175 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id + |
90 | "' value='" + label + |
176 | "' value='" + label + |
91 | "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText + |
177 | "' onClick='_jmolClick(" + scriptIndex + _jmol.targetText + |
92 | ")' onMouseover='_jmolMouseOver(" + scriptIndex + |
178 | ")' onMouseover='_jmolMouseOver(" + scriptIndex + |
93 | ");return true' onMouseout='_jmolMouseOut()' " + |
179 | ");return true' onMouseout='_jmolMouseOut()' " + |
94 | _jmol.buttonCssText + "/>"; |
180 | _jmol.buttonCssText + "/></span>"; |
95 | if (_jmol.debugAlert) |
181 | if (_jmol.debugAlert) |
96 | alert(t); |
182 | alert(t); |
97 |
|
183 | return _jmolDocumentWrite(t); |
98 | } |
184 | } |
99 | 185 | ||
100 | function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked, |
186 | function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked, |
101 | labelHtml, isChecked, id) { |
187 | labelHtml, isChecked, id, title) { |
102 | _jmolInitCheck(); |
188 | _jmolInitCheck(); |
103 | if (id == undefined || id == null) |
189 | if (id == undefined || id == null) |
104 | id = "jmolCheckbox" + _jmol.checkboxCount; |
190 | id = "jmolCheckbox" + _jmol.checkboxCount; |
105 | ++_jmol.checkboxCount; |
191 | ++_jmol.checkboxCount; |
106 | if (scriptWhenChecked == undefined || scriptWhenChecked == null || |
192 | if (scriptWhenChecked == undefined || scriptWhenChecked == null || |
Line 112... | Line 198... | ||
112 | alert("jmolCheckbox requires a label"); |
198 | alert("jmolCheckbox requires a label"); |
113 | return; |
199 | return; |
114 | } |
200 | } |
115 | var indexChecked = _jmolAddScript(scriptWhenChecked); |
201 | var indexChecked = _jmolAddScript(scriptWhenChecked); |
116 | var indexUnchecked = _jmolAddScript(scriptWhenUnchecked); |
202 | var indexUnchecked = _jmolAddScript(scriptWhenUnchecked); |
- | 203 | var eospan = "</span>" |
|
117 | var t = "<input type='checkbox' name='" + id + "' id='" + id + |
204 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id + |
118 | "' onClick='_jmolCbClick(this," + |
205 | "' onClick='_jmolCbClick(this," + |
119 | indexChecked + "," + indexUnchecked + _jmol.targetText + |
206 | indexChecked + "," + indexUnchecked + _jmol.targetText + |
120 | ")' onMouseover='_jmolCbOver(this," + indexChecked + "," + |
207 | ")' onMouseover='_jmolCbOver(this," + indexChecked + "," + |
121 | indexUnchecked + |
208 | indexUnchecked + |
122 | ");return true' onMouseout='_jmolMouseOut()' " + |
209 | ");return true' onMouseout='_jmolMouseOut()' " + |
123 | (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" |
210 | (isChecked ? "checked " : "") + _jmol.checkboxCssText + "/>" |
- | 211 | if (labelHtml.toLowerCase().indexOf("<td>")>=0) { |
|
- | 212 | t += eospan |
|
124 |
|
213 | eospan = ""; |
- | 214 | } |
|
- | 215 | t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan; |
|
125 | if (_jmol.debugAlert) |
216 | if (_jmol.debugAlert) |
126 | alert(t); |
217 | alert(t); |
127 |
|
218 | return _jmolDocumentWrite(t); |
- | 219 | } |
|
- | 220 | ||
- | 221 | function jmolStartNewRadioGroup() { |
|
- | 222 | ++_jmol.radioGroupCount; |
|
128 | } |
223 | } |
129 | 224 | ||
130 | function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName) { |
225 | function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName, id, title) { |
- | 226 | /* |
|
- | 227 | ||
- | 228 | array: [radio1,radio2,radio3...] |
|
- | 229 | where radioN = ["script","label",isSelected,"id","title"] |
|
- | 230 | ||
- | 231 | */ |
|
- | 232 | ||
131 | _jmolInitCheck(); |
233 | _jmolInitCheck(); |
132 | var type = typeof arrayOfRadioButtons; |
234 | var type = typeof arrayOfRadioButtons; |
133 | if (type != "object" || type == null || ! arrayOfRadioButtons.length) { |
235 | if (type != "object" || type == null || ! arrayOfRadioButtons.length) { |
134 | alert("invalid arrayOfRadioButtons"); |
236 | alert("invalid arrayOfRadioButtons"); |
135 | return; |
237 | return; |
136 | } |
238 | } |
137 | if (separatorHtml == undefined || separatorHtml == null) |
239 | if (separatorHtml == undefined || separatorHtml == null) |
138 | separatorHtml = " "; |
240 | separatorHtml = " "; |
139 | var |
241 | var len = arrayOfRadioButtons.length; |
140 | var t = ""; |
- | |
141 | jmolStartNewRadioGroup(); |
242 | jmolStartNewRadioGroup(); |
- | 243 | if (!groupName) |
|
- | 244 | groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1); |
|
- | 245 | var t = "<span id='"+(id ? id : groupName)+"'>"; |
|
142 | for (var i = 0; i < |
246 | for (var i = 0; i < len; ++i) { |
- | 247 | if (i == len - 1) |
|
- | 248 | separatorHtml = ""; |
|
143 | var radio = arrayOfRadioButtons[i]; |
249 | var radio = arrayOfRadioButtons[i]; |
144 | type = typeof radio; |
250 | type = typeof radio; |
145 | if (type == "object") { |
251 | if (type == "object") { |
146 | t += _jmolRadio(radio[0], radio[1], radio[2], separatorHtml, groupName); |
252 | 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); |
147 | } else { |
253 | } else { |
148 | t += _jmolRadio(radio, null, null, separatorHtml, groupName); |
254 | t += _jmolRadio(radio, null, null, separatorHtml, groupName, (id ? id : groupName)+"_"+i, title); |
149 | } |
255 | } |
150 | } |
256 | } |
- | 257 | t+="</span>" |
|
151 | if (_jmol.debugAlert) |
258 | if (_jmol.debugAlert) |
152 | alert(t); |
259 | alert(t); |
153 |
|
260 | return _jmolDocumentWrite(t); |
154 | } |
261 | } |
155 | 262 | ||
- | 263 | ||
- | 264 | function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) { |
|
- | 265 | _jmolInitCheck(); |
|
- | 266 | if (_jmol.radioGroupCount == 0) |
|
- | 267 | ++_jmol.radioGroupCount; |
|
- | 268 | var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, (id ? id : groupName + "_" + _jmol.radioCount), title ? title : 0); |
|
- | 269 | if (_jmol.debugAlert) |
|
- | 270 | alert(t); |
|
- | 271 | return _jmolDocumentWrite(t); |
|
- | 272 | } |
|
- | 273 | ||
156 | function jmolLink(script, |
274 | function jmolLink(script, label, id, title) { |
- | 275 | _jmolInitCheck(); |
|
- | 276 | if (id == undefined || id == null) |
|
- | 277 | id = "jmolLink" + _jmol.linkCount; |
|
- | 278 | if (label == undefined || label == null) |
|
- | 279 | label = script.substring(0, 32); |
|
- | 280 | ++_jmol.linkCount; |
|
- | 281 | var scriptIndex = _jmolAddScript(script); |
|
- | 282 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><a name='" + id + "' id='" + id + |
|
- | 283 | "' href='javascript:_jmolClick(" + scriptIndex + _jmol.targetText + ");' onMouseover='_jmolMouseOver(" + scriptIndex + |
|
- | 284 | ");return true;' onMouseout='_jmolMouseOut()' " + |
|
- | 285 | _jmol.linkCssText + ">" + label + "</a></span>"; |
|
- | 286 | if (_jmol.debugAlert) |
|
- | 287 | alert(t); |
|
- | 288 | return _jmolDocumentWrite(t); |
|
- | 289 | } |
|
- | 290 | ||
- | 291 | function jmolCommandInput(label, size, id, title) { |
|
157 | _jmolInitCheck(); |
292 | _jmolInitCheck(); |
158 | if (id == undefined || id == null) |
293 | if (id == undefined || id == null) |
159 | id = " |
294 | id = "jmolCmd" + _jmol.cmdCount; |
160 |
|
295 | if (label == undefined || label == null) |
161 |
|
296 | label = "Execute"; |
162 |
|
297 | if (size == undefined || isNaN(size)) |
163 |
|
298 | size = 60; |
164 |
|
299 | ++_jmol.cmdCount; |
165 |
|
300 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" + id + "' id='" + id + |
166 | " |
301 | "' size='"+size+"'><input type=button value = '"+label+"' onClick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")'/></span>"; |
167 | _jmol.linkCssText + ">" + text + "</a>"; |
- | |
168 | if (_jmol.debugAlert) |
302 | if (_jmol.debugAlert) |
169 | alert(t); |
303 | alert(t); |
170 |
|
304 | return _jmolDocumentWrite(t); |
171 | } |
305 | } |
172 | 306 | ||
173 | function jmolMenu(arrayOfMenuItems, size, id) { |
307 | function jmolMenu(arrayOfMenuItems, size, id, title) { |
174 | _jmolInitCheck(); |
308 | _jmolInitCheck(); |
175 | if (id == undefined || id == null) |
309 | if (id == undefined || id == null) |
176 | id = "jmolMenu" + _jmol.menuCount; |
310 | id = "jmolMenu" + _jmol.menuCount; |
177 | ++_jmol.menuCount; |
311 | ++_jmol.menuCount; |
178 | var type = typeof arrayOfMenuItems; |
312 | var type = typeof arrayOfMenuItems; |
179 | if (type != null && type == "object" && arrayOfMenuItems.length) { |
313 | if (type != null && type == "object" && arrayOfMenuItems.length) { |
180 | var |
314 | var len = arrayOfMenuItems.length; |
181 | if (typeof size != "number" || size == 1) |
315 | if (typeof size != "number" || size == 1) |
182 | size = null; |
316 | size = null; |
183 | else if (size < 0) |
317 | else if (size < 0) |
184 | size = |
318 | size = len; |
185 | var sizeText = size ? " size='" + size + "' " : ""; |
319 | var sizeText = size ? " size='" + size + "' " : ""; |
186 | var t = "<select name='" + id + "' id='" + id + |
320 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><select name='" + id + "' id='" + id + |
187 | "' onChange='_jmolMenuSelected(this" + |
321 | "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" + |
188 | _jmol.targetText + ")'" + |
- | |
189 | sizeText + _jmol.menuCssText + ">"; |
322 | sizeText + _jmol.menuCssText + ">"; |
190 | for (var i = 0; i < |
323 | for (var i = 0; i < len; ++i) { |
191 | var menuItem = arrayOfMenuItems[i]; |
324 | var menuItem = arrayOfMenuItems[i]; |
192 | type = typeof menuItem; |
325 | type = typeof menuItem; |
193 | var script, text; |
326 | var script, text; |
194 | var isSelected = undefined; |
327 | var isSelected = undefined; |
195 | if (type == "object" && menuItem != null) { |
328 | if (type == "object" && menuItem != null) { |
Line 198... | Line 331... | ||
198 | isSelected = menuItem[2]; |
331 | isSelected = menuItem[2]; |
199 | } else { |
332 | } else { |
200 | script = text = menuItem; |
333 | script = text = menuItem; |
201 | } |
334 | } |
202 | if (text == undefined || text == null) |
335 | if (text == undefined || text == null) |
203 | text = script; |
336 | text = script; |
- | 337 | if (script=="#optgroup") { |
|
- | 338 | t += "<optgroup label='" + text + "'>"; |
|
- | 339 | } else if (script=="#optgroupEnd") { |
|
- | 340 | t += "</optgroup>"; |
|
- | 341 | } else { |
|
204 | var scriptIndex = _jmolAddScript(script); |
342 | var scriptIndex = _jmolAddScript(script); |
205 | var selectedText = isSelected ? "' selected>" : "'>"; |
343 | var selectedText = isSelected ? "' selected>" : "'>"; |
206 | t += "<option value='" + scriptIndex + selectedText + text + "</option>"; |
344 | t += "<option value='" + scriptIndex + selectedText + text + "</option>"; |
- | 345 | } |
|
207 | } |
346 | } |
208 | t += "</select>"; |
347 | t += "</select></span>"; |
209 | if (_jmol.debugAlert) |
348 | if (_jmol.debugAlert) |
210 | alert(t); |
349 | alert(t); |
211 |
|
350 | return _jmolDocumentWrite(t); |
212 | } |
351 | } |
213 | } |
352 | } |
214 | 353 | ||
215 | function jmolHtml(html) { |
354 | function jmolHtml(html) { |
216 |
|
355 | return _jmolDocumentWrite(html); |
217 | } |
356 | } |
218 | 357 | ||
219 | function jmolBr() { |
358 | function jmolBr() { |
220 |
|
359 | return _jmolDocumentWrite("<br />"); |
221 | } |
360 | } |
222 | 361 | ||
223 | //////////////////////////////////////////////////////////////// |
362 | //////////////////////////////////////////////////////////////// |
224 | // advanced scripting functions |
363 | // advanced scripting functions |
225 | //////////////////////////////////////////////////////////////// |
364 | //////////////////////////////////////////////////////////////// |
Line 227... | Line 366... | ||
227 | function jmolDebugAlert(enableAlerts) { |
366 | function jmolDebugAlert(enableAlerts) { |
228 | _jmol.debugAlert = (enableAlerts == undefined || enableAlerts) |
367 | _jmol.debugAlert = (enableAlerts == undefined || enableAlerts) |
229 | } |
368 | } |
230 | 369 | ||
231 | function jmolAppletInline(size, inlineModel, script, nameSuffix) { |
370 | function jmolAppletInline(size, inlineModel, script, nameSuffix) { |
- | 371 | _jmolInitCheck(); |
|
232 | _jmolApplet |
372 | return _jmolApplet(size, _jmolSterilizeInline(inlineModel), |
- | 373 | script, nameSuffix); |
|
233 | } |
374 | } |
234 | 375 | ||
235 | function jmolSetTarget(targetSuffix) { |
376 | function jmolSetTarget(targetSuffix) { |
236 | _jmol.targetSuffix = targetSuffix; |
377 | _jmol.targetSuffix = targetSuffix; |
237 | _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : ""; |
378 | _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : ""; |
238 | } |
379 | } |
239 | 380 | ||
240 | function jmolScript(script, targetSuffix) { |
381 | function jmolScript(script, targetSuffix) { |
241 | if (script) { |
382 | if (script) { |
242 | _jmolCheckBrowser(); |
383 | _jmolCheckBrowser(); |
243 |
|
384 | if (targetSuffix == "all") { |
- | 385 | with (_jmol) { |
|
244 | var |
386 | for (var i = 0; i < appletSuffixes.length; ++i) { |
245 |
|
387 | var applet = _jmolGetApplet(appletSuffixes[i]); |
246 |
|
388 | if (applet) applet.script(script); |
- | 389 | } |
|
- | 390 | } |
|
247 | else |
391 | } else { |
- | 392 | var applet=_jmolGetApplet(targetSuffix); |
|
248 |
|
393 | if (applet) applet.script(script); |
- | 394 | } |
|
249 | } |
395 | } |
250 | } |
396 | } |
251 | 397 | ||
252 | function jmolLoadInline(model, targetSuffix) { |
398 | function jmolLoadInline(model, targetSuffix) { |
253 | if (model) |
399 | if (!model)return "ERROR: NO MODEL" |
254 |
|
400 | var applet=_jmolGetApplet(targetSuffix); |
- | 401 | if (!applet)return "ERROR: NO APPLET" |
|
255 |
|
402 | if (typeof(model) == "string") |
256 |
|
403 | return applet.loadInlineString(model, "", false); |
- | 404 | else |
|
- | 405 | return applet.loadInlineArray(model, "", false); |
|
- | 406 | } |
|
- | 407 | ||
- | 408 | ||
- | 409 | function jmolLoadInlineScript(model, script, targetSuffix) { |
|
- | 410 | if (!model)return "ERROR: NO MODEL" |
|
257 |
|
411 | var applet=_jmolGetApplet(targetSuffix); |
- | 412 | if (!applet)return "ERROR: NO APPLET" |
|
258 |
|
413 | return applet.loadInlineString(model, script, false); |
- | 414 | } |
|
- | 415 | ||
- | 416 | ||
259 |
|
417 | function jmolLoadInlineArray(ModelArray, script, targetSuffix) { |
- | 418 | if (!model)return "ERROR: NO MODEL" |
|
- | 419 | if (!script)script="" |
|
260 |
|
420 | var applet=_jmolGetApplet(targetSuffix); |
- | 421 | if (!applet)return "ERROR: NO APPLET" |
|
261 |
|
422 | try { |
262 |
|
423 | return applet.loadInlineArray(ModelArray, script, false); |
263 |
|
424 | } catch (err) { |
- | 425 | //IE 7 bug |
|
264 |
|
426 | return applet.loadInlineString(ModelArray.join("\n"), script, false); |
- | 427 | } |
|
- | 428 | } |
|
- | 429 | ||
- | 430 | function jmolAppendInlineArray(ModelArray, script, targetSuffix) { |
|
- | 431 | if (!model)return "ERROR: NO MODEL" |
|
- | 432 | if (!script)script="" |
|
- | 433 | var applet=_jmolGetApplet(targetSuffix); |
|
- | 434 | if (!applet)return "ERROR: NO APPLET" |
|
265 |
|
435 | try { |
266 |
|
436 | return applet.loadInlineArray(ModelArray, script, true); |
- | 437 | } catch (err) { |
|
267 | / |
438 | //IE 7 bug |
- | 439 | return applet.loadInlineString(ModelArray.join("\n"), script, true); |
|
268 | } |
440 | } |
269 | } |
441 | } |
270 | 442 | ||
271 | function jmolStartNewRadioGroup() { |
- | |
272 | ++_jmol.radioGroupCount; |
- | |
273 | } |
- | |
274 | - | ||
275 | function |
443 | function jmolAppendInlineScript(model, script, targetSuffix) { |
276 | _jmolInitCheck(); |
- | |
277 | if ( |
444 | if (!model)return "ERROR: NO MODEL" |
278 |
|
445 | var applet=_jmolGetApplet(targetSuffix); |
279 | var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName); |
- | |
280 | if ( |
446 | if (!applet)return "ERROR: NO APPLET" |
281 | alert(t); |
- | |
282 |
|
447 | return applet.loadInlineString(model, script, true); |
283 | } |
448 | } |
284 | 449 | ||
285 | function jmolCheckBrowser(action, urlOrMessage, nowOrLater) { |
450 | function jmolCheckBrowser(action, urlOrMessage, nowOrLater) { |
286 | if (typeof action == "string") { |
451 | if (typeof action == "string") { |
287 | action = action.toLowerCase(); |
452 | action = action.toLowerCase(); |
Line 345... | Line 510... | ||
345 | 510 | ||
346 | function jmolSetMenuCssClass(menuCssClass) { |
511 | function jmolSetMenuCssClass(menuCssClass) { |
347 | if (_jmol.hasGetElementById) { |
512 | if (_jmol.hasGetElementById) { |
348 | _jmol.menuCssClass = menuCssClass; |
513 | _jmol.menuCssClass = menuCssClass; |
349 | _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : ""; |
514 | _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : ""; |
350 | } |
515 | } |
351 | } |
516 | } |
352 | 517 | ||
353 | //////////////////////////////////////////////////////////////// |
518 | //////////////////////////////////////////////////////////////// |
354 | // functions for INTERNAL USE ONLY which are subject to change |
519 | // functions for INTERNAL USE ONLY which are subject to change |
355 | // use at your own risk ... you have been WARNED! |
520 | // use at your own risk ... you have been WARNED! |
356 | //////////////////////////////////////////////////////////////// |
521 | //////////////////////////////////////////////////////////////// |
357 | - | ||
358 | var _jmol = { |
522 | var _jmol = { |
- | 523 | currentDocument: document, |
|
359 | 524 | ||
360 | debugAlert: false, |
525 | debugAlert: false, |
361 | bgcolor: "black", |
- | |
362 | progresscolor: "blue", |
- | |
363 | boxbgcolor: "black", |
- | |
364 | boxfgcolor: "white", |
- | |
365 | boxmessage: "Downloading JmolApplet ...", |
- | |
366 | 526 | ||
367 | codebase: " |
527 | codebase: "", |
368 | modelbase: ".", |
528 | modelbase: ".", |
369 | 529 | ||
370 | appletCount: 0, |
530 | appletCount: 0, |
- | 531 | appletSuffixes: [], |
|
- | 532 | appletWindow: null, |
|
371 | 533 | ||
372 | buttonCount: 0, |
534 | buttonCount: 0, |
373 | checkboxCount: 0, |
535 | checkboxCount: 0, |
374 | linkCount: 0, |
536 | linkCount: 0, |
- | 537 | cmdCount: 0, |
|
375 | menuCount: 0, |
538 | menuCount: 0, |
376 | radioCount: 0, |
539 | radioCount: 0, |
377 | radioGroupCount: 0, |
540 | radioGroupCount: 0, |
378 | 541 | ||
379 | appletCssClass: null, |
542 | appletCssClass: null, |
380 | appletCssText: "", |
543 | appletCssText: "", |
381 | buttonCssClass: null, |
544 | buttonCssClass: null, |
382 | buttonCssText: "", |
545 | buttonCssText: "", |
383 | checkboxCssClass: null, |
546 | checkboxCssClass: null, |
384 | checkboxCssText: "", |
547 | checkboxCssText: "", |
385 | radioCssClass: null, |
548 | radioCssClass: null, |
386 | radioCssText: "", |
549 | radioCssText: "", |
387 | linkCssClass: null, |
550 | linkCssClass: null, |
388 | linkCssText: "", |
551 | linkCssText: "", |
389 | menuCssClass: null, |
552 | menuCssClass: null, |
390 | menuCssText: "", |
553 | menuCssText: "", |
391 | 554 | ||
392 | targetSuffix: 0, |
555 | targetSuffix: 0, |
393 | targetText: "", |
556 | targetText: "", |
394 | scripts: [""], |
557 | scripts: [""], |
- | 558 | params: { |
|
- | 559 | syncId: ("" + Math.random()).substring(3), |
|
- | 560 | progressbar: "true", |
|
- | 561 | progresscolor: "blue", |
|
- | 562 | boxbgcolor: "black", |
|
- | 563 | boxfgcolor: "white", |
|
- | 564 | boxmessage: "Downloading JmolApplet ..." |
|
395 | 565 | }, |
|
396 | ua: navigator.userAgent.toLowerCase(), |
566 | ua: navigator.userAgent.toLowerCase(), |
397 | uaVersion: parseFloat(navigator.appVersion), |
567 | uaVersion: parseFloat(navigator.appVersion), |
398 | 568 | ||
399 | os: "unknown", |
569 | os: "unknown", |
400 | browser: "unknown", |
570 | browser: "unknown", |
401 | browserVersion: 0, |
571 | browserVersion: 0, |
402 | hasGetElementById: !!document.getElementById, |
572 | hasGetElementById: !!document.getElementById, |
403 | isJavaEnabled: navigator.javaEnabled(), |
573 | isJavaEnabled: navigator.javaEnabled(), |
404 | isNetscape47Win: false, |
574 | isNetscape47Win: false, |
- | 575 | isIEWin: false, |
|
- | 576 | useIEObject: false, |
|
- | 577 | useHtml4Object: false, |
|
- | 578 | ||
- | 579 | windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93", |
|
- | 580 | windowsCabUrl: |
|
- | 581 | "http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab", |
|
405 | 582 | ||
406 | isBrowserCompliant: false, |
583 | isBrowserCompliant: false, |
407 | isJavaCompliant: false, |
584 | isJavaCompliant: false, |
408 | isFullyCompliant: false, |
585 | isFullyCompliant: false, |
409 | 586 | ||
410 | initialized: false, |
587 | initialized: false, |
411 | initChecked: false, |
588 | initChecked: false, |
412 | 589 | ||
413 | browserChecked: false, |
590 | browserChecked: false, |
414 | checkBrowserAction: "alert", |
591 | checkBrowserAction: "alert", |
415 | checkBrowserUrlOrMessage: null, |
592 | checkBrowserUrlOrMessage: null, |
- | 593 | ||
- | 594 | archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar |
|
416 | 595 | ||
417 | previousOnloadHandler: null, |
596 | previousOnloadHandler: null, |
418 | ready: {} |
597 | ready: {} |
419 | } |
598 | } |
420 | 599 | ||
421 | with (_jmol) { |
600 | with (_jmol) { |
422 | function _jmolTestUA(candidate) { |
601 | function _jmolTestUA(candidate) { |
423 | var ua = _jmol.ua; |
602 | var ua = _jmol.ua; |
424 | var index = ua.indexOf(candidate); |
603 | var index = ua.indexOf(candidate); |
425 | if (index < 0) |
604 | if (index < 0) |
426 | return false; |
605 | return false; |
427 | _jmol.browser = candidate; |
606 | _jmol.browser = candidate; |
428 | _jmol.browserVersion = parseFloat(ua.substring(index |
607 | _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1)); |
429 | return true; |
608 | return true; |
430 | } |
609 | } |
431 | 610 | ||
432 | function _jmolTestOS(candidate) { |
611 | function _jmolTestOS(candidate) { |
433 | if (_jmol.ua.indexOf(candidate) < 0) |
612 | if (_jmol.ua.indexOf(candidate) < 0) |
Line 452... | Line 631... | ||
452 | 631 | ||
453 | isNetscape47Win = (os == "win" && browser == "mozilla" && |
632 | isNetscape47Win = (os == "win" && browser == "mozilla" && |
454 | browserVersion >= 4.78 && browserVersion <= 4.8); |
633 | browserVersion >= 4.78 && browserVersion <= 4.8); |
455 | 634 | ||
456 | if (os == "win") { |
635 | if (os == "win") { |
457 | isBrowserCompliant = hasGetElementById |
636 | isBrowserCompliant = hasGetElementById; |
458 | } else if (os == "mac") { // mac is the problem child :-( |
637 | } else if (os == "mac") { // mac is the problem child :-( |
459 | if (browser == "mozilla" && browserVersion >= 5) { |
638 | if (browser == "mozilla" && browserVersion >= 5) { |
460 | // miguel 2004 11 17 |
639 | // miguel 2004 11 17 |
461 | // checking the plugins array does not work because |
640 | // checking the plugins array does not work because |
462 | // Netscape 7.2 OS X still has Java 1.3.1 listed even though |
641 | // Netscape 7.2 OS X still has Java 1.3.1 listed even though |
Line 467... | Line 646... | ||
467 | } else if (browser == "opera" && browserVersion <= 7.54) { |
646 | } else if (browser == "opera" && browserVersion <= 7.54) { |
468 | isBrowserCompliant = false; |
647 | isBrowserCompliant = false; |
469 | } else { |
648 | } else { |
470 | isBrowserCompliant = hasGetElementById && |
649 | isBrowserCompliant = hasGetElementById && |
471 | !((browser == "msie") || |
650 | !((browser == "msie") || |
472 | (browser == "safari" && browserVersion < 125. |
651 | (browser == "safari" && browserVersion < 125.12)); |
473 | } |
652 | } |
474 | } else if (os == "linux" || os == "unix") { |
653 | } else if (os == "linux" || os == "unix") { |
475 | if (browser == "konqueror" && browserVersion <= 3.3) |
654 | if (browser == "konqueror" && browserVersion <= 3.3) |
476 | isBrowserCompliant = false; |
655 | isBrowserCompliant = false; |
477 | else |
656 | else |
Line 482... | Line 661... | ||
482 | 661 | ||
483 | // possibly more checks in the future for this |
662 | // possibly more checks in the future for this |
484 | isJavaCompliant = isJavaEnabled; |
663 | isJavaCompliant = isJavaEnabled; |
485 | 664 | ||
486 | isFullyCompliant = isBrowserCompliant && isJavaCompliant; |
665 | isFullyCompliant = isBrowserCompliant && isJavaCompliant; |
- | 666 | ||
- | 667 | // IE5.5 works just fine ... but let's push them to Sun Java |
|
- | 668 | isIEWin = (os == "win" && browser == "msie" && browserVersion >= 5.5); |
|
- | 669 | useIEObject = isIEWin; |
|
- | 670 | useHtml4Object = |
|
- | 671 | (os != "mac" && browser == "mozilla" && browserVersion >= 5) || |
|
- | 672 | (os == "win" && browser == "opera" && browserVersion >= 8) || |
|
- | 673 | (os == "mac" && browser == "safari" && browserVersion >= 412.2); |
|
- | 674 | ||
- | 675 | doTranslate = true; |
|
- | 676 | haveSetTranslate = false; |
|
- | 677 | } |
|
- | 678 | ||
- | 679 | ||
- | 680 | function jmolSetCallback(callbackName,funcName) { |
|
- | 681 | _jmol.params[callbackName] = funcName |
|
- | 682 | } |
|
- | 683 | ||
- | 684 | function jmolSetSyncId(n) { |
|
- | 685 | return _jmol.params["syncId"] = n |
|
- | 686 | } |
|
- | 687 | ||
- | 688 | function jmolGetSyncId() { |
|
- | 689 | return _jmol.params["syncId"] |
|
- | 690 | } |
|
- | 691 | ||
- | 692 | function jmolSetLogLevel(n) { |
|
- | 693 | _jmol.params.logLevel = ''+n; |
|
487 | } |
694 | } |
488 | 695 | ||
- | 696 | /* AngelH, mar2007: |
|
- | 697 | By (re)setting these variables in the webpage before calling jmolApplet(), |
|
- | 698 | a custom message can be provided (e.g. localized for user's language) when no Java is installed. |
|
- | 699 | */ |
|
- | 700 | if (noJavaMsg==undefined) var noJavaMsg = |
|
- | 701 | "You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" + |
|
- | 702 | "Check the warning message from your browser and/or enable Java applets in<br />\n" + |
|
- | 703 | "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />"; |
|
- | 704 | if (noJavaMsg2==undefined) var noJavaMsg2 = |
|
- | 705 | "You do not have the<br />\n" + |
|
- | 706 | "Java Runtime Environment<br />\n" + |
|
- | 707 | "installed for applet support.<br />\n" + |
|
- | 708 | "Visit <a href='http://www.java.com'>www.java.com</a>"; |
|
489 | function _jmolApplet(size, inlineModel, script, nameSuffix) { |
709 | function _jmolApplet(size, inlineModel, script, nameSuffix) { |
- | 710 | /* AngelH, mar2007 |
|
- | 711 | Fixed percent / pixel business, to avoid browser errors: |
|
- | 712 | put "px" where needed, avoid where not. |
|
- | 713 | */ |
|
490 | with (_jmol) { |
714 | with (_jmol) { |
491 | if (! nameSuffix) |
715 | if (! nameSuffix) |
492 | nameSuffix = appletCount; |
716 | nameSuffix = appletCount; |
- | 717 | appletSuffixes.push(nameSuffix); |
|
493 | ++appletCount; |
718 | ++appletCount; |
494 | if (! script) |
719 | if (! script) |
495 | script = "select *"; |
720 | script = "select *"; |
496 | var sz = _jmolGetAppletSize(size); |
721 | var sz = _jmolGetAppletSize(size); |
- | 722 | var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' "; |
|
- | 723 | var tHeader, tFooter; |
|
- | 724 | if (!codebase) |
|
- | 725 | jmolInitialize("."); |
|
- | 726 | if (useIEObject || useHtml4Object) { |
|
- | 727 | params.name = 'jmolApplet' + nameSuffix; |
|
- | 728 | params.archive = archivePath; |
|
- | 729 | params.mayscript = 'true'; |
|
- | 730 | params.codebase = codebase; |
|
- | 731 | } |
|
- | 732 | if (useIEObject) { // use MSFT IE6 object tag with .cab file reference |
|
- | 733 | winCodebase = (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : ""); |
|
- | 734 | params.code = 'JmolApplet'; |
|
497 |
|
735 | tHeader = |
- | 736 | "<object name='jmolApplet" + nameSuffix + |
|
- | 737 | "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" + |
|
- | 738 | " classid='" + windowsClassId + "'\n" + winCodebase + widthAndHeight + ">\n"; |
|
- | 739 | tFooter = "</object>"; |
|
- | 740 | } else if (useHtml4Object) { // use HTML4 object tag |
|
- | 741 | tHeader = |
|
- | 742 | "<object name='jmolApplet" + nameSuffix + |
|
498 |
|
743 | "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" + |
- | 744 | " classid='java:JmolApplet'\n" + |
|
- | 745 | " type='application/x-java-applet'\n" + |
|
- | 746 | widthAndHeight + ">\n"; |
|
- | 747 | tFooter = "</object>"; |
|
- | 748 | } else { // use applet tag |
|
- | 749 | tHeader = |
|
- | 750 | "<applet name='jmolApplet" + nameSuffix + |
|
- | 751 | "' id='jmolApplet" + nameSuffix + |
|
499 | "' " + appletCssText + |
752 | "' " + appletCssText + |
500 | " code='JmolApplet' |
753 | " code='JmolApplet'" + |
501 | " codebase='" + codebase + "'\n" + |
754 | " archive='" + archivePath + "' codebase='" + codebase + "'\n" + |
502 |
|
755 | widthAndHeight + |
503 | " |
756 | " mayscript='true'>\n"; |
504 |
|
757 | tFooter = "</applet>"; |
- | 758 | } |
|
- | 759 | var visitJava; |
|
505 |
|
760 | if (isIEWin || useHtml4Object) { |
506 |
|
761 | var szX = "width:" + sz[0] |
507 |
|
762 | if ( szX.indexOf("%")==-1 ) szX+="px" |
508 |
|
763 | var szY = "height:" + sz[1] |
509 |
|
764 | if ( szY.indexOf("%")==-1 ) szY+="px" |
510 |
|
765 | visitJava = |
511 | " |
766 | "<p style='background-color:yellow; color:black; " + |
512 |
|
767 | szX + ";" + szY + ";" + |
513 |
|
768 | // why doesn't this vertical-align work? |
- | 769 | "text-align:center;vertical-align:middle;'>\n" + |
|
- | 770 | noJavaMsg + |
|
- | 771 | "</p>"; |
|
514 | 772 | } else { |
|
515 |
|
773 | visitJava = |
- | 774 | "<table bgcolor='yellow'><tr>" + |
|
516 |
|
775 | "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" + |
517 |
|
776 | noJavaMsg2 + |
- | 777 | "</font></td></tr></table>"; |
|
- | 778 | } |
|
- | 779 | params.loadInline = (inlineModel ? inlineModel : ""); |
|
518 |
|
780 | params.script = (script ? _jmolSterilizeScript(script) : ""); |
519 | t |
781 | var t = tHeader + _jmolParams() + visitJava + tFooter; |
520 | jmolSetTarget(nameSuffix); |
782 | jmolSetTarget(nameSuffix); |
521 | ready["jmolApplet" + nameSuffix] = false; |
783 | ready["jmolApplet" + nameSuffix] = false; |
522 | if (_jmol.debugAlert) |
784 | if (_jmol.debugAlert) |
523 | alert(t); |
785 | alert(t); |
524 |
|
786 | return _jmolDocumentWrite(t); |
525 | } |
787 | } |
- | 788 | } |
|
- | 789 | ||
- | 790 | function _jmolParams() { |
|
- | 791 | var t = ""; |
|
- | 792 | for (i in _jmol.params) |
|
- | 793 | if(_jmol.params[i]!="") |
|
- | 794 | t+=" <param name='"+i+"' value='"+_jmol.params[i]+"' />\n"; |
|
- | 795 | return t |
|
526 | } |
796 | } |
527 | 797 | ||
528 | function _jmolInitCheck() { |
798 | function _jmolInitCheck() { |
529 | if (_jmol.initChecked) |
799 | if (_jmol.initChecked) |
530 | return; |
800 | return; |
531 | _jmol.initChecked = true; |
801 | _jmol.initChecked = true; |
532 | if (_jmol.initialized) |
- | |
533 | return; |
- | |
534 |
|
802 | jmolInitialize(defaultdir, defaultjar) |
535 | " must be called before any other Jmol.js functions"); |
- | |
536 | } |
803 | } |
537 | 804 | ||
538 | function _jmolCheckBrowser() { |
805 | function _jmolCheckBrowser() { |
539 | with (_jmol) { |
806 | with (_jmol) { |
540 | if (browserChecked) |
807 | if (browserChecked) |
Line 550... | Line 817... | ||
550 | _jmolPopup(checkBrowserUrlOrMessage); |
817 | _jmolPopup(checkBrowserUrlOrMessage); |
551 | else { |
818 | else { |
552 | var msg = checkBrowserUrlOrMessage; |
819 | var msg = checkBrowserUrlOrMessage; |
553 | if (msg == null) |
820 | if (msg == null) |
554 | msg = "Your web browser is not fully compatible with Jmol\n\n" + |
821 | msg = "Your web browser is not fully compatible with Jmol\n\n" + |
555 | " |
822 | "browser: " + browser + |
556 | " version: " + browserVersion + |
823 | " version: " + browserVersion + |
557 | " os: " + os + |
824 | " os: " + os + |
558 | "\n\n" + ua; |
825 | "\n\n" + ua; |
559 | alert(msg); |
826 | alert(msg); |
560 | } |
827 | } |
561 | } |
828 | } |
562 | return false; |
829 | return false; |
- | 830 | } |
|
- | 831 | ||
- | 832 | function _jmolDocumentWrite(text) { |
|
- | 833 | if (_jmol.currentDocument) |
|
- | 834 | _jmol.currentDocument.write(text); |
|
- | 835 | return text; |
|
563 | } |
836 | } |
564 | 837 | ||
565 | function _jmolPopup(url) { |
838 | function _jmolPopup(url) { |
566 | var popup = window.open(url, "JmolPopup", |
839 | var popup = window.open(url, "JmolPopup", |
567 | "left=150,top=150,height=400,width=600," + |
840 | "left=150,top=150,height=400,width=600," + |
Line 574... | Line 847... | ||
574 | 847 | ||
575 | function _jmolReadyCallback(name) { |
848 | function _jmolReadyCallback(name) { |
576 | if (_jmol.debugAlert) |
849 | if (_jmol.debugAlert) |
577 | alert(name + " is ready"); |
850 | alert(name + " is ready"); |
578 | _jmol.ready["" + name] = true; |
851 | _jmol.ready["" + name] = true; |
579 | } |
852 | } |
- | 853 | ||
- | 854 | function _jmolSterilizeScript(script) { |
|
- | 855 | var inlineScript = script.replace(/'/g, "'"); |
|
- | 856 | if (_jmol.debugAlert) |
|
- | 857 | alert("script:\n" + inlineScript); |
|
- | 858 | return inlineScript; |
|
- | 859 | } |
|
580 | 860 | ||
581 | function |
861 | function _jmolSterilizeInline(model) { |
- | 862 | var inlineModel = |
|
582 |
|
863 | model.replace(/\r|\n|\r\n/g, "|").replace(/'/g, "'"); |
583 | if (_jmol.debugAlert) |
864 | if (_jmol.debugAlert) |
584 | alert("inline model:\n" + inlineModel); |
865 | alert("inline model:\n" + inlineModel); |
585 | return inlineModel; |
866 | return inlineModel; |
586 | } |
867 | } |
587 | 868 | ||
- | 869 | /* AngelH, mar2007: |
|
- | 870 | By (re)setting this variable in the webpage before calling jmolApplet(), limits for applet size can be overriden. |
|
- | 871 | */ |
|
- | 872 | ||
- | 873 | /* hansonr, jun2007: |
|
- | 874 | 2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html) |
|
- | 875 | */ |
|
- | 876 | ||
- | 877 | if (allowedJmolSize==undefined) var allowedJmolSize = [1, 2048, 300] // min, max, default (pixels) |
|
588 | function _jmolGetAppletSize(size) { |
878 | function _jmolGetAppletSize(size) { |
- | 879 | /* AngelH, mar2007 |
|
- | 880 | Accepts single number or 2-value array, each one can be either: |
|
- | 881 | percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.) |
|
- | 882 | Size is now returned as string or number, no "px". |
|
- | 883 | */ |
|
589 | var width, height; |
884 | var width, height; |
590 | var type = typeof size; |
- | |
591 | if (type == "number") |
- | |
592 | width = height = size; |
- | |
593 |
|
885 | if ( (typeof size) == "object" && size != null ) { |
594 | width = size[0]; height = size[1]; |
886 | width = size[0]; height = size[1]; |
- | 887 | } else { |
|
- | 888 | width = height = size; |
|
- | 889 | } |
|
- | 890 | // if percent, leave it as it is: |
|
- | 891 | if ( width.toString().charAt(width.toString().length-1) != "%" ) { |
|
- | 892 | width = parseFloat(width); // convert to nr., or strip text, or make zero |
|
- | 893 | if ( width <= 1 && width > 0 ) { width = (width*100)+"%" } // decimal: convert to percent and quit |
|
- | 894 | else if ( width >= allowedJmolSize[0] && width <= allowedJmolSize[1] ) { width = parseInt(width) } // accept only that range (pixels) |
|
- | 895 | else { width = allowedJmolSize[2] } // default size 300 pixels |
|
- | 896 | } |
|
- | 897 | if ( height.toString().charAt(height.toString().length-1) != "%" ) { |
|
- | 898 | height = parseFloat(height); |
|
- | 899 | if ( height <= 1 && height > 0 ) { height = (height*100)+"%" } |
|
- | 900 | else if ( height >= allowedJmolSize[0] && height <= allowedJmolSize[1] ) { height = parseInt(height) } |
|
- | 901 | else { height = allowedJmolSize[2] } |
|
595 | } |
902 | } |
596 | if (! (width >= 25 && width <= 2000)) |
- | |
597 | width = 300; |
- | |
598 | if (! (height >= 25 && height <= 2000)) |
- | |
599 | height = 300; |
- | |
600 | return [width, height]; |
903 | return [width, height]; |
601 | } |
904 | } |
602 | 905 | ||
603 | function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName) { |
906 | function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) { |
604 | ++_jmol.radioCount; |
907 | ++_jmol.radioCount; |
605 | if (groupName == undefined || groupName == null) |
908 | if (groupName == undefined || groupName == null) |
606 | groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1); |
909 | groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1); |
607 | if (!script) |
910 | if (!script) |
608 | return ""; |
911 | return ""; |
609 | if (labelHtml == undefined || labelHtml == null) |
912 | if (labelHtml == undefined || labelHtml == null) |
610 | labelHtml = script.substring(0, 32); |
913 | labelHtml = script.substring(0, 32); |
611 | if (! separatorHtml) |
914 | if (! separatorHtml) |
612 | separatorHtml = ""; |
915 | separatorHtml = ""; |
613 | var scriptIndex = _jmolAddScript(script); |
916 | var scriptIndex = _jmolAddScript(script); |
614 |
|
917 | var eospan = "</span>" |
- | 918 | var t = "<span id=\"span_"+id+"\""+(title ? " title =\"" + title + "\"":"")+"><input name='" |
|
615 |
|
919 | + groupName + "' id='"+id+"' type='radio' onClick='_jmolClick(" + |
616 | scriptIndex + _jmol.targetText + |
- | |
617 | ");return true;' onMouseover='_jmolMouseOver(" + |
920 | scriptIndex + _jmol.targetText + ");return true;' onMouseover='_jmolMouseOver(" + |
618 | scriptIndex + |
- | |
619 | ");return true;' onMouseout='_jmolMouseOut()' " + |
921 | scriptIndex + ");return true;' onMouseout='_jmolMouseOut()' " + |
620 | (isChecked ? "checked " : "") + _jmol.radioCssText + "/>" |
922 | (isChecked ? "checked " : "") + _jmol.radioCssText + "/>" |
- | 923 | if (labelHtml.toLowerCase().indexOf("<td>")>=0) { |
|
- | 924 | t += eospan |
|
- | 925 | eospan = ""; |
|
- | 926 | } |
|
621 |
|
927 | t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan + separatorHtml; |
- | 928 | ||
- | 929 | return t; |
|
622 | } |
930 | } |
623 | 931 | ||
624 | function _jmolFindApplet(target) { |
932 | function _jmolFindApplet(target) { |
625 | // first look for the target in the current window |
933 | // first look for the target in the current window |
- | 934 | var applet = _jmolFindAppletInWindow(_jmol.appletWindow != null ? _jmol.appletWindow : window, target); |
|
- | 935 | // THEN look for the target in child frames |
|
- | 936 | if (applet == undefined) |
|
626 |
|
937 | applet = _jmolSearchFrames(window, target); |
- | 938 | // FINALLY look for the target in sibling frames |
|
627 | if (applet == undefined) |
939 | if (applet == undefined) |
628 | applet = _jmolSearchFrames(top, target); // look starting in top frame |
940 | applet = _jmolSearchFrames(top, target); // look starting in top frame |
629 | return applet; |
941 | return applet; |
- | 942 | } |
|
- | 943 | ||
- | 944 | function _jmolGetApplet(targetSuffix){ |
|
- | 945 | var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0"); |
|
- | 946 | var applet = _jmolFindApplet(target); |
|
- | 947 | if (applet) return applet |
|
- | 948 | if(!_jmol.alerted)alert("could not find applet " + target); |
|
- | 949 | _jmol.alerted = true; |
|
- | 950 | return null |
|
630 | } |
951 | } |
631 | 952 | ||
632 | function _jmolSearchFrames(win, target) { |
953 | function _jmolSearchFrames(win, target) { |
633 | var applet; |
954 | var applet; |
634 | var frames = win.frames; |
955 | var frames = win.frames; |
635 | if (frames && frames.length) { // look in all the frames below this window |
956 | if (frames && frames.length) { // look in all the frames below this window |
- | 957 | try{ |
|
636 | for (var i = 0; i < frames.length; ++i) { |
958 | for (var i = 0; i < frames.length; ++i) { |
637 | applet = _jmolSearchFrames(frames[i |
959 | applet = _jmolSearchFrames(frames[i], target); |
638 | if (applet) |
960 | if (applet) |
639 |
|
961 | return applet; |
640 | } |
962 | } |
- | 963 | }catch(e) { |
|
- | 964 | if (_jmol.debugAlert) |
|
- | 965 | alert("Jmol.js _jmolSearchFrames cannot access " + win.name + ".frame[" + i + "] consider using jmolSetAppletWindow()") |
|
- | 966 | } |
|
- | 967 | } |
|
641 |
|
968 | return applet = _jmolFindAppletInWindow(win, target) |
- | 969 | } |
|
- | 970 | ||
- | 971 | function _jmolFindAppletInWindow(win, target) { |
|
642 | var doc = win.document; |
972 | var doc = win.document; |
643 | / |
973 | // getElementById fails on MacOSX Safari & Mozilla |
- | 974 | if (_jmol.useHtml4Object || _jmol.useIEObject) |
|
- | 975 | return doc.getElementById(target); |
|
644 | if (doc.applets) |
976 | else if (doc.applets) |
645 |
|
977 | return doc.applets[target]; |
646 | else |
978 | else |
647 |
|
979 | return doc[target]; |
648 | } |
- | |
649 | return applet; |
- | |
650 | } |
980 | } |
651 | 981 | ||
652 | function _jmolAddScript(script) { |
982 | function _jmolAddScript(script) { |
653 | if (! script) |
983 | if (! script) |
654 | return 0; |
984 | return 0; |
655 | var index = _jmol.scripts.length; |
985 | var index = _jmol.scripts.length; |
656 | _jmol.scripts[index] = script; |
986 | _jmol.scripts[index] = script; |
657 | return index; |
987 | return index; |
658 | } |
988 | } |
659 | 989 | ||
660 | function _jmolClick(scriptIndex, targetSuffix) { |
990 | function _jmolClick(scriptIndex, targetSuffix, elementClicked) { |
- | 991 | _jmol.element = elementClicked; |
|
661 | jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
992 | jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
662 | } |
993 | } |
663 | 994 | ||
664 | function _jmolMenuSelected(menuObject, targetSuffix) { |
995 | function _jmolMenuSelected(menuObject, targetSuffix) { |
665 | var scriptIndex = menuObject.value; |
996 | var scriptIndex = menuObject.value; |
666 | if (scriptIndex != undefined) { |
997 | if (scriptIndex != undefined) { |
667 | jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
998 | jmolScript(_jmol.scripts[scriptIndex], targetSuffix); |
668 | return; |
999 | return; |
669 | } |
1000 | } |
670 | var |
1001 | var len = menuObject.length; |
671 | if (typeof |
1002 | if (typeof len == "number") { |
672 | for (var i = 0; i < |
1003 | for (var i = 0; i < len; ++i) { |
673 | if (menuObject[i].selected) { |
1004 | if (menuObject[i].selected) { |
674 | _jmolClick(menuObject[i].value, targetSuffix); |
1005 | _jmolClick(menuObject[i].value, targetSuffix); |
675 | return; |
1006 | return; |
676 | } |
1007 | } |
677 | } |
1008 | } |
678 | } |
1009 | } |
679 | alert("?Que? menu selected bug #8734"); |
1010 | alert("?Que? menu selected bug #8734"); |
- | 1011 | } |
|
- | 1012 | ||
- | 1013 | ||
- | 1014 | _jmol.checkboxMasters = {}; |
|
- | 1015 | _jmol.checkboxItems = {}; |
|
- | 1016 | ||
- | 1017 | function jmolSetCheckboxGroup(chkMaster,chkBox) { |
|
- | 1018 | var id = chkMaster; |
|
- | 1019 | if(typeof(id)=="number")id = "jmolCheckbox" + id; |
|
- | 1020 | chkMaster = document.getElementById(id); |
|
- | 1021 | if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id); |
|
- | 1022 | var m = _jmol.checkboxMasters[id] = {}; |
|
- | 1023 | m.chkMaster = chkMaster; |
|
- | 1024 | m.chkGroup = {}; |
|
- | 1025 | for (var i = 1; i < arguments.length; i++){ |
|
- | 1026 | var id = arguments[i]; |
|
- | 1027 | if(typeof(id)=="number")id = "jmolCheckbox" + id; |
|
- | 1028 | checkboxItem = document.getElementById(id); |
|
- | 1029 | if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id); |
|
- | 1030 | m.chkGroup[id] = checkboxItem; |
|
- | 1031 | _jmol.checkboxItems[id] = m; |
|
- | 1032 | } |
|
- | 1033 | } |
|
- | 1034 | ||
- | 1035 | function _jmolNotifyMaster(m){ |
|
- | 1036 | //called when a group item is checked |
|
- | 1037 | var allOn = true; |
|
- | 1038 | var allOff = true; |
|
- | 1039 | for (var chkBox in m.chkGroup){ |
|
- | 1040 | if(m.chkGroup[chkBox].checked) |
|
- | 1041 | allOff = false; |
|
- | 1042 | else |
|
- | 1043 | allOn = false; |
|
- | 1044 | } |
|
- | 1045 | if (allOn)m.chkMaster.checked = true; |
|
- | 1046 | if (allOff)m.chkMaster.checked = false; |
|
- | 1047 | if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id]) |
|
- | 1048 | _jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id]) |
|
- | 1049 | } |
|
- | 1050 | ||
- | 1051 | function _jmolNotifyGroup(m, isOn){ |
|
- | 1052 | //called when a master item is checked |
|
- | 1053 | for (var chkBox in m.chkGroup){ |
|
- | 1054 | var item = m.chkGroup[chkBox] |
|
- | 1055 | item.checked = isOn; |
|
- | 1056 | if (_jmol.checkboxMasters[item.id]) |
|
- | 1057 | _jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn) |
|
- | 1058 | } |
|
680 | } |
1059 | } |
681 | 1060 | ||
682 | function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) { |
1061 | function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) { |
- | 1062 | _jmol.control = ckbox |
|
683 | _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix); |
1063 | _jmolClick(ckbox.checked ? whenChecked : whenUnchecked, targetSuffix); |
- | 1064 | if(_jmol.checkboxMasters[ckbox.id]) |
|
- | 1065 | _jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked) |
|
- | 1066 | if(_jmol.checkboxItems[ckbox.id]) |
|
- | 1067 | _jmolNotifyMaster(_jmol.checkboxItems[ckbox.id]) |
|
684 | } |
1068 | } |
685 | 1069 | ||
686 | function _jmolCbOver(ckbox, whenChecked, whenUnchecked) { |
1070 | function _jmolCbOver(ckbox, whenChecked, whenUnchecked) { |
687 | window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked]; |
1071 | window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked]; |
688 | } |
1072 | } |
689 | 1073 | ||
690 | function _jmolMouseOver(scriptIndex) { |
1074 | function _jmolMouseOver(scriptIndex) { |
691 | window.status = _jmol.scripts[scriptIndex]; |
1075 | window.status = _jmol.scripts[scriptIndex]; |
692 | } |
1076 | } |
693 | 1077 | ||
694 | function _jmolMouseOut() { |
1078 | function _jmolMouseOut() { |
695 | window.status = " "; |
1079 | window.status = " "; |
696 | return true; |
1080 | return true; |
697 | } |
1081 | } |
698 | 1082 | ||
Line 701... | Line 1085... | ||
701 | if (_jmol.debugAlert) |
1085 | if (_jmol.debugAlert) |
702 | alert("jmolCodebase=" + _jmol.codebase); |
1086 | alert("jmolCodebase=" + _jmol.codebase); |
703 | } |
1087 | } |
704 | 1088 | ||
705 | function _jmolOnloadResetForms() { |
1089 | function _jmolOnloadResetForms() { |
- | 1090 | // must be evaluated ONLY once |
|
706 | _jmol.previousOnloadHandler = window.onload; |
1091 | _jmol.previousOnloadHandler = window.onload; |
707 | window.onload = |
1092 | window.onload = |
708 | function() { |
1093 | function() { |
709 | // alert("onloadResetForms"); |
- | |
710 | with (_jmol) { |
1094 | with (_jmol) { |
711 | if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) { |
1095 | if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) { |
712 | var forms = document.forms; |
1096 | var forms = document.forms; |
713 | if (!forms || forms.length == 0) { |
- | |
714 | alert("<form> tags seem to be missing\n" + |
- | |
715 | "Jmol/HTML input controls must be contained " + |
- | |
716 | "within form tags" |
- | |
717 | // + "\n\n" + forms + " forms.length=" + forms.length + |
- | |
718 | // " typeof=" + (typeof forms) |
- | |
719 | ); |
- | |
720 | } else { |
- | |
721 |
|
1097 | for (var i = forms.length; --i >= 0; ) |
722 |
|
1098 | forms[i].reset(); |
723 | } |
- | |
724 | } |
1099 | } |
725 | if (previousOnloadHandler) |
1100 | if (previousOnloadHandler) |
726 | previousOnloadHandler(); |
1101 | previousOnloadHandler(); |
727 | } |
1102 | } |
728 | } |
1103 | } |
- | 1104 | } |
|
- | 1105 | ||
- | 1106 | //////////////////////////////////// |
|
- | 1107 | /////extensions for getProperty///// |
|
- | 1108 | //////////////////////////////////// |
|
- | 1109 | ||
- | 1110 | ||
- | 1111 | function _jmolEvalJSON(s,key){ |
|
- | 1112 | s=s+"" |
|
- | 1113 | if(!s)return [] |
|
- | 1114 | if(s.charAt(0)!="{"){ |
|
- | 1115 | if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n") |
|
- | 1116 | return s |
|
- | 1117 | } |
|
- | 1118 | var A = eval("("+s+")") |
|
- | 1119 | if(!A)return |
|
- | 1120 | if(key && A[key])A=A[key] |
|
- | 1121 | return A |
|
- | 1122 | } |
|
- | 1123 | ||
- | 1124 | function _jmolEnumerateObject(A,key){ |
|
- | 1125 | var sout="" |
|
- | 1126 | if(typeof(A) == "string" && A!="null"){ |
|
- | 1127 | sout+="\n"+key+"=\""+A+"\"" |
|
- | 1128 | }else if(!isNaN(A)||A==null){ |
|
- | 1129 | sout+="\n"+key+"="+(A+""==""?"null":A) |
|
- | 1130 | }else if(A.length){ |
|
- | 1131 | sout+=key+"=[]" |
|
- | 1132 | for(var i=0;i<A.length;i++){ |
|
- | 1133 | sout+="\n" |
|
- | 1134 | if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){ |
|
- | 1135 | sout+=_jmolEnumerateObject(A[i],key+"["+i+"]") |
|
- | 1136 | }else{ |
|
- | 1137 | sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i]) |
|
- | 1138 | } |
|
- | 1139 | } |
|
- | 1140 | }else{ |
|
- | 1141 | if(key != ""){ |
|
- | 1142 | sout+=key+"={}" |
|
- | 1143 | key+="." |
|
- | 1144 | } |
|
- | 1145 | ||
- | 1146 | for(var i in A){ |
|
- | 1147 | sout+="\n" |
|
- | 1148 | if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){ |
|
- | 1149 | sout+=_jmolEnumerateObject(A[i],key+i) |
|
- | 1150 | }else{ |
|
- | 1151 | sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i]) |
|
- | 1152 | } |
|
- | 1153 | } |
|
- | 1154 | } |
|
- | 1155 | return sout |
|
- | 1156 | } |
|
- | 1157 | ||
- | 1158 | ||
- | 1159 | function _jmolSortKey0(a,b){ |
|
- | 1160 | return (a[0]<b[0]?1:a[0]>b[0]?-1:0) |
|
- | 1161 | } |
|
- | 1162 | ||
- | 1163 | function _jmolSortMessages(A){ |
|
- | 1164 | if(!A || typeof(A)!="object")return [] |
|
- | 1165 | var B = [] |
|
- | 1166 | for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j] |
|
- | 1167 | if(B.length == 0) return |
|
- | 1168 | B=B.sort(_jmolSortKey0) |
|
- | 1169 | return B |
|
- | 1170 | } |
|
- | 1171 | ||
- | 1172 | /////////additional extensions ////////// |
|
- | 1173 | ||
- | 1174 | ||
- | 1175 | function _jmolDomScriptLoad(URL){ |
|
- | 1176 | //open(URL) //to debug |
|
- | 1177 | _jmol.servercall=URL |
|
- | 1178 | var node = document.getElementById("_jmolScriptNode") |
|
- | 1179 | if (node && _jmol.browser!="msie"){ |
|
- | 1180 | document.getElementsByTagName("HEAD")[0].removeChild(node) |
|
- | 1181 | node=null |
|
- | 1182 | } |
|
- | 1183 | if (node) { |
|
- | 1184 | node.setAttribute("src",URL) |
|
- | 1185 | } else { |
|
- | 1186 | node=document.createElement("script") |
|
- | 1187 | node.setAttribute("id","_jmolScriptNode") |
|
- | 1188 | node.setAttribute("type","text/javascript") |
|
- | 1189 | node.setAttribute("src",URL) |
|
- | 1190 | document.getElementsByTagName("HEAD")[0].appendChild(node) |
|
- | 1191 | } |
|
- | 1192 | } |
|
- | 1193 | ||
- | 1194 | ||
- | 1195 | function _jmolExtractPostData(url){ |
|
- | 1196 | S=url.split("&POST:") |
|
- | 1197 | var s="" |
|
- | 1198 | for(var i=1;i<S.length;i++){ |
|
- | 1199 | KV=S[i].split("=") |
|
- | 1200 | s+="&POSTKEY"+i+"="+KV[0] |
|
- | 1201 | s+="&POSTVALUE"+i+"="+KV[1] |
|
- | 1202 | } |
|
- | 1203 | return "&url="+escape(S[0])+s |
|
- | 1204 | } |
|
- | 1205 | ||
- | 1206 | function _jmolLoadModel(targetSuffix,remoteURL,array,isError,errorMessage){ |
|
- | 1207 | //called by server, but in client |
|
- | 1208 | //overload this function to customize return |
|
- | 1209 | _jmol.remoteURL=remoteURL |
|
- | 1210 | if(isError)alert(errorMessage) |
|
- | 1211 | jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix) |
|
- | 1212 | } |
|
- | 1213 | ||
- | 1214 | //////////user property/status functions///////// |
|
- | 1215 | ||
- | 1216 | function jmolGetStatus(strStatus,targetSuffix){ |
|
- | 1217 | return _jmolSortMessages(jmolGetPropertyAsArray("jmolStatus",strStatus,targetSuffix)) |
|
- | 1218 | } |
|
- | 1219 | ||
- | 1220 | function jmolGetPropertyAsArray(sKey,sValue,targetSuffix) { |
|
- | 1221 | return _jmolEvalJSON(jmolGetPropertyAsJSON(sKey,sValue,targetSuffix),sKey) |
|
- | 1222 | } |
|
- | 1223 | ||
- | 1224 | function jmolGetPropertyAsString(sKey,sValue,targetSuffix) { |
|
- | 1225 | var applet = _jmolGetApplet(targetSuffix); |
|
- | 1226 | if(!sValue)sValue="" |
|
- | 1227 | return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "") |
|
- | 1228 | } |
|
- | 1229 | ||
- | 1230 | function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) { |
|
- | 1231 | if(!sValue)sValue = "" |
|
- | 1232 | var applet = _jmolGetApplet(targetSuffix); |
|
- | 1233 | try { |
|
- | 1234 | return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "") |
|
- | 1235 | } catch(e) { |
|
- | 1236 | return "" |
|
- | 1237 | } |
|
- | 1238 | } |
|
- | 1239 | ||
- | 1240 | function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) { |
|
- | 1241 | if(!sValue)sValue = "" |
|
- | 1242 | var applet = _jmolGetApplet(targetSuffix); |
|
- | 1243 | return (applet ? applet.getProperty(sKey,sValue) : null) |
|
- | 1244 | } |
|
- | 1245 | ||
- | 1246 | ||
- | 1247 | function jmolDecodeJSON(s) { |
|
- | 1248 | return _jmolEnumerateObject(_jmolEvalJSON(s),"") |
|
- | 1249 | } |
|
- | 1250 | ||
- | 1251 | ||
- | 1252 | ///////// synchronous scripting //////// |
|
- | 1253 | ||
- | 1254 | function jmolScriptWait(script, targetSuffix) { |
|
- | 1255 | if(!targetSuffix)targetSuffix="0" |
|
- | 1256 | var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
|
- | 1257 | var s = "" |
|
- | 1258 | for(var i=Ret.length;--i>=0;) |
|
- | 1259 | for(var j=0;j< Ret[i].length;j++) |
|
- | 1260 | s+=Ret[i][j]+"\n" |
|
- | 1261 | return s |
|
- | 1262 | } |
|
- | 1263 | ||
- | 1264 | function jmolScriptWaitOutput(script, targetSuffix) { |
|
- | 1265 | if(!targetSuffix)targetSuffix="0" |
|
- | 1266 | var ret = "" |
|
- | 1267 | try{ |
|
- | 1268 | if (script) { |
|
- | 1269 | _jmolCheckBrowser(); |
|
- | 1270 | var applet=_jmolGetApplet(targetSuffix); |
|
- | 1271 | if (applet) ret += applet.scriptWaitOutput(script); |
|
- | 1272 | } |
|
- | 1273 | }catch(e){ |
|
- | 1274 | } |
|
- | 1275 | return ret; |
|
- | 1276 | } |
|
- | 1277 | ||
- | 1278 | function jmolEvaluate(molecularMath, targetSuffix) { |
|
- | 1279 | ||
- | 1280 | //carries out molecular math on a model |
|
- | 1281 | ||
- | 1282 | if(!targetSuffix)targetSuffix="0" |
|
- | 1283 | var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix); |
|
- | 1284 | var s = result.replace(/\-*\d+/,"") |
|
- | 1285 | if (s == "" && !isNaN(parseInt(result)))return parseInt(result); |
|
- | 1286 | var s = result.replace(/\-*\d*\.\d*/,"") |
|
- | 1287 | if (s == "" && !isNaN(parseFloat(result)))return parseFloat(result); |
|
- | 1288 | return result; |
|
- | 1289 | } |
|
- | 1290 | ||
- | 1291 | function jmolScriptEcho(script, targetSuffix) { |
|
- | 1292 | // returns a newline-separated list of all echos from a script |
|
- | 1293 | if(!targetSuffix)targetSuffix="0" |
|
- | 1294 | var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
|
- | 1295 | var s = "" |
|
- | 1296 | for(var i=Ret.length;--i>=0;) |
|
- | 1297 | for(var j=Ret[i].length;--j>=0;) |
|
- | 1298 | if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n" |
|
- | 1299 | return s.replace(/ \| /g, "\n") |
|
- | 1300 | } |
|
- | 1301 | ||
- | 1302 | ||
- | 1303 | function jmolScriptMessage(script, targetSuffix) { |
|
- | 1304 | // returns a newline-separated list of all messages from a script, ending with "script completed\n" |
|
- | 1305 | if(!targetSuffix)targetSuffix="0" |
|
- | 1306 | var Ret=jmolScriptWaitAsArray(script, targetSuffix) |
|
- | 1307 | var s = "" |
|
- | 1308 | for(var i=Ret.length;--i>=0;) |
|
- | 1309 | for(var j=Ret[i].length;--j>=0;) |
|
- | 1310 | if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n" |
|
- | 1311 | return s.replace(/ \| /g, "\n") |
|
- | 1312 | } |
|
- | 1313 | ||
- | 1314 | ||
- | 1315 | function jmolScriptWaitAsArray(script, targetSuffix) { |
|
- | 1316 | var ret = "" |
|
- | 1317 | try{ |
|
- | 1318 | jmolGetStatus("scriptEcho,scriptMessage,scriptStatus,scriptError",targetSuffix) |
|
- | 1319 | if (script) { |
|
- | 1320 | _jmolCheckBrowser(); |
|
- | 1321 | var applet=_jmolGetApplet(targetSuffix); |
|
- | 1322 | if (applet) ret += applet.scriptWait(script); |
|
- | 1323 | ret = _jmolEvalJSON(ret,"jmolStatus") |
|
- | 1324 | if(typeof ret == "object") |
|
- | 1325 | return ret |
|
- | 1326 | } |
|
- | 1327 | }catch(e){ |
|
- | 1328 | } |
|
- | 1329 | return [[ret]] |
|
- | 1330 | } |
|
- | 1331 | ||
- | 1332 | ||
- | 1333 | ||
- | 1334 | //////////// save/restore orientation ///////////// |
|
- | 1335 | ||
- | 1336 | function jmolSaveOrientation(id, targetSuffix) { |
|
- | 1337 | if(!targetSuffix)targetSuffix="0" |
|
- | 1338 | return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo |
|
- | 1339 | } |
|
- | 1340 | ||
- | 1341 | function jmolRestoreOrientation(id, targetSuffix) { |
|
- | 1342 | if(!targetSuffix)targetSuffix="0" |
|
- | 1343 | var s=_jmol["savedOrientation"+id] |
|
- | 1344 | if (!s || s == "")return |
|
- | 1345 | s=s.replace(/1\.0/,"0") |
|
- | 1346 | return jmolScriptWait(s,targetSuffix) |
|
- | 1347 | } |
|
- | 1348 | ||
- | 1349 | function jmolRestoreOrientationDelayed(id, delay, targetSuffix) { |
|
- | 1350 | if(arguments.length < 2)delay=1; |
|
- | 1351 | if(!targetSuffix)targetSuffix="0" |
|
- | 1352 | var s=_jmol["savedOrientation"+id] |
|
- | 1353 | if (!s || s == "")return |
|
- | 1354 | s=s.replace(/1\.0/,delay) |
|
- | 1355 | return jmolScriptWait(s,targetSuffix) |
|
- | 1356 | } |
|
- | 1357 | ||
- | 1358 | //////////// add parameter ///////////// |
|
- | 1359 | /* |
|
- | 1360 | * for adding callbacks or other parameters. Use: |
|
- | 1361 | ||
- | 1362 | jmolSetDocument(0) |
|
- | 1363 | var s= jmolApplet(....) |
|
- | 1364 | s = jmolAppletAddParam(s,"messageCallback", "myFunctionName") |
|
- | 1365 | document.write(s) |
|
- | 1366 | jmolSetDocument(document) // if you want to then write buttons and such normally |
|
- | 1367 | |
|
- | 1368 | */ |
|
- | 1369 | ||
- | 1370 | function jmolAppletAddParam(appletCode,name,value){ |
|
- | 1371 | if(value == "")return appletCode |
|
- | 1372 | return appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param") |
|
- | 1373 | } |
|
- | 1374 | ||
- | 1375 | ///////////////auto load Research Consortium for Structural Biology (RCSB) data /////////// |
|
- | 1376 | ||
- | 1377 | function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){ |
|
- | 1378 | ||
- | 1379 | if(!_jmol.thismodel)_jmol.thismodel = "1crn" |
|
- | 1380 | if(!_jmol.serverURL)_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm" |
|
- | 1381 | if(!_jmol.RCSBserver)_jmol.RCSBserver="http://www.rcsb.org" |
|
- | 1382 | if(!_jmol.defaultURL_RCSB)_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF" |
|
- | 1383 | if(!fileformat)fileformat="PDB" |
|
- | 1384 | if(!pdbid)pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel) |
|
- | 1385 | if(!pdbid || pdbid.length != 4)return "" |
|
- | 1386 | if(!targetSuffix)targetSuffix="0" |
|
- | 1387 | if(!optionalscript)optionalscript="" |
|
- | 1388 | var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase()) |
|
- | 1389 | if(fileformat!="CIF")url=url.replace(/CIF/,fileformat) |
|
- | 1390 | _jmol.optionalscript=optionalscript |
|
- | 1391 | _jmol.thismodel=pdbid |
|
- | 1392 | _jmol.thistargetsuffix=targetSuffix |
|
- | 1393 | _jmol.thisurl=url |
|
- | 1394 | _jmol.modelArray = [] |
|
- | 1395 | url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) |
|
- | 1396 | _jmolDomScriptLoad(url) |
|
- | 1397 | return url |
|
- | 1398 | } |
|
- | 1399 | ||
- | 1400 | /////////////// St. Olaf College AJAX server -- ANY URL /////////// |
|
- | 1401 | ||
- | 1402 | function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){ |
|
- | 1403 | _jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm" |
|
- | 1404 | if(!_jmol.thisurlANY)_jmol.thisurlANY = "http://www.stolaf.edu/depts/chemistry/mo/struc/data/ycp3-1.mol" |
|
- | 1405 | if(!url)url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY) |
|
- | 1406 | if(!userid)userid="0" |
|
- | 1407 | if(!targetSuffix)targetSuffix="0" |
|
- | 1408 | if(!optionalscript)optionalscript="" |
|
- | 1409 | _jmol.optionalscript=optionalscript |
|
- | 1410 | _jmol.thistargetsuffix=targetSuffix |
|
- | 1411 | _jmol.modelArray = [] |
|
- | 1412 | _jmol.thisurl = url |
|
- | 1413 | url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url) |
|
- | 1414 | _jmolDomScriptLoad(url) |
|
- | 1415 | } |
|
- | 1416 | ||
- | 1417 | ||
- | 1418 | /////////////// Mineralogical Society of America (MSA) data ///////// |
|
- | 1419 | ||
- | 1420 | function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){ |
|
- | 1421 | ||
- | 1422 | if(!_jmol.thiskeyMSA)_jmol.thiskeyMSA = "mineral" |
|
- | 1423 | if(!_jmol.thismodelMSA)_jmol.thismodelMSA = "quartz" |
|
- | 1424 | if(!_jmol.ajaxURL_MSA)_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs" |
|
- | 1425 | if(!key)key=prompt("Enter a field:", _jmol.thiskeyMSA) |
|
- | 1426 | if(!key)return "" |
|
- | 1427 | if(!value)value=prompt("Enter a "+key+":", _jmol.thismodelMSA) |
|
- | 1428 | if(!value)return "" |
|
- | 1429 | if(!targetSuffix)targetSuffix="0" |
|
- | 1430 | if(!optionalscript)optionalscript="" |
|
- | 1431 | if(optionalscript == 1)optionalscript='load "" {1 1 1}' |
|
- | 1432 | var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value) |
|
- | 1433 | _jmol.optionalscript=optionalscript |
|
- | 1434 | _jmol.thiskeyMSA=key |
|
- | 1435 | _jmol.thismodelMSA=value |
|
- | 1436 | _jmol.thistargetsuffix=targetSuffix |
|
- | 1437 | _jmol.thisurl=url |
|
- | 1438 | _jmol.modelArray = [] |
|
- | 1439 | loadModel=_jmolLoadModel |
|
- | 1440 | _jmolDomScriptLoad(url) |
|
- | 1441 | return url |
|
- | 1442 | } |
|
- | 1443 | ||
- | 1444 | ||
- | 1445 | ||
- | 1446 | function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){ |
|
- | 1447 | if(!userid)userid="0" |
|
- | 1448 | if(!targetSuffix)targetSuffix="0" |
|
- | 1449 | if(!optionalscript)optionalscript="" |
|
- | 1450 | _jmol.optionalscript=optionalscript |
|
- | 1451 | _jmol.thismodel=userid |
|
- | 1452 | _jmol.thistargetsuffix=targetSuffix |
|
- | 1453 | _jmol.modelArray = [] |
|
- | 1454 | _jmol.thisurl = url |
|
- | 1455 | url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix |
|
- | 1456 | _jmolDomScriptLoad(url) |
|
- | 1457 | } |
|
- | 1458 | ||
- | 1459 | ||
- | 1460 | //// in case Jmol library has already been loaded: |
|
- | 1461 | ||
- | 1462 | }catch(e){} |
|
- | 1463 | ||
- | 1464 | ///////////////moving atoms ////////////// |
|
- | 1465 | ||
- | 1466 | // HIGHLY experimental!! |
|
- | 1467 | ||
- | 1468 | function jmolSetAtomCoord(i,x,y,z,targetSuffix){ |
|
- | 1469 | _jmolCheckBrowser(); |
|
- | 1470 | var applet=_jmolGetApplet(targetSuffix); |
|
- | 1471 | if (applet) applet.getProperty('jmolViewer').setAtomCoord(i,x,y,z) |
|
- | 1472 | } |
|
- | 1473 | ||
- | 1474 | function jmolSetAtomCoordRelative(i,x,y,z,targetSuffix){ |
|
- | 1475 | _jmolCheckBrowser(); |
|
- | 1476 | var applet=_jmolGetApplet(targetSuffix); |
|
- | 1477 | if (applet) applet.getProperty('jmolViewer').setAtomCoordRelative(i,x,y,z) |
|
- | 1478 | } |
|
- | 1479 | ||
- | 1480 | ||
- | 1481 | ///////////////applet fake for testing buttons///////////// |
|
- | 1482 | ||
- | 1483 | ||
- | 1484 | if(document.location.search.indexOf("NOAPPLET")>=0){ |
|
- | 1485 | jmolApplet = function(w){ |
|
- | 1486 | var s="<table style='background-color:black' width="+w+"><tr height="+w+">" |
|
- | 1487 | +"<td align=center valign=center style='background-color:white'>" |
|
- | 1488 | +"Applet would be here" |
|
- | 1489 | +"<p><textarea id=fakeApplet rows=5 cols=50></textarea>" |
|
- | 1490 | +"</td></tr></table>" |
|
- | 1491 | return _jmolDocumentWrite(s) |
|
- | 1492 | } |
|
- | 1493 | ||
- | 1494 | _jmolFindApplet = function(){return jmolApplet0} |
|
- | 1495 | ||
- | 1496 | jmolApplet0 = { |
|
- | 1497 | script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script} |
|
- | 1498 | ,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\n"+script} |
|
- | 1499 | ,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script} |
|
- | 1500 | } |
|
- | 1501 | } |
|
- | 1502 | ||
- | 1503 | ||
- | 1504 | /////////////////////////////////////////// |
|
- | 1505 | ||
- | 1506 | //new 9:49 AM 3/6/2007: |
|
- | 1507 | ||
- | 1508 | //both w and h are optional. |
|
- | 1509 | //if either is between 0 and 1, then it is taken as percent/100. |
|
- | 1510 | //if either is greater than 1, then it is taken as a size. |
|
- | 1511 | function jmolResize(w,h) { |
|
- | 1512 | _jmol.alerted = true; |
|
- | 1513 | var percentW = (!w ? 100 : w <= 1 && w > 0 ? w * 100 : 0) |
|
- | 1514 | var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0) |
|
- | 1515 | if (_jmol.browser=="msie") { |
|
- | 1516 | var width=document.body.clientWidth; |
|
- | 1517 | var height=document.body.clientHeight; |
|
- | 1518 | } else { |
|
- | 1519 | var netscapeScrollWidth=15; |
|
- | 1520 | var width=window.innerWidth - netscapeScrollWidth; |
|
- | 1521 | var height=window.innerHeight-netscapeScrollWidth; |
|
- | 1522 | } |
|
- | 1523 | var applet = _jmolGetApplet(0); |
|
- | 1524 | if(!applet)return; |
|
- | 1525 | applet.style.width = (percentW ? width * percentW/100 : w)+"px" |
|
- | 1526 | applet.style.height = (percentH ? height * percentH/100 : h)+"px" |
|
- | 1527 | title=width + " " + height + " " + (new Date()) |
|
729 | } |
1528 | } |
730 | 1529 |