rbbt-views 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/lib/rbbt/workflow/rest.rb +142 -57
  2. data/lib/rbbt/workflow/rest/auth.rb +3 -2
  3. data/lib/rbbt/workflow/rest/client.rb +4 -1
  4. data/lib/rbbt/workflow/rest/email.rb +23 -0
  5. data/lib/rbbt/workflow/rest/entity.rb +87 -62
  6. data/lib/rbbt/workflow/rest/helpers.rb +38 -0
  7. data/lib/rbbt/workflow/rest/render.rb +532 -153
  8. data/lib/rbbt/workflow/rest/util.rb +81 -104
  9. data/share/views/compass/_base.sass +0 -3
  10. data/share/views/compass/app.sass +0 -103
  11. data/share/views/compass/compass.config +5 -5
  12. data/share/views/compass/layout.sass +133 -0
  13. data/share/views/compass/main.sass +28 -5
  14. data/share/views/entity/GOTerm.haml +15 -0
  15. data/share/views/entity/Gene.haml +7 -0
  16. data/share/views/entity/GenomicMutation.haml +10 -0
  17. data/share/views/entity/KeggPathway.haml +13 -0
  18. data/share/views/entity/MutatedIsoform.haml +43 -0
  19. data/share/views/entity/NCIBioCartaPathways.haml +9 -0
  20. data/share/views/entity/NCINaturePathways.haml +9 -0
  21. data/share/views/entity/NCIReactomePathways.haml +9 -0
  22. data/share/views/entity/PfamDomain.haml +1 -0
  23. data/share/views/entity_list/Default.haml +10 -0
  24. data/share/views/form.haml +2 -54
  25. data/share/views/front.haml +1 -0
  26. data/share/views/job_list.haml +1 -1
  27. data/share/views/js/app.js +122 -68
  28. data/share/views/layout.haml +28 -22
  29. data/share/views/partials/_form.haml +36 -0
  30. data/share/views/partials/_job_control.haml +8 -8
  31. data/share/views/partials/_result_table.haml +12 -40
  32. data/share/views/partials/_result_table_controls.haml +36 -28
  33. data/share/views/partials/_table.haml +39 -0
  34. data/share/views/public/favicon.gif +0 -0
  35. data/share/views/public/plugins/jmol/CHANGES.txt +11124 -0
  36. data/share/views/public/plugins/jmol/COPYRIGHT.txt +73 -0
  37. data/share/views/public/plugins/jmol/ChimeToJmol.jar +0 -0
  38. data/share/views/public/plugins/jmol/Jmol.jar +0 -0
  39. data/share/views/public/plugins/jmol/Jmol.js +1711 -0
  40. data/share/views/public/plugins/jmol/JmolApplet.jar +0 -0
  41. data/share/views/public/plugins/jmol/JmolApplet0.jar +0 -0
  42. data/share/views/public/plugins/jmol/JmolApplet0_Console.jar +0 -0
  43. data/share/views/public/plugins/jmol/JmolApplet0_Minimize.jar +0 -0
  44. data/share/views/public/plugins/jmol/JmolApplet0_Popup.jar +0 -0
  45. data/share/views/public/plugins/jmol/JmolApplet0_ReadersCifPdb.jar +0 -0
  46. data/share/views/public/plugins/jmol/JmolApplet0_ReadersMolXyz.jar +0 -0
  47. data/share/views/public/plugins/jmol/JmolApplet0_ReadersMore.jar +0 -0
  48. data/share/views/public/plugins/jmol/JmolApplet0_ReadersQuantum.jar +0 -0
  49. data/share/views/public/plugins/jmol/JmolApplet0_ReadersSimple.jar +0 -0
  50. data/share/views/public/plugins/jmol/JmolApplet0_ReadersXml.jar +0 -0
  51. data/share/views/public/plugins/jmol/JmolApplet0_ReadersXtal.jar +0 -0
  52. data/share/views/public/plugins/jmol/JmolApplet0_ShapeBio.jar +0 -0
  53. data/share/views/public/plugins/jmol/JmolApplet0_ShapeSpecial.jar +0 -0
  54. data/share/views/public/plugins/jmol/JmolApplet0_ShapeSurface.jar +0 -0
  55. data/share/views/public/plugins/jmol/JmolApplet0_Smiles.jar +0 -0
  56. data/share/views/public/plugins/jmol/JmolApplet0_Symmetry.jar +0 -0
  57. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ar.jar +0 -0
  58. data/share/views/public/plugins/jmol/JmolApplet0_i18n_bs.jar +0 -0
  59. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ca.jar +0 -0
  60. data/share/views/public/plugins/jmol/JmolApplet0_i18n_cs.jar +0 -0
  61. data/share/views/public/plugins/jmol/JmolApplet0_i18n_da.jar +0 -0
  62. data/share/views/public/plugins/jmol/JmolApplet0_i18n_de.jar +0 -0
  63. data/share/views/public/plugins/jmol/JmolApplet0_i18n_el.jar +0 -0
  64. data/share/views/public/plugins/jmol/JmolApplet0_i18n_en_GB.jar +0 -0
  65. data/share/views/public/plugins/jmol/JmolApplet0_i18n_es.jar +0 -0
  66. data/share/views/public/plugins/jmol/JmolApplet0_i18n_et.jar +0 -0
  67. data/share/views/public/plugins/jmol/JmolApplet0_i18n_fi.jar +0 -0
  68. data/share/views/public/plugins/jmol/JmolApplet0_i18n_fr.jar +0 -0
  69. data/share/views/public/plugins/jmol/JmolApplet0_i18n_fy.jar +0 -0
  70. data/share/views/public/plugins/jmol/JmolApplet0_i18n_hu.jar +0 -0
  71. data/share/views/public/plugins/jmol/JmolApplet0_i18n_hy.jar +0 -0
  72. data/share/views/public/plugins/jmol/JmolApplet0_i18n_id.jar +0 -0
  73. data/share/views/public/plugins/jmol/JmolApplet0_i18n_it.jar +0 -0
  74. data/share/views/public/plugins/jmol/JmolApplet0_i18n_jv.jar +0 -0
  75. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ko.jar +0 -0
  76. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ms.jar +0 -0
  77. data/share/views/public/plugins/jmol/JmolApplet0_i18n_nb.jar +0 -0
  78. data/share/views/public/plugins/jmol/JmolApplet0_i18n_nl.jar +0 -0
  79. data/share/views/public/plugins/jmol/JmolApplet0_i18n_oc.jar +0 -0
  80. data/share/views/public/plugins/jmol/JmolApplet0_i18n_pl.jar +0 -0
  81. data/share/views/public/plugins/jmol/JmolApplet0_i18n_pt.jar +0 -0
  82. data/share/views/public/plugins/jmol/JmolApplet0_i18n_pt_BR.jar +0 -0
  83. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ru.jar +0 -0
  84. data/share/views/public/plugins/jmol/JmolApplet0_i18n_sl.jar +0 -0
  85. data/share/views/public/plugins/jmol/JmolApplet0_i18n_sv.jar +0 -0
  86. data/share/views/public/plugins/jmol/JmolApplet0_i18n_ta.jar +0 -0
  87. data/share/views/public/plugins/jmol/JmolApplet0_i18n_te.jar +0 -0
  88. data/share/views/public/plugins/jmol/JmolApplet0_i18n_tr.jar +0 -0
  89. data/share/views/public/plugins/jmol/JmolApplet0_i18n_uk.jar +0 -0
  90. data/share/views/public/plugins/jmol/JmolApplet0_i18n_zh_CN.jar +0 -0
  91. data/share/views/public/plugins/jmol/JmolApplet0_i18n_zh_TW.jar +0 -0
  92. data/share/views/public/plugins/jmol/JmolAppletSigned.jar +0 -0
  93. data/share/views/public/plugins/jmol/JmolAppletSigned0.jar +0 -0
  94. data/share/views/public/plugins/jmol/JmolAppletSigned0_Console.jar +0 -0
  95. data/share/views/public/plugins/jmol/JmolAppletSigned0_Minimize.jar +0 -0
  96. data/share/views/public/plugins/jmol/JmolAppletSigned0_MultiTouch.jar +0 -0
  97. data/share/views/public/plugins/jmol/JmolAppletSigned0_Popup.jar +0 -0
  98. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersCifPdb.jar +0 -0
  99. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersMolXyz.jar +0 -0
  100. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersMore.jar +0 -0
  101. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersQuantum.jar +0 -0
  102. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersSimple.jar +0 -0
  103. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersXml.jar +0 -0
  104. data/share/views/public/plugins/jmol/JmolAppletSigned0_ReadersXtal.jar +0 -0
  105. data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeBio.jar +0 -0
  106. data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeSpecial.jar +0 -0
  107. data/share/views/public/plugins/jmol/JmolAppletSigned0_ShapeSurface.jar +0 -0
  108. data/share/views/public/plugins/jmol/JmolAppletSigned0_Smiles.jar +0 -0
  109. data/share/views/public/plugins/jmol/JmolAppletSigned0_Symmetry.jar +0 -0
  110. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ar.jar +0 -0
  111. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_bs.jar +0 -0
  112. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ca.jar +0 -0
  113. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_cs.jar +0 -0
  114. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_da.jar +0 -0
  115. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_de.jar +0 -0
  116. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_el.jar +0 -0
  117. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_en_GB.jar +0 -0
  118. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_es.jar +0 -0
  119. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_et.jar +0 -0
  120. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fi.jar +0 -0
  121. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fr.jar +0 -0
  122. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_fy.jar +0 -0
  123. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_hu.jar +0 -0
  124. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_hy.jar +0 -0
  125. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_id.jar +0 -0
  126. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_it.jar +0 -0
  127. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_jv.jar +0 -0
  128. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ko.jar +0 -0
  129. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ms.jar +0 -0
  130. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_nb.jar +0 -0
  131. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_nl.jar +0 -0
  132. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_oc.jar +0 -0
  133. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pl.jar +0 -0
  134. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pt.jar +0 -0
  135. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_pt_BR.jar +0 -0
  136. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ru.jar +0 -0
  137. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_sl.jar +0 -0
  138. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_sv.jar +0 -0
  139. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_ta.jar +0 -0
  140. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_te.jar +0 -0
  141. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_tr.jar +0 -0
  142. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_uk.jar +0 -0
  143. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_zh_CN.jar +0 -0
  144. data/share/views/public/plugins/jmol/JmolAppletSigned0_i18n_zh_TW.jar +0 -0
  145. data/share/views/public/plugins/jmol/JmolData.jar +0 -0
  146. data/share/views/public/plugins/jmol/LEAME.txt +217 -0
  147. data/share/views/public/plugins/jmol/LICENSE.txt +504 -0
  148. data/share/views/public/plugins/jmol/README.txt +203 -0
  149. data/share/views/public/plugins/jmol/jmol +22 -0
  150. data/share/views/public/plugins/jmol/jmol.bat +5 -0
  151. data/share/views/public/plugins/jmol/jmol.mac +0 -0
  152. data/share/views/public/plugins/jmol/jmol.sh +39 -0
  153. data/share/views/public/plugins/jquery/js/jquery.form.js +980 -0
  154. data/share/views/result.haml +2 -2
  155. metadata +139 -6
  156. data/share/views/workflow_list.haml +0 -5
@@ -0,0 +1,73 @@
1
+
2
+ Copyright 1998-2007 The Jmol Development Team
3
+
4
+ This library is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU Lesser General Public
6
+ License as published by the Free Software Foundation; either
7
+ version 2.1 of the License, or (at your option) any later version.
8
+
9
+ This library is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public
15
+ License along with this library; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17
+ 02111-1307 USA.
18
+
19
+
20
+ Complete source code for the Jmol application, the Jmol applet, and
21
+ surrounding utilities is available from http://www.jmol.org
22
+
23
+
24
+ This software uses several external libraries and resources:
25
+
26
+ JUnit
27
+ Used for unit testing. Distributed by the IBM Public License (see
28
+ doc/ibm.license.html). See http://www.junit.org/.
29
+
30
+ The Chemical Development Kit
31
+ Used for reading and writing CML and ShelX. Distributed by Lesser GNU Public
32
+ License
33
+ See http://cdk.sf.net/.
34
+
35
+ AElfred
36
+ Used for XML parsing. Distributed free and without warranty.
37
+ Copyright (C) 1997,1998 by Microstar Software Ltd.
38
+ See http://www.microstar.com/aelfred.html.
39
+
40
+ SAX
41
+ Used for event-based XML parsing. Distributed free and without warranty.
42
+ See http://www.megginson.com/SAX/.
43
+
44
+ Acme Image encoders
45
+ Used for exporting images in GIF and PPM formats. Distributed free and
46
+ without warranty. Copyright (C) 1996,1998 by Jef Poskanzer.
47
+ See http://www.acme.com/.
48
+
49
+ JPEG Encoder
50
+ Used for exporting images in JPEG format. Distributed free and without
51
+ warranty (see doc/jpegEncoder.license).
52
+ Copyright (c) 1998 James R. Weeks and BioElectroMech.
53
+ See http://www.obrador.com/essentialjpeg/.
54
+
55
+ Java Analysis Studio
56
+ Used for graphs. Distributed by the GNU Lesser General Public License
57
+ (see doc/lgpl.license), and requires providing the source code (see
58
+ http://jas.freehep.org/source.htm). See http://jas.freehep.org/.
59
+
60
+ Unofficial Java3D vecmath package
61
+ Used for linear algebra. Distributed free and without warranty.
62
+ Copyright (C) 1997,1998,1999 by Kenji Hiranabe.
63
+ See http://www.esm.co.jp/divisions/open-sys/java/vecmath/.
64
+
65
+ JFA Icon collection
66
+ Used for icons in menus and toolbars. Distributed free and without warranty.
67
+ Copyright (C) 1998 by Dean S. Jones.
68
+ See http://jfa.javalobby.org/projects/icons/
69
+
70
+ Jakarta Commons CLI
71
+ Used for parsing command line optinos. Distributed with The Apache Software
72
+ License, Version 1.1. Copyright (c) 1999-2001 The Apache Software Foundation.
73
+ See http://jakarta.apache.org/commons/cli/.
@@ -0,0 +1,1711 @@
1
+ /* Jmol 12.0 script library Jmol.js 9:48 PM 1/31/2011 Bob Hanson
2
+
3
+ checkbox heirarchy -- see http://chemapps.stolaf.edu/jmol/docs/examples-11/check.htm
4
+
5
+ based on:
6
+ *
7
+ * Copyright (C) 2004-2005 Miguel, Jmol Development, www.jmol.org
8
+ *
9
+ * Contact: hansonr@stolaf.edu
10
+ *
11
+ * This library is free software; you can redistribute it and/or
12
+ * modify it under the terms of the GNU Lesser General Public
13
+ * License as published by the Free Software Foundation; either
14
+ * version 2.1 of the License, or (at your option) any later version.
15
+ *
16
+ * This library is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ * Lesser General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Lesser General Public
22
+ * License along with this library; if not, write to the Free Software
23
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24
+ * 02111-1307 USA.
25
+ */
26
+
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
+ // angel herraez -- update of jmolResize(w,h,targetSuffix) so it is not tied to first applet
36
+ // bob hanson -- jmolEvaluate -- evaluates molecular math 8:37 AM 2/23/2007
37
+ // bob hanson -- jmolScriptMessage -- returns all "scriptStatus" messages 8:37 AM 2/23/2007
38
+ // bob hanson -- jmolScriptEcho -- returns all "scriptEcho" messages 8:37 AM 2/23/2007
39
+ // bob hanson -- jmolScriptWait -- 11:31 AM 5/2/2006
40
+ // bob hanson -- remove trailing separatorHTML in radio groups -- 12:18 PM 5/6/2006
41
+ // bob hanson -- adds support for dynamic DOM script nodes 7:04 AM 5/19/2006
42
+ // bob hanson -- adds try/catch for wiki - multiple code passes 7:05 AM 5/19/2006
43
+ // bob hanson -- auto-initiates to defaultdir/defaultjar -- change as desired.
44
+ // bob hanson -- adding save/restore orientation w/ and w/o delay 11:49 AM 5/25/2006
45
+ // bob hanson -- adding AjaxJS service 11:16 AM 6/3/2006
46
+ // bob hanson -- fix for iframes not available for finding applet
47
+ // bob hanson -- added applet fake ?NOAPPLET URL flag
48
+ // bob hanson -- added jmolSetCallback(calbackName, funcName) 3:32 PM 6/13/2006
49
+ // used PRIOR to jmolApplet() or jmolAppletInline()
50
+ // added 4th array element in jmolRadioGroup -- title
51
+ // added <span> and id around link, checkbox, radio, menu
52
+ // fixing AJAX loads for MSIE/Opera-Mozilla incompatibility
53
+ // -- renamed Jmol-11.js from Jmol-new.js; JmolApplet.jar from JmolAppletProto.jar
54
+ // renamed Jmol.js for Jmol 11 distribution
55
+ // -- modified jmolRestoreOrientation() to be immediate, no 1-second delay
56
+ // bob hanson -- jmolScriptWait always returns a string -- 11:23 AM 9/16/2006
57
+ // bh -- jmolCommandInput()
58
+ // bh -- jmolSetTranslation(TF) -- forces translation even if there might be message callback issues
59
+ // bh -- minor fixes suggested by Angel
60
+ // bh -- adds jmolSetSyncId() and jmolGetSyncId()
61
+ // bh 3/2008 -- adds jmolAppendInlineScript() and jmolAppendInlineArray()
62
+ // bh 3/2008 -- fixes IE7 bug in relation to jmolLoadInlineArray()
63
+ // bh 6/2008 -- adds jmolSetAppletWindow()
64
+ // Angel H. 6/2008 -- added html <label> tags to checkboxes and radio buttons [in jmolCheckbox() and _jmolRadio() functions]
65
+ // bh 7/2008 -- code fix "for(i..." not "for(var i..."
66
+ // bh 12/2008 -- jmolLoadInline, jmolLoadInlineArray, jmolLoadInlineScript, jmolAppendInlineScript, jmolAppendInlineArray all return error message or null (Jmol 11.7.16)
67
+ // bh 12/2008 -- jmolScriptWaitOutput() -- waits for script to complete and delivers output normally sent to console
68
+
69
+ // bh 5/2009 -- Support for XHTML using jmolSetXHTML(id)
70
+ // ah & bh 6/2009 -- New jmolResizeApplet() more flexible, similar to jmolApplet() size syntax
71
+ // bh 11/2009 -- care in accessing top.document
72
+ // bh 12/2009 -- added jmolSetParameter(name, value)
73
+ // bh 12/2009 -- added PARAMS=name:value;name:value;name:value... for command line
74
+ // bh 12/2009 -- overhaul of target checking
75
+ // bh 1/2010 -- all _xxxx() methods ALWAYS have complete argument list
76
+ // bh 1/2010 -- adds option to run a JavaScript function from any Jmol control.
77
+ // This is accomplished by passing an array rather than a script:
78
+ // jmolHref([myfunc,"my param 1", "my param 2"], "testing")
79
+ // function myfunc(jmolControlObject, [myfunc,"my param 1", "my param 2"], target){...}
80
+ // and allows much more flexibility with responding to controls
81
+ // bh 4/2010 -- added jmolSetMemoryMb(nMb)
82
+ // ah 1/2011 -- wider detection of browsers; more browsers now use the object tag instead of the applet tag;
83
+ // fix of object tag (removed classid) accounts for change of behavior in Chrome
84
+ // bh 3/2011 -- added jmolLoadAjax_STOLAF_NIH
85
+ // ah 9/2011 -- Applet is now wrapped in a <span> tag (might break existing user code).
86
+ // Added jmolSwitchToSignedApplet(); replaces an applet with the signed applet,
87
+ // preserving size, model and state; an additional script may be specified.
88
+ // Note: as a result, unsigned and signed applets may coexist in a page.
89
+
90
+ var defaultdir = "/plugins/jmol/"
91
+ var defaultjar = "JmolAppletSigned.jar"
92
+
93
+
94
+ // Note added 12:41 PM 9/21/2008 by Bob Hanson, hansonr@stolaf.edu:
95
+
96
+ // JMOLJAR=xxxxx.jar on the URL for this page will override
97
+ // the JAR file specified in the jmolInitialize() call.
98
+
99
+ // The idea is that it can be very useful to test a web page with different JAR files
100
+ // Or for an expert user to substitute a signed applet for an unsigned one
101
+ // so as to use a broader range of models or to create JPEG files, for example.
102
+
103
+ // If the JAR file is not in the current directory (has any sort of "/" in its name)
104
+ // then the user is presented with a warning and asked whether it is OK to change Jar files.
105
+ // The default action, if the user just presses "OK" is to NOT allow the change.
106
+ // The user must type the word "yes" in the prompt box for the change to be approved.
107
+
108
+ // For a simple change to the signed applet in the same original directory (if it's available),
109
+ // you can use JMOLJAR=SIGNED on the URL.
110
+
111
+ // If you don't want people to be able to switch in their own JAR file on your page,
112
+ // simply set this next line to read "var allowJMOLJAR = false".
113
+
114
+
115
+ var undefined; // for IE 5 ... wherein undefined is undefined
116
+
117
+ ////////////////////////////////////////////////////////////////
118
+ // Basic Scripting infrastruture
119
+ ////////////////////////////////////////////////////////////////
120
+
121
+ function jmolInitialize(codebaseDirectory, fileNameOrUseSignedApplet) {
122
+ if (_jmol.initialized)
123
+ return;
124
+ _jmol.initialized = true;
125
+ if(_jmol.jmoljar) {
126
+ var f = _jmol.jmoljar;
127
+ if (f.indexOf("/") >= 0) {
128
+ 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.")
129
+ var ok = prompt("Do you want to use applet " + f + "? ","yes or no")
130
+ if (ok == "yes") {
131
+ codebaseDirectory = f.substring(0, f.lastIndexOf("/"));
132
+ fileNameOrUseSignedApplet = f.substring(f.lastIndexOf("/") + 1);
133
+ } else {
134
+ _jmolGetJarFilename(fileNameOrUseSignedApplet);
135
+ alert("The web page URL was ignored. Continuing using " + _jmol.archivePath + ' in directory "' + codebaseDirectory + '"');
136
+ }
137
+ } else {
138
+ if (f=="SIGNED") { f=true; }
139
+ fileNameOrUseSignedApplet = f;
140
+ }
141
+ }
142
+ _jmolSetCodebase(codebaseDirectory);
143
+ _jmolGetJarFilename(fileNameOrUseSignedApplet);
144
+ _jmolOnloadResetForms();
145
+ }
146
+
147
+ function jmolSetTranslation(TF) {
148
+ _jmol.params.doTranslate = ''+TF;
149
+ }
150
+
151
+ function _jmolGetJarFilename(fileNameOrFlag) {
152
+ _jmol.archivePath =
153
+ (typeof(fileNameOrFlag) == "string" ? fileNameOrFlag : (fileNameOrFlag ? "JmolAppletSigned" : "JmolApplet") + "0.jar");
154
+ }
155
+
156
+ function jmolSetDocument(doc) {
157
+ _jmol.currentDocument = doc;
158
+ }
159
+
160
+ function jmolSetAppletColor(boxbgcolor, boxfgcolor, progresscolor) {
161
+ _jmolInitCheck();
162
+ _jmol.params.boxbgcolor = boxbgcolor;
163
+ if (boxfgcolor)
164
+ _jmol.params.boxfgcolor = boxfgcolor
165
+ else if (boxbgcolor == "white" || boxbgcolor == "#FFFFFF")
166
+ _jmol.params.boxfgcolor = "black";
167
+ else
168
+ _jmol.params.boxfgcolor = "white";
169
+ if (progresscolor)
170
+ _jmol.params.progresscolor = progresscolor;
171
+ if (_jmol.debugAlert)
172
+ alert(" boxbgcolor=" + _jmol.params.boxbgcolor +
173
+ " boxfgcolor=" + _jmol.params.boxfgcolor +
174
+ " progresscolor=" + _jmol.params.progresscolor);
175
+ }
176
+
177
+ function jmolSetAppletWindow(w) {
178
+ _jmol.appletWindow = w;
179
+ }
180
+
181
+ function jmolApplet(size, script, nameSuffix) {
182
+ _jmolInitCheck();
183
+ return _jmolApplet(size, null, script, nameSuffix);
184
+ }
185
+
186
+ ////////////////////////////////////////////////////////////////
187
+ // Basic controls
188
+ ////////////////////////////////////////////////////////////////
189
+
190
+ // undefined means it wasn't there; null means it was explicitly listed as null (so as to skip it)
191
+
192
+ function jmolButton(script, label, id, title) {
193
+ _jmolInitCheck();
194
+ id != undefined && id != null || (id = "jmolButton" + _jmol.buttonCount);
195
+ label != undefined && label != null || (label = script.substring(0, 32));
196
+ ++_jmol.buttonCount;
197
+ var scriptIndex = _jmolAddScript(script);
198
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input type='button' name='" + id + "' id='" + id +
199
+ "' value='" + label +
200
+ "' onclick='_jmolClick(this," + scriptIndex + _jmol.targetText +
201
+ ")' onmouseover='_jmolMouseOver(" + scriptIndex +
202
+ ");return true' onmouseout='_jmolMouseOut()' " +
203
+ _jmol.buttonCssText + " /></span>";
204
+ if (_jmol.debugAlert)
205
+ alert(t);
206
+ return _jmolDocumentWrite(t);
207
+ }
208
+
209
+ function jmolCheckbox(scriptWhenChecked, scriptWhenUnchecked,
210
+ labelHtml, isChecked, id, title) {
211
+ _jmolInitCheck();
212
+ id != undefined && id != null || (id = "jmolCheckbox" + _jmol.checkboxCount);
213
+ ++_jmol.checkboxCount;
214
+ if (scriptWhenChecked == undefined || scriptWhenChecked == null ||
215
+ scriptWhenUnchecked == undefined || scriptWhenUnchecked == null) {
216
+ alert("jmolCheckbox requires two scripts");
217
+ return;
218
+ }
219
+ if (labelHtml == undefined || labelHtml == null) {
220
+ alert("jmolCheckbox requires a label");
221
+ return;
222
+ }
223
+ var indexChecked = _jmolAddScript(scriptWhenChecked);
224
+ var indexUnchecked = _jmolAddScript(scriptWhenUnchecked);
225
+ var eospan = "</span>"
226
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input type='checkbox' name='" + id + "' id='" + id +
227
+ "' onclick='_jmolCbClick(this," +
228
+ indexChecked + "," + indexUnchecked + _jmol.targetText +
229
+ ")' onmouseover='_jmolCbOver(this," + indexChecked + "," +
230
+ indexUnchecked +
231
+ ");return true' onmouseout='_jmolMouseOut()' " +
232
+ (isChecked ? "checked='true' " : "")+ _jmol.checkboxCssText + " />"
233
+ if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
234
+ t += eospan
235
+ eospan = "";
236
+ }
237
+ t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan;
238
+ if (_jmol.debugAlert)
239
+ alert(t);
240
+ return _jmolDocumentWrite(t);
241
+ }
242
+
243
+ function jmolStartNewRadioGroup() {
244
+ ++_jmol.radioGroupCount;
245
+ }
246
+
247
+ function jmolRadioGroup(arrayOfRadioButtons, separatorHtml, groupName, id, title) {
248
+ /*
249
+
250
+ array: [radio1,radio2,radio3...]
251
+ where radioN = ["script","label",isSelected,"id","title"]
252
+
253
+ */
254
+
255
+ _jmolInitCheck();
256
+ var type = typeof arrayOfRadioButtons;
257
+ if (type != "object" || type == null || ! arrayOfRadioButtons.length) {
258
+ alert("invalid arrayOfRadioButtons");
259
+ return;
260
+ }
261
+ separatorHtml != undefined && separatorHtml != null || (separatorHtml = "&nbsp; ");
262
+ var len = arrayOfRadioButtons.length;
263
+ jmolStartNewRadioGroup();
264
+ groupName || (groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1));
265
+ var t = "<span id='"+(id ? id : groupName)+"'>";
266
+ for (var i = 0; i < len; ++i) {
267
+ if (i == len - 1)
268
+ separatorHtml = "";
269
+ var radio = arrayOfRadioButtons[i];
270
+ type = typeof radio;
271
+ if (type == "object") {
272
+ 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);
273
+ } else {
274
+ t += _jmolRadio(radio, null, null, separatorHtml, groupName, (id ? id : groupName)+"_"+i, title);
275
+ }
276
+ }
277
+ t+="</span>"
278
+ if (_jmol.debugAlert)
279
+ alert(t);
280
+ return _jmolDocumentWrite(t);
281
+ }
282
+
283
+
284
+ function jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
285
+ _jmolInitCheck();
286
+ if (_jmol.radioGroupCount == 0)
287
+ ++_jmol.radioGroupCount;
288
+ var t = _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, (id ? id : groupName + "_" + _jmol.radioCount), title ? title : 0);
289
+ if (_jmol.debugAlert)
290
+ alert(t);
291
+ return _jmolDocumentWrite(t);
292
+ }
293
+
294
+ function jmolLink(script, label, id, title) {
295
+ _jmolInitCheck();
296
+ id != undefined && id != null || (id = "jmolLink" + _jmol.linkCount);
297
+ label != undefined && label != null || (label = script.substring(0, 32));
298
+ ++_jmol.linkCount;
299
+ var scriptIndex = _jmolAddScript(script);
300
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><a name='" + id + "' id='" + id +
301
+ "' href='javascript:_jmolClick(this," + scriptIndex + _jmol.targetText + ");' onmouseover='_jmolMouseOver(" + scriptIndex +
302
+ ");return true;' onmouseout='_jmolMouseOut()' " +
303
+ _jmol.linkCssText + ">" + label + "</a></span>";
304
+ if (_jmol.debugAlert)
305
+ alert(t);
306
+ return _jmolDocumentWrite(t);
307
+ }
308
+
309
+ function jmolCommandInput(label, size, id, title) {
310
+ _jmolInitCheck();
311
+ id != undefined && id != null || (id = "jmolCmd" + _jmol.cmdCount);
312
+ label != undefined && label != null || (label = "Execute");
313
+ size != undefined && !isNaN(size) || (size = 60);
314
+ ++_jmol.cmdCount;
315
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input name='" + id + "' id='" + id +
316
+ "' size='"+size+"' onkeypress='_jmolCommandKeyPress(event,\""+id+"\"" + _jmol.targetText + ")'><input type=button value = '"+label+"' onclick='jmolScript(document.getElementById(\""+id+"\").value" + _jmol.targetText + ")' /></span>";
317
+ if (_jmol.debugAlert)
318
+ alert(t);
319
+ return _jmolDocumentWrite(t);
320
+ }
321
+
322
+ function _jmolCommandKeyPress(e, id, target) {
323
+ var keycode = (window.event ? window.event.keyCode : e ? e.which : 0);
324
+ if (keycode == 13) {
325
+ var inputBox = document.getElementById(id)
326
+ _jmolScriptExecute(inputBox, inputBox.value, target)
327
+ }
328
+ }
329
+
330
+ function _jmolScriptExecute(element,script,target) {
331
+ if (typeof(script) == "object")
332
+ script[0](element, script, target)
333
+ else
334
+ jmolScript(script, target)
335
+ }
336
+
337
+ function jmolMenu(arrayOfMenuItems, size, id, title) {
338
+ _jmolInitCheck();
339
+ id != undefined && id != null || (id = "jmolMenu" + _jmol.menuCount);
340
+ ++_jmol.menuCount;
341
+ var type = typeof arrayOfMenuItems;
342
+ if (type != null && type == "object" && arrayOfMenuItems.length) {
343
+ var len = arrayOfMenuItems.length;
344
+ if (typeof size != "number" || size == 1)
345
+ size = null;
346
+ else if (size < 0)
347
+ size = len;
348
+ var sizeText = size ? " size='" + size + "' " : "";
349
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><select name='" + id + "' id='" + id +
350
+ "' onChange='_jmolMenuSelected(this" + _jmol.targetText + ")'" +
351
+ sizeText + _jmol.menuCssText + ">";
352
+ for (var i = 0; i < len; ++i) {
353
+ var menuItem = arrayOfMenuItems[i];
354
+ type = typeof menuItem;
355
+ var script, text;
356
+ var isSelected = undefined;
357
+ if (type == "object" && menuItem != null) {
358
+ script = menuItem[0];
359
+ text = menuItem[1];
360
+ isSelected = menuItem[2];
361
+ } else {
362
+ script = text = menuItem;
363
+ }
364
+ text != undefined && text != null || (text = script);
365
+ if (script=="#optgroup") {
366
+ t += "<optgroup label='" + text + "'>";
367
+ } else if (script=="#optgroupEnd") {
368
+ t += "</optgroup>";
369
+ } else {
370
+ var scriptIndex = _jmolAddScript(script);
371
+ var selectedText = isSelected ? "' selected='true'>" : "'>";
372
+ t += "<option value='" + scriptIndex + selectedText + text + "</option>";
373
+ }
374
+ }
375
+ t += "</select></span>";
376
+ if (_jmol.debugAlert)
377
+ alert(t);
378
+ return _jmolDocumentWrite(t);
379
+ }
380
+ }
381
+
382
+ function jmolHtml(html) {
383
+ return _jmolDocumentWrite(html);
384
+ }
385
+
386
+ function jmolBr() {
387
+ return _jmolDocumentWrite("<br />");
388
+ }
389
+
390
+ ////////////////////////////////////////////////////////////////
391
+ // advanced scripting functions
392
+ ////////////////////////////////////////////////////////////////
393
+
394
+ function jmolDebugAlert(enableAlerts) {
395
+ _jmol.debugAlert = (enableAlerts == undefined || enableAlerts)
396
+ }
397
+
398
+ function jmolAppletInline(size, inlineModel, script, nameSuffix) {
399
+ _jmolInitCheck();
400
+ return _jmolApplet(size, _jmolSterilizeInline(inlineModel),
401
+ script, nameSuffix);
402
+ }
403
+
404
+ function jmolSetTarget(targetSuffix) {
405
+ _jmol.targetSuffix = targetSuffix;
406
+ _jmol.targetText = targetSuffix ? ",\"" + targetSuffix + "\"" : ",0";
407
+ }
408
+
409
+ function jmolScript(script, targetSuffix) {
410
+ if (script) {
411
+ _jmolCheckBrowser();
412
+ if (targetSuffix == "all") {
413
+ with (_jmol) {
414
+ for (var i = 0; i < appletSuffixes.length; ++i) {
415
+ var applet = _jmolGetApplet(appletSuffixes[i]);
416
+ if (applet) applet.script(script);
417
+ }
418
+ }
419
+ } else {
420
+ var applet=_jmolGetApplet(targetSuffix);
421
+ if (applet) applet.script(script);
422
+ }
423
+ }
424
+ }
425
+
426
+ function jmolLoadInline(model, targetSuffix) {
427
+ if (!model)return "ERROR: NO MODEL"
428
+ var applet=_jmolGetApplet(targetSuffix);
429
+ if (!applet)return "ERROR: NO APPLET"
430
+ if (typeof(model) == "string")
431
+ return applet.loadInlineString(model, "", false);
432
+ else
433
+ return applet.loadInlineArray(model, "", false);
434
+ }
435
+
436
+
437
+ function jmolLoadInlineScript(model, script, targetSuffix) {
438
+ if (!model)return "ERROR: NO MODEL"
439
+ var applet=_jmolGetApplet(targetSuffix);
440
+ if (!applet)return "ERROR: NO APPLET"
441
+ return applet.loadInlineString(model, script, false);
442
+ }
443
+
444
+
445
+ function jmolLoadInlineArray(ModelArray, script, targetSuffix) {
446
+ if (!model)return "ERROR: NO MODEL"
447
+ script || (script="")
448
+ var applet=_jmolGetApplet(targetSuffix);
449
+ if (!applet)return "ERROR: NO APPLET"
450
+ try {
451
+ return applet.loadInlineArray(ModelArray, script, false);
452
+ } catch (err) {
453
+ //IE 7 bug
454
+ return applet.loadInlineString(ModelArray.join("\n"), script, false);
455
+ }
456
+ }
457
+
458
+ function jmolAppendInlineArray(ModelArray, script, targetSuffix) {
459
+ if (!model)return "ERROR: NO MODEL"
460
+ script || (script="")
461
+ var applet=_jmolGetApplet(targetSuffix);
462
+ if (!applet)return "ERROR: NO APPLET"
463
+ try {
464
+ return applet.loadInlineArray(ModelArray, script, true);
465
+ } catch (err) {
466
+ //IE 7 bug
467
+ return applet.loadInlineString(ModelArray.join("\n"), script, true);
468
+ }
469
+ }
470
+
471
+ function jmolAppendInlineScript(model, script, targetSuffix) {
472
+ if (!model)return "ERROR: NO MODEL"
473
+ var applet=_jmolGetApplet(targetSuffix);
474
+ if (!applet)return "ERROR: NO APPLET"
475
+ return applet.loadInlineString(model, script, true);
476
+ }
477
+
478
+ function jmolCheckBrowser(action, urlOrMessage, nowOrLater) {
479
+ if (typeof action == "string") {
480
+ action = action.toLowerCase();
481
+ action == "alert" || action == "redirect" || action == "popup" || (action = null);
482
+ }
483
+ if (typeof action != "string")
484
+ alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
485
+ "action must be 'alert', 'redirect', or 'popup'");
486
+ else {
487
+ if (typeof urlOrMessage != "string")
488
+ alert("jmolCheckBrowser(action, urlOrMessage, nowOrLater)\n\n" +
489
+ "urlOrMessage must be a string");
490
+ else {
491
+ _jmol.checkBrowserAction = action;
492
+ _jmol.checkBrowserUrlOrMessage = urlOrMessage;
493
+ }
494
+ }
495
+ if (typeof nowOrLater == "string" && nowOrLater.toLowerCase() == "now")
496
+ _jmolCheckBrowser();
497
+ }
498
+
499
+ var _jmolScriptForSwitching;
500
+ function jmolSwitchToSignedApplet(targetSuffix, additionalScript) {
501
+ if (!targetSuffix) { targetSuffix = "0"; }
502
+ if (!additionalScript) { additionalScript = ""; }
503
+ var s = jmolEvaluate("_signedApplet",targetSuffix);
504
+ var w = jmolEvaluate("_width",targetSuffix);
505
+ var h = jmolEvaluate("_height",targetSuffix);
506
+ if (s=="true") {
507
+ jmolScript(additionalScript,targetSuffix);
508
+ return;
509
+ }
510
+ var appletParent = document.getElementById("jmolApplet"+targetSuffix).parentNode;
511
+ _jmolScriptForSwitching = jmolGetPropertyAsString("stateInfo", "", targetSuffix) + additionalScript;
512
+ appletParent.innerHTML = "";
513
+ _jmolGetJarFilename(true);
514
+ jmolSetDocument(false);
515
+ appletParent.innerHTML = jmolApplet([w,h], "javascript jmolScript(_jmolScriptForSwitching," + targetSuffix + ")", targetSuffix);
516
+ jmolSetDocument(document);
517
+ }
518
+
519
+ ////////////////////////////////////////////////////////////////
520
+ // Cascading Style Sheet Class support
521
+ ////////////////////////////////////////////////////////////////
522
+
523
+ function jmolSetAppletCssClass(appletCssClass) {
524
+ if (_jmol.hasGetElementById) {
525
+ _jmol.appletCssClass = appletCssClass;
526
+ _jmol.appletCssText = appletCssClass ? "class='" + appletCssClass + "' " : "";
527
+ }
528
+ }
529
+
530
+ function jmolSetButtonCssClass(buttonCssClass) {
531
+ if (_jmol.hasGetElementById) {
532
+ _jmol.buttonCssClass = buttonCssClass;
533
+ _jmol.buttonCssText = buttonCssClass ? "class='" + buttonCssClass + "' " : "";
534
+ }
535
+ }
536
+
537
+ function jmolSetCheckboxCssClass(checkboxCssClass) {
538
+ if (_jmol.hasGetElementById) {
539
+ _jmol.checkboxCssClass = checkboxCssClass;
540
+ _jmol.checkboxCssText = checkboxCssClass ? "class='" + checkboxCssClass + "' " : "";
541
+ }
542
+ }
543
+
544
+ function jmolSetRadioCssClass(radioCssClass) {
545
+ if (_jmol.hasGetElementById) {
546
+ _jmol.radioCssClass = radioCssClass;
547
+ _jmol.radioCssText = radioCssClass ? "class='" + radioCssClass + "' " : "";
548
+ }
549
+ }
550
+
551
+ function jmolSetLinkCssClass(linkCssClass) {
552
+ if (_jmol.hasGetElementById) {
553
+ _jmol.linkCssClass = linkCssClass;
554
+ _jmol.linkCssText = linkCssClass ? "class='" + linkCssClass + "' " : "";
555
+ }
556
+ }
557
+
558
+ function jmolSetMenuCssClass(menuCssClass) {
559
+ if (_jmol.hasGetElementById) {
560
+ _jmol.menuCssClass = menuCssClass;
561
+ _jmol.menuCssText = menuCssClass ? "class='" + menuCssClass + "' " : "";
562
+ }
563
+ }
564
+
565
+ ////////////////////////////////////////////////////////////////
566
+ // functions for INTERNAL USE ONLY which are subject to change
567
+ // use at your own risk ... you have been WARNED!
568
+ ////////////////////////////////////////////////////////////////
569
+ var _jmol = {
570
+ currentDocument: document,
571
+
572
+ debugAlert: false,
573
+
574
+ codebase: "",
575
+ modelbase: ".",
576
+
577
+ appletCount: 0,
578
+ appletSuffixes: [],
579
+ appletWindow: null,
580
+ allowedJmolSize: [25, 2048, 300], // min, max, default (pixels)
581
+ /* By setting the _jmol.allowedJmolSize[] variable in the webpage
582
+ before calling jmolApplet(), limits for applet size can be overriden.
583
+ 2048 standard for GeoWall (http://geowall.geo.lsa.umich.edu/home.html)
584
+ */
585
+ buttonCount: 0,
586
+ checkboxCount: 0,
587
+ linkCount: 0,
588
+ cmdCount: 0,
589
+ menuCount: 0,
590
+ radioCount: 0,
591
+ radioGroupCount: 0,
592
+
593
+ appletCssClass: null,
594
+ appletCssText: "",
595
+ buttonCssClass: null,
596
+ buttonCssText: "",
597
+ checkboxCssClass: null,
598
+ checkboxCssText: "",
599
+ java_arguments: "-Xmx512m",
600
+ radioCssClass: null,
601
+ radioCssText: "",
602
+ linkCssClass: null,
603
+ linkCssText: "",
604
+ menuCssClass: null,
605
+ menuCssText: "",
606
+
607
+ targetSuffix: 0,
608
+ targetText: ",0",
609
+ scripts: [""],
610
+ params: {
611
+ syncId: ("" + Math.random()).substring(3),
612
+ progressbar: "true",
613
+ progresscolor: "blue",
614
+ boxbgcolor: "black",
615
+ boxfgcolor: "white",
616
+ boxmessage: "Downloading JmolApplet ..."
617
+ },
618
+ ua: navigator.userAgent.toLowerCase(),
619
+ // uaVersion: parseFloat(navigator.appVersion), // not used
620
+
621
+ os: "unknown",
622
+ browser: "unknown",
623
+ browserVersion: 0,
624
+ hasGetElementById: !!document.getElementById,
625
+ isJavaEnabled: navigator.javaEnabled(),
626
+ // isNetscape47Win: false, // not used, N4.7 is no longer supported even for detection
627
+ useIEObject: false,
628
+ useHtml4Object: false,
629
+
630
+ windowsClassId: "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",
631
+ windowsCabUrl:
632
+ "http://java.sun.com/update/1.6.0/jinstall-6u22-windows-i586.cab",
633
+
634
+ isBrowserCompliant: false,
635
+ isJavaCompliant: false,
636
+ isFullyCompliant: false,
637
+
638
+ initialized: false,
639
+ initChecked: false,
640
+
641
+ browserChecked: false,
642
+ checkBrowserAction: "alert",
643
+ checkBrowserUrlOrMessage: null,
644
+
645
+ archivePath: null, // JmolApplet0.jar OR JmolAppletSigned0.jar
646
+
647
+ previousOnloadHandler: null,
648
+
649
+ jmoljar: null,
650
+ useNoApplet: false,
651
+
652
+ ready: {}
653
+ }
654
+
655
+ with (_jmol) {
656
+ function _jmolTestUA(candidate) {
657
+ var ua = _jmol.ua;
658
+ var index = ua.indexOf(candidate);
659
+ if (index < 0)
660
+ return false;
661
+ _jmol.browser = candidate;
662
+ _jmol.browserVersion = parseFloat(ua.substring(index+candidate.length+1));
663
+ return true;
664
+ }
665
+
666
+ function _jmolTestOS(candidate) {
667
+ if (_jmol.ua.indexOf(candidate) < 0)
668
+ return false;
669
+ _jmol.os = candidate;
670
+ return true;
671
+ }
672
+
673
+ _jmolTestUA("konqueror") ||
674
+ _jmolTestUA("webkit") ||
675
+ _jmolTestUA("omniweb") ||
676
+ _jmolTestUA("opera") ||
677
+ _jmolTestUA("webtv") ||
678
+ _jmolTestUA("icab") ||
679
+ _jmolTestUA("msie") ||
680
+ (_jmol.ua.indexOf("compatible") < 0 && _jmolTestUA("mozilla")); //Netscape, Mozilla, Seamonkey, Firefox and anything assimilated
681
+
682
+ _jmolTestOS("linux") ||
683
+ _jmolTestOS("unix") ||
684
+ _jmolTestOS("mac") ||
685
+ _jmolTestOS("win");
686
+
687
+ isBrowserCompliant = hasGetElementById;
688
+ // known exceptions (old browsers):
689
+ if (browser == "opera" && browserVersion <= 7.54 && os == "mac"
690
+ || browser == "webkit" && browserVersion < 125.12
691
+ || browser == "msie" && os == "mac"
692
+ || browser == "konqueror" && browserVersion <= 3.3
693
+ ) {
694
+ isBrowserCompliant = false;
695
+ }
696
+
697
+ // possibly more checks in the future for this
698
+ isJavaCompliant = isJavaEnabled;
699
+
700
+ isFullyCompliant = isBrowserCompliant && isJavaCompliant;
701
+
702
+ useIEObject = (os == "win" && browser == "msie" && browserVersion >= 5.5);
703
+ useHtml4Object =
704
+ (browser == "mozilla" && browserVersion >= 5) ||
705
+ (browser == "opera" && browserVersion >= 8) ||
706
+ (browser == "webkit" && browserVersion >= 412.2);
707
+ try {
708
+ if (top.location.search.indexOf("JMOLJAR=")>=0)
709
+ jmoljar = top.location.search.split("JMOLJAR=")[1].split("&")[0];
710
+ } catch(e) {
711
+ // can't access top.location
712
+ }
713
+ try {
714
+ useNoApplet = (top.location.search.indexOf("NOAPPLET")>=0);
715
+ } catch(e) {
716
+ // can't access top.document
717
+ }
718
+ }
719
+
720
+ function jmolSetMemoryMb(nMb) {
721
+ _jmol.java_arguments = "-Xmx" + Math.round(nMb) + "m"
722
+ }
723
+
724
+ function jmolSetParameter(name,value) {
725
+ _jmol.params[name] = value
726
+ }
727
+
728
+ function jmolSetCallback(callbackName,funcName) {
729
+ _jmol.params[callbackName] = funcName
730
+ }
731
+
732
+ try {
733
+ // note this is done FIRST, so it cannot override a setting done by the developer
734
+ if (top.location.search.indexOf("PARAMS=")>=0) {
735
+ var pars = unescape(top.location.search.split("PARAMS=")[1].split("&")[0]).split(";");
736
+ for (var i = 0; i < pars.length; i++) {
737
+ var p = pars[i].split(":");
738
+ jmolSetParameter(p[0],p[1]);
739
+ }
740
+ }
741
+ } catch(e) {
742
+ // can't access top.location
743
+ }
744
+
745
+ function jmolSetSyncId(n) {
746
+ return _jmol.params["syncId"] = n
747
+ }
748
+
749
+ function jmolGetSyncId() {
750
+ return _jmol.params["syncId"]
751
+ }
752
+
753
+ function jmolSetLogLevel(n) {
754
+ _jmol.params.logLevel = ''+n;
755
+ }
756
+
757
+ /* AngelH, mar2007:
758
+ By (re)setting these variables in the webpage before calling jmolApplet(),
759
+ a custom message can be provided (e.g. localized for user's language) when no Java is installed.
760
+ */
761
+ if (noJavaMsg==undefined) var noJavaMsg =
762
+ "You do not have Java applets enabled in your web browser, or your browser is blocking this applet.<br />\n" +
763
+ "Check the warning message from your browser and/or enable Java applets in<br />\n" +
764
+ "your web browser preferences, or install the Java Runtime Environment from <a href='http://www.java.com'>www.java.com</a><br />";
765
+ if (noJavaMsg2==undefined) var noJavaMsg2 =
766
+ "You do not have the<br />\n" +
767
+ "Java Runtime Environment<br />\n" +
768
+ "installed for applet support.<br />\n" +
769
+ "Visit <a href='http://www.java.com'>www.java.com</a>";
770
+ function _jmolApplet(size, inlineModel, script, nameSuffix) {
771
+ /* AngelH, mar2007
772
+ Fixed percent / pixel business, to avoid browser errors:
773
+ put "px" where needed, avoid where not.
774
+
775
+ Bob Hanson, 1/2010
776
+ Fixed inline escape changing returns to |
777
+ */
778
+ with (_jmol) {
779
+ nameSuffix == undefined && (nameSuffix = appletCount);
780
+ appletSuffixes.push(nameSuffix);
781
+ ++appletCount;
782
+ script || (script = "select *");
783
+ var sz = _jmolGetAppletSize(size);
784
+ var widthAndHeight = " width='" + sz[0] + "' height='" + sz[1] + "' ";
785
+ var tHeader, tFooter;
786
+ codebase || jmolInitialize(".");
787
+ if (useIEObject || useHtml4Object) {
788
+ params.archive = archivePath;
789
+ params.mayscript = 'true';
790
+ params.codebase = codebase;
791
+ params.code = 'JmolApplet';
792
+ tHeader = "<span>" +
793
+ "<object name='jmolApplet" + nameSuffix +
794
+ "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
795
+ widthAndHeight + "\n";
796
+ tFooter = "</object></span>";
797
+ }
798
+ if (java_arguments)
799
+ params.java_arguments = java_arguments;
800
+ if (useIEObject) { // use MSFT IE6 object tag with .cab file reference
801
+ tHeader += " classid='" + windowsClassId + "'\n" +
802
+ (windowsCabUrl ? " codebase='" + windowsCabUrl + "'\n" : "") + ">\n";
803
+ } else if (useHtml4Object) { // use HTML4 object tag
804
+ tHeader += " type='application/x-java-applet'\n>\n";
805
+ /* " classid='java:JmolApplet'\n" + AH removed this
806
+ Chromium Issue 62076: Java Applets using an <object> with a classid paramater don't load.
807
+ http://code.google.com/p/chromium/issues/detail?id=62076
808
+ They say this is the correct behavior according to the spec, and there's no indication at this point
809
+ that WebKit will be changing the handling, so eventually Safari will acquire this behavior too.
810
+ Removing the classid parameter seems to be well tolerated by all browsers (even IE!).
811
+ */
812
+ } else { // use applet tag
813
+ tHeader = "<span>" +
814
+ "<applet name='jmolApplet" + nameSuffix +
815
+ "' id='jmolApplet" + nameSuffix + "' " + appletCssText + "\n" +
816
+ widthAndHeight + "\n" +
817
+ " code='JmolApplet'" +
818
+ " archive='" + archivePath + "' codebase='" + codebase + "'\n" +
819
+ " mayscript='true'>\n";
820
+ tFooter = "</applet></span>";
821
+ }
822
+ var visitJava;
823
+ if (useIEObject || useHtml4Object) {
824
+ var szX = "width:" + sz[0]
825
+ if ( szX.indexOf("%")==-1 ) szX+="px"
826
+ var szY = "height:" + sz[1]
827
+ if ( szY.indexOf("%")==-1 ) szY+="px"
828
+ visitJava =
829
+ "<p style='background-color:yellow; color:black; " +
830
+ szX + ";" + szY + ";" +
831
+ // why doesn't this vertical-align work?
832
+ "text-align:center;vertical-align:middle;'>\n" +
833
+ noJavaMsg +
834
+ "</p>";
835
+ } else {
836
+ visitJava =
837
+ "<table bgcolor='yellow'><tr>" +
838
+ "<td align='center' valign='middle' " + widthAndHeight + "><font color='black'>\n" +
839
+ noJavaMsg2 +
840
+ "</font></td></tr></table>";
841
+ }
842
+ params.loadInline = (inlineModel ? inlineModel : "");
843
+ params.script = (script ? _jmolSterilizeScript(script) : "");
844
+ var t = tHeader + _jmolParams() + visitJava + tFooter;
845
+ jmolSetTarget(nameSuffix);
846
+ ready["jmolApplet" + nameSuffix] = false;
847
+ if (_jmol.debugAlert)
848
+ alert(t);
849
+ return _jmolDocumentWrite(t);
850
+ }
851
+ }
852
+
853
+ function _jmolParams() {
854
+ var t = "";
855
+ for (var i in _jmol.params)
856
+ if(_jmol.params[i]!="")
857
+ t+=" <param name='"+i+"' value='"+_jmol.params[i]+"' />\n";
858
+ return t
859
+ }
860
+
861
+ function _jmolInitCheck() {
862
+ if (_jmol.initChecked)
863
+ return;
864
+ _jmol.initChecked = true;
865
+ jmolInitialize(defaultdir, defaultjar)
866
+ }
867
+
868
+ function _jmolCheckBrowser() {
869
+ with (_jmol) {
870
+ if (browserChecked)
871
+ return;
872
+ browserChecked = true;
873
+
874
+ if (isFullyCompliant)
875
+ return true;
876
+
877
+ if (checkBrowserAction == "redirect")
878
+ location.href = checkBrowserUrlOrMessage;
879
+ else if (checkBrowserAction == "popup")
880
+ _jmolPopup(checkBrowserUrlOrMessage);
881
+ else {
882
+ var msg = checkBrowserUrlOrMessage;
883
+ if (msg == null)
884
+ msg = "Your web browser is not fully compatible with Jmol\n\n" +
885
+ "browser: " + browser +
886
+ " version: " + browserVersion +
887
+ " os: " + os +
888
+ " isBrowserCompliant: " + isBrowserCompliant +
889
+ " isJavaCompliant: " + isJavaCompliant +
890
+ "\n\n" + ua;
891
+ alert(msg);
892
+ }
893
+ }
894
+ return false;
895
+ }
896
+
897
+ function jmolSetXHTML(id) {
898
+ _jmol.isXHTML = true
899
+ _jmol.XhtmlElement = null
900
+ _jmol.XhtmlAppendChild = false
901
+ if (id){
902
+ _jmol.XhtmlElement = document.getElementById(id)
903
+ _jmol.XhtmlAppendChild = true
904
+ }
905
+ }
906
+
907
+ function _jmolDocumentWrite(text) {
908
+ if (_jmol.currentDocument) {
909
+ if (_jmol.isXHTML && !_jmol.XhtmlElement) {
910
+ var s = document.getElementsByTagName("script")
911
+ _jmol.XhtmlElement = s.item(s.length - 1)
912
+ _jmol.XhtmlAppendChild = false
913
+ }
914
+ if (_jmol.XhtmlElement) {
915
+ _jmolDomDocumentWrite(text)
916
+ } else {
917
+ _jmol.currentDocument.write(text);
918
+ }
919
+ }
920
+ return text;
921
+ }
922
+
923
+ function _jmolDomDocumentWrite(data) {
924
+ var pt = 0
925
+ var Ptr = []
926
+ Ptr[0] = 0
927
+ while (Ptr[0] < data.length) {
928
+ var child = _jmolGetDomElement(data, Ptr)
929
+ if (!child)break
930
+ if (_jmol.XhtmlAppendChild)
931
+ _jmol.XhtmlElement.appendChild(child)
932
+ else
933
+ _jmol.XhtmlElement.parentNode.insertBefore(child, _jmol.XhtmlElement);
934
+ }
935
+ }
936
+ function _jmolGetDomElement(data, Ptr, closetag, lvel) {
937
+ var e = document.createElement("span")
938
+ e.innerHTML = data
939
+ Ptr[0] = data.length
940
+ return e
941
+
942
+ //unnecessary?
943
+
944
+ closetag || (closetag = "")
945
+ lvel || (lvel = 0)
946
+ var pt0 = Ptr[0]
947
+ var pt = pt0
948
+ while (pt < data.length && data.charAt(pt) != "<") pt++
949
+ if (pt != pt0) {
950
+ var text = data.substring(pt0, pt)
951
+ Ptr[0] = pt
952
+ return document.createTextNode(text)
953
+ }
954
+ pt0 = ++pt
955
+ var ch
956
+ while (pt < data.length && "\n\r\t >".indexOf(ch = data.charAt(pt)) < 0) pt++
957
+ var tagname = data.substring(pt0, pt)
958
+ var e = (tagname == closetag || tagname == "/" ? ""
959
+ : document.createElementNS ? document.createElementNS('http://www.w3.org/1999/xhtml', tagname)
960
+ : document.createElement(tagname));
961
+ if (ch == ">") {
962
+ Ptr[0] = ++pt
963
+ return e
964
+ }
965
+ while (pt < data.length && (ch = data.charAt(pt)) != ">") {
966
+ while (pt < data.length && "\n\r\t ".indexOf(ch = data.charAt(pt)) >= 0) pt++
967
+ pt0 = pt
968
+ while (pt < data.length && "\n\r\t =/>".indexOf(ch = data.charAt(pt)) < 0) pt++
969
+ var attrname = data.substring(pt0, pt).toLowerCase()
970
+ if (attrname && ch != "=")
971
+ e.setAttribute(attrname, "true")
972
+ while (pt < data.length && "\n\r\t ".indexOf(ch = data.charAt(pt)) >= 0) pt++
973
+ if (ch == "/") {
974
+ Ptr[0] = pt + 2
975
+ return e
976
+ } else if (ch == "=") {
977
+ var quote = data.charAt(++pt)
978
+ pt0 = ++pt
979
+ while (pt < data.length && (ch = data.charAt(pt)) != quote) pt++
980
+ var attrvalue = data.substring(pt0, pt)
981
+ e.setAttribute(attrname, attrvalue)
982
+ pt++
983
+ }
984
+ }
985
+ Ptr[0] = ++pt
986
+ while (Ptr[0] < data.length) {
987
+ var child = _jmolGetDomElement(data, Ptr, "/" + tagname, lvel+1)
988
+ if (!child)break
989
+ e.appendChild(child)
990
+ }
991
+ return e
992
+ }
993
+
994
+ function _jmolPopup(url) {
995
+ var popup = window.open(url, "JmolPopup",
996
+ "left=150,top=150,height=400,width=600," +
997
+ "directories=yes,location=yes,menubar=yes," +
998
+ "toolbar=yes," +
999
+ "resizable=yes,scrollbars=yes,status=yes");
1000
+ if (popup.focus)
1001
+ poup.focus();
1002
+ }
1003
+
1004
+ function _jmolReadyCallback(name) {
1005
+ if (_jmol.debugAlert)
1006
+ alert(name + " is ready");
1007
+ _jmol.ready["" + name] = true;
1008
+ }
1009
+
1010
+ function _jmolSterilizeScript(script) {
1011
+ script = script.replace(/'/g, "&#39;");
1012
+ if (_jmol.debugAlert)
1013
+ alert("script:\n" + script);
1014
+ return script;
1015
+ }
1016
+
1017
+ function _jmolSterilizeInline(model) {
1018
+ model = model.replace(/\r|\n|\r\n/g, (model.indexOf("|") >= 0 ? "\\/n" : "|")).replace(/'/g, "&#39;");
1019
+ if (_jmol.debugAlert)
1020
+ alert("inline model:\n" + model);
1021
+ return model;
1022
+ }
1023
+
1024
+ function _jmolRadio(script, labelHtml, isChecked, separatorHtml, groupName, id, title) {
1025
+ ++_jmol.radioCount;
1026
+ groupName != undefined && groupName != null || (groupName = "jmolRadioGroup" + (_jmol.radioGroupCount - 1));
1027
+ if (!script)
1028
+ return "";
1029
+ labelHtml != undefined && labelHtml != null || (labelHtml = script.substring(0, 32));
1030
+ separatorHtml || (separatorHtml = "")
1031
+ var scriptIndex = _jmolAddScript(script);
1032
+ var eospan = "</span>"
1033
+ var t = "<span id=\"span_"+id+"\""+(title ? " title=\"" + title + "\"":"")+"><input name='"
1034
+ + groupName + "' id='"+id+"' type='radio' onclick='_jmolClick(this," +
1035
+ scriptIndex + _jmol.targetText + ");return true;' onmouseover='_jmolMouseOver(" +
1036
+ scriptIndex + ");return true;' onmouseout='_jmolMouseOut()' " +
1037
+ (isChecked ? "checked='true' " : "") + _jmol.radioCssText + " />"
1038
+ if (labelHtml.toLowerCase().indexOf("<td>")>=0) {
1039
+ t += eospan
1040
+ eospan = "";
1041
+ }
1042
+ t += "<label for=\"" + id + "\">" + labelHtml + "</label>" +eospan + separatorHtml;
1043
+
1044
+ return t;
1045
+ }
1046
+
1047
+ function _jmolFindApplet(target) {
1048
+ // first look for the target in the current window
1049
+ var applet = _jmolFindAppletInWindow(_jmol.appletWindow != null ? _jmol.appletWindow : window, target);
1050
+ // THEN look for the target in child frames
1051
+ if (applet == undefined)
1052
+ applet = _jmolSearchFrames(window, target);
1053
+ // FINALLY look for the target in sibling frames
1054
+ if (applet == undefined)
1055
+ applet = _jmolSearchFrames(top, target); // look starting in top frame
1056
+ return applet;
1057
+ }
1058
+
1059
+ function _jmolGetApplet(targetSuffix){
1060
+ var target = "jmolApplet" + (targetSuffix ? targetSuffix : "0");
1061
+ var applet = _jmolFindApplet(target);
1062
+ if (applet) return applet
1063
+ _jmol.alerted || alert("could not find applet " + target);
1064
+ _jmol.alerted = true;
1065
+ return null
1066
+ }
1067
+
1068
+ function _jmolSearchFrames(win, target) {
1069
+ var applet;
1070
+ var frames = win.frames;
1071
+ if (frames && frames.length) { // look in all the frames below this window
1072
+ try{
1073
+ for (var i = 0; i < frames.length; ++i) {
1074
+ applet = _jmolSearchFrames(frames[i], target);
1075
+ if (applet)
1076
+ return applet;
1077
+ }
1078
+ }catch(e) {
1079
+ if (_jmol.debugAlert)
1080
+ alert("Jmol.js _jmolSearchFrames cannot access " + win.name + ".frame[" + i + "] consider using jmolSetAppletWindow()")
1081
+ }
1082
+ }
1083
+ return applet = _jmolFindAppletInWindow(win, target)
1084
+ }
1085
+
1086
+ function _jmolFindAppletInWindow(win, target) {
1087
+ var doc = win.document;
1088
+ if (doc.getElementById(target))
1089
+ return doc.getElementById(target);
1090
+ else if (doc.applets)
1091
+ return doc.applets[target];
1092
+ else
1093
+ return doc[target];
1094
+ }
1095
+
1096
+ function _jmolAddScript(script) {
1097
+ if (!script)
1098
+ return 0;
1099
+ var index = _jmol.scripts.length;
1100
+ _jmol.scripts[index] = script;
1101
+ return index;
1102
+ }
1103
+
1104
+ function _jmolClick(elementClicked, scriptIndex, targetSuffix) {
1105
+ _jmol.element = elementClicked;
1106
+ _jmolScriptExecute(elementClicked, _jmol.scripts[scriptIndex], targetSuffix);
1107
+ }
1108
+
1109
+ function _jmolMenuSelected(menuObject, targetSuffix) {
1110
+ var scriptIndex = menuObject.value;
1111
+ if (scriptIndex != undefined) {
1112
+ _jmolScriptExecute(menuObject, _jmol.scripts[scriptIndex], targetSuffix);
1113
+ return;
1114
+ }
1115
+ var len = menuObject.length;
1116
+ if (typeof len == "number") {
1117
+ for (var i = 0; i < len; ++i) {
1118
+ if (menuObject[i].selected) {
1119
+ _jmolClick(menuObject[i], menuObject[i].value, targetSuffix);
1120
+ return;
1121
+ }
1122
+ }
1123
+ }
1124
+ alert("?Que? menu selected bug #8734");
1125
+ }
1126
+
1127
+
1128
+ _jmol.checkboxMasters = {};
1129
+ _jmol.checkboxItems = {};
1130
+
1131
+ function jmolSetCheckboxGroup(chkMaster,chkBox) {
1132
+ var id = chkMaster;
1133
+ if(typeof(id)=="number")id = "jmolCheckbox" + id;
1134
+ chkMaster = document.getElementById(id);
1135
+ if (!chkMaster)alert("jmolSetCheckboxGroup: master checkbox not found: " + id);
1136
+ var m = _jmol.checkboxMasters[id] = {};
1137
+ m.chkMaster = chkMaster;
1138
+ m.chkGroup = {};
1139
+ for (var i = 1; i < arguments.length; i++){
1140
+ var id = arguments[i];
1141
+ if(typeof(id)=="number")id = "jmolCheckbox" + id;
1142
+ checkboxItem = document.getElementById(id);
1143
+ if (!checkboxItem)alert("jmolSetCheckboxGroup: group checkbox not found: " + id);
1144
+ m.chkGroup[id] = checkboxItem;
1145
+ _jmol.checkboxItems[id] = m;
1146
+ }
1147
+ }
1148
+
1149
+ function _jmolNotifyMaster(m){
1150
+ //called when a group item is checked
1151
+ var allOn = true;
1152
+ var allOff = true;
1153
+ for (var chkBox in m.chkGroup){
1154
+ if(m.chkGroup[chkBox].checked)
1155
+ allOff = false;
1156
+ else
1157
+ allOn = false;
1158
+ }
1159
+ if (allOn)m.chkMaster.checked = true;
1160
+ if (allOff)m.chkMaster.checked = false;
1161
+ if ((allOn || allOff) && _jmol.checkboxItems[m.chkMaster.id])
1162
+ _jmolNotifyMaster(_jmol.checkboxItems[m.chkMaster.id])
1163
+ }
1164
+
1165
+ function _jmolNotifyGroup(m, isOn){
1166
+ //called when a master item is checked
1167
+ for (var chkBox in m.chkGroup){
1168
+ var item = m.chkGroup[chkBox]
1169
+ item.checked = isOn;
1170
+ if (_jmol.checkboxMasters[item.id])
1171
+ _jmolNotifyGroup(_jmol.checkboxMasters[item.id], isOn)
1172
+ }
1173
+ }
1174
+
1175
+ function _jmolCbClick(ckbox, whenChecked, whenUnchecked, targetSuffix) {
1176
+ _jmol.control = ckbox
1177
+ _jmolClick(ckbox, ckbox.checked ? whenChecked : whenUnchecked, targetSuffix);
1178
+ if(_jmol.checkboxMasters[ckbox.id])
1179
+ _jmolNotifyGroup(_jmol.checkboxMasters[ckbox.id], ckbox.checked)
1180
+ if(_jmol.checkboxItems[ckbox.id])
1181
+ _jmolNotifyMaster(_jmol.checkboxItems[ckbox.id])
1182
+ }
1183
+
1184
+ function _jmolCbOver(ckbox, whenChecked, whenUnchecked) {
1185
+ window.status = _jmol.scripts[ckbox.checked ? whenUnchecked : whenChecked];
1186
+ }
1187
+
1188
+ function _jmolMouseOver(scriptIndex) {
1189
+ window.status = _jmol.scripts[scriptIndex];
1190
+ }
1191
+
1192
+ function _jmolMouseOut() {
1193
+ window.status = " ";
1194
+ return true;
1195
+ }
1196
+
1197
+ function _jmolSetCodebase(codebase) {
1198
+ _jmol.codebase = codebase ? codebase : ".";
1199
+ if (_jmol.debugAlert)
1200
+ alert("jmolCodebase=" + _jmol.codebase);
1201
+ }
1202
+
1203
+ function _jmolOnloadResetForms() {
1204
+ // must be evaluated ONLY once
1205
+ _jmol.previousOnloadHandler = window.onload;
1206
+ window.onload =
1207
+ function() {
1208
+ with (_jmol) {
1209
+ if (buttonCount+checkboxCount+menuCount+radioCount+radioGroupCount > 0) {
1210
+ var forms = document.forms;
1211
+ for (var i = forms.length; --i >= 0; )
1212
+ forms[i].reset();
1213
+ }
1214
+ if (previousOnloadHandler)
1215
+ previousOnloadHandler();
1216
+ }
1217
+ }
1218
+ }
1219
+
1220
+ ////////////////////////////////////
1221
+ /////extensions for getProperty/////
1222
+ ////////////////////////////////////
1223
+
1224
+
1225
+ function _jmolEvalJSON(s,key){
1226
+ s=s+""
1227
+ if(!s)return []
1228
+ if(s.charAt(0)!="{"){
1229
+ if(s.indexOf(" | ")>=0)s=s.replace(/\ \|\ /g, "\n")
1230
+ return s
1231
+ }
1232
+ var A = eval("("+s+")")
1233
+ if(!A)return
1234
+ if(key && A[key])A=A[key]
1235
+ return A
1236
+ }
1237
+
1238
+ function _jmolEnumerateObject(A,key){
1239
+ var sout=""
1240
+ if(typeof(A) == "string" && A!="null"){
1241
+ sout+="\n"+key+"=\""+A+"\""
1242
+ }else if(!isNaN(A)||A==null){
1243
+ sout+="\n"+key+"="+(A+""==""?"null":A)
1244
+ }else if(A.length){
1245
+ sout+=key+"=[]"
1246
+ for(var i=0;i<A.length;i++){
1247
+ sout+="\n"
1248
+ if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
1249
+ sout+=_jmolEnumerateObject(A[i],key+"["+i+"]")
1250
+ }else{
1251
+ sout+=key+"["+i+"]="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
1252
+ }
1253
+ }
1254
+ }else{
1255
+ if(key != ""){
1256
+ sout+=key+"={}"
1257
+ key+="."
1258
+ }
1259
+
1260
+ for(var i in A){
1261
+ sout+="\n"
1262
+ if(typeof(A[i]) == "object"||typeof(A[i]) == "array"){
1263
+ sout+=_jmolEnumerateObject(A[i],key+i)
1264
+ }else{
1265
+ sout+=key+i+"="+(typeof(A[i]) == "string" && A[i]!="null"?"\""+A[i].replace(/\"/g,"\\\"")+"\"":A[i])
1266
+ }
1267
+ }
1268
+ }
1269
+ return sout
1270
+ }
1271
+
1272
+
1273
+ function _jmolSortKey0(a,b){
1274
+ return (a[0]<b[0]?1:a[0]>b[0]?-1:0)
1275
+ }
1276
+
1277
+ function _jmolSortMessages(A){
1278
+ if(!A || typeof(A)!="object")return []
1279
+ var B = []
1280
+ for(var i=A.length-1;i>=0;i--)for(var j=0;j<A[i].length;j++)B[B.length]=A[i][j]
1281
+ if(B.length == 0) return
1282
+ B=B.sort(_jmolSortKey0)
1283
+ return B
1284
+ }
1285
+
1286
+ /////////additional extensions //////////
1287
+
1288
+
1289
+ function _jmolDomScriptLoad(URL){
1290
+ //open(URL) //to debug
1291
+ _jmol.servercall=URL
1292
+ var node = document.getElementById("_jmolScriptNode")
1293
+ if (node && _jmol.browser!="msie"){
1294
+ document.getElementsByTagName("HEAD")[0].removeChild(node)
1295
+ node=null
1296
+ }
1297
+ if (node) {
1298
+ node.setAttribute("src",URL)
1299
+ } else {
1300
+ node=document.createElement("script")
1301
+ node.setAttribute("id","_jmolScriptNode")
1302
+ node.setAttribute("type","text/javascript")
1303
+ node.setAttribute("src",URL)
1304
+ document.getElementsByTagName("HEAD")[0].appendChild(node)
1305
+ }
1306
+ }
1307
+
1308
+
1309
+ function _jmolExtractPostData(url){
1310
+ S=url.split("&POST:")
1311
+ var s=""
1312
+ for(var i=1;i<S.length;i++){
1313
+ KV=S[i].split("=")
1314
+ s+="&POSTKEY"+i+"="+KV[0]
1315
+ s+="&POSTVALUE"+i+"="+KV[1]
1316
+ }
1317
+ return "&url="+escape(S[0])+s
1318
+ }
1319
+
1320
+ function _jmolLoadModel(targetSuffix,remoteURL,array,isError,errorMessage){
1321
+ //called by server, but in client
1322
+ //overload this function to customize return
1323
+ _jmol.remoteURL=remoteURL
1324
+ isError && alert(errorMessage)
1325
+ jmolLoadInlineScript(array.join("\n"),_jmol.optionalscript,targetSuffix)
1326
+ }
1327
+
1328
+ //////////user property/status functions/////////
1329
+
1330
+ function jmolGetStatus(strStatus,targetSuffix){
1331
+ return _jmolSortMessages(jmolGetPropertyAsArray("jmolStatus",strStatus,targetSuffix))
1332
+ }
1333
+
1334
+ function jmolGetPropertyAsArray(sKey,sValue,targetSuffix) {
1335
+ return _jmolEvalJSON(jmolGetPropertyAsJSON(sKey,sValue,targetSuffix),sKey)
1336
+ }
1337
+
1338
+ function jmolGetPropertyAsString(sKey,sValue,targetSuffix) {
1339
+ var applet = _jmolGetApplet(targetSuffix);
1340
+ sValue == undefined && (sValue="");
1341
+ return (applet ? applet.getPropertyAsString(sKey,sValue) + "" : "")
1342
+ }
1343
+
1344
+ function jmolGetPropertyAsJSON(sKey,sValue,targetSuffix) {
1345
+ sValue == undefined && (sValue = "")
1346
+ var applet = _jmolGetApplet(targetSuffix);
1347
+ try {
1348
+ return (applet ? applet.getPropertyAsJSON(sKey,sValue) + "" : "")
1349
+ } catch(e) {
1350
+ return ""
1351
+ }
1352
+ }
1353
+
1354
+ function jmolGetPropertyAsJavaObject(sKey,sValue,targetSuffix) {
1355
+ sValue == undefined && (sValue = "")
1356
+ var applet = _jmolGetApplet(targetSuffix);
1357
+ return (applet ? applet.getProperty(sKey,sValue) : null)
1358
+ }
1359
+
1360
+
1361
+ function jmolDecodeJSON(s) {
1362
+ return _jmolEnumerateObject(_jmolEvalJSON(s),"")
1363
+ }
1364
+
1365
+
1366
+ ///////// synchronous scripting ////////
1367
+
1368
+ function jmolScriptWait(script, targetSuffix) {
1369
+ targetSuffix == undefined && (targetSuffix="0")
1370
+ var Ret=jmolScriptWaitAsArray(script, targetSuffix)
1371
+ var s = ""
1372
+ for(var i=Ret.length;--i>=0;)
1373
+ for(var j=0;j< Ret[i].length;j++)
1374
+ s+=Ret[i][j]+"\n"
1375
+ return s
1376
+ }
1377
+
1378
+ function jmolScriptWaitOutput(script, targetSuffix) {
1379
+ targetSuffix == undefined && (targetSuffix="0")
1380
+ var ret = ""
1381
+ try{
1382
+ if (script) {
1383
+ _jmolCheckBrowser();
1384
+ var applet=_jmolGetApplet(targetSuffix);
1385
+ if (applet) ret += applet.scriptWaitOutput(script);
1386
+ }
1387
+ }catch(e){
1388
+ }
1389
+ return ret;
1390
+ }
1391
+
1392
+ function jmolEvaluate(molecularMath, targetSuffix) {
1393
+
1394
+ //carries out molecular math on a model
1395
+
1396
+ targetSuffix == undefined && (targetSuffix="0")
1397
+ var result = "" + jmolGetPropertyAsJavaObject("evaluate", molecularMath, targetSuffix);
1398
+ var s = result.replace(/\-*\d+/,"")
1399
+ if (s == "" && !isNaN(parseInt(result)))return parseInt(result);
1400
+ var s = result.replace(/\-*\d*\.\d*/,"")
1401
+ if (s == "" && !isNaN(parseFloat(result)))return parseFloat(result);
1402
+ return result;
1403
+ }
1404
+
1405
+ function jmolScriptEcho(script, targetSuffix) {
1406
+ // returns a newline-separated list of all echos from a script
1407
+ targetSuffix == undefined && (targetSuffix="0")
1408
+ var Ret=jmolScriptWaitAsArray(script, targetSuffix)
1409
+ var s = ""
1410
+ for(var i=Ret.length;--i>=0;)
1411
+ for(var j=Ret[i].length;--j>=0;)
1412
+ if (Ret[i][j][1] == "scriptEcho")s+=Ret[i][j][3]+"\n"
1413
+ return s.replace(/ \| /g, "\n")
1414
+ }
1415
+
1416
+
1417
+ function jmolScriptMessage(script, targetSuffix) {
1418
+ // returns a newline-separated list of all messages from a script, ending with "script completed\n"
1419
+ targetSuffix == undefined && (targetSuffix="0")
1420
+ var Ret=jmolScriptWaitAsArray(script, targetSuffix)
1421
+ var s = ""
1422
+ for(var i=Ret.length;--i>=0;)
1423
+ for(var j=Ret[i].length;--j>=0;)
1424
+ if (Ret[i][j][1] == "scriptStatus")s+=Ret[i][j][3]+"\n"
1425
+ return s.replace(/ \| /g, "\n")
1426
+ }
1427
+
1428
+
1429
+ function jmolScriptWaitAsArray(script, targetSuffix) {
1430
+ var ret = ""
1431
+ try{
1432
+ jmolGetStatus("scriptEcho,scriptMessage,scriptStatus,scriptError",targetSuffix)
1433
+ if (script) {
1434
+ _jmolCheckBrowser();
1435
+ var applet=_jmolGetApplet(targetSuffix);
1436
+ if (applet) ret += applet.scriptWait(script);
1437
+ ret = _jmolEvalJSON(ret,"jmolStatus")
1438
+ if(typeof ret == "object")
1439
+ return ret
1440
+ }
1441
+ }catch(e){
1442
+ }
1443
+ return [[ret]]
1444
+ }
1445
+
1446
+
1447
+
1448
+ //////////// save/restore orientation /////////////
1449
+
1450
+ function jmolSaveOrientation(id, targetSuffix) {
1451
+ targetSuffix == undefined && (targetSuffix="0")
1452
+ return _jmol["savedOrientation"+id] = jmolGetPropertyAsArray("orientationInfo","info",targetSuffix).moveTo
1453
+ }
1454
+
1455
+ function jmolRestoreOrientation(id, targetSuffix) {
1456
+ targetSuffix == undefined && (targetSuffix="0")
1457
+ var s=_jmol["savedOrientation"+id]
1458
+ if (!s || s == "")return
1459
+ s=s.replace(/1\.0/,"0")
1460
+ return jmolScriptWait(s,targetSuffix)
1461
+ }
1462
+
1463
+ function jmolRestoreOrientationDelayed(id, delay, targetSuffix) {
1464
+ arguments.length < 2 && (delay=1)
1465
+ targetSuffix == undefined && (targetSuffix="0")
1466
+ var s=_jmol["savedOrientation"+id]
1467
+ if (!s || s == "")return
1468
+ s=s.replace(/1\.0/,delay)
1469
+ return jmolScriptWait(s,targetSuffix)
1470
+ }
1471
+
1472
+ //////////// add parameter /////////////
1473
+ /*
1474
+ * for adding callbacks or other parameters. Use:
1475
+
1476
+ jmolSetDocument(0)
1477
+ var s= jmolApplet(....)
1478
+ s = jmolAppletAddParam(s,"messageCallback", "myFunctionName")
1479
+ document.write(s)
1480
+ jmolSetDocument(document) // if you want to then write buttons and such normally
1481
+
1482
+ */
1483
+
1484
+ function jmolAppletAddParam(appletCode,name,value){
1485
+ return (value == "" ? appletCode : appletCode.replace(/\<param/,"\n<param name='"+name+"' value='"+value+"' />\n<param"))
1486
+ }
1487
+
1488
+ ///////////////auto load Research Consortium for Structural Biology (RCSB) data ///////////
1489
+
1490
+ function jmolLoadAjax_STOLAF_RCSB(fileformat,pdbid,optionalscript,targetSuffix){
1491
+
1492
+ _jmol.thismodel || (_jmol.thismodel = "1crn")
1493
+ _jmol.serverURL || (_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm")
1494
+ _jmol.RCSBserver || (_jmol.RCSBserver="http://www.rcsb.org")
1495
+ _jmol.defaultURL_RCSB || (_jmol.defaultURL_RCSB=_jmol.RCSBserver+"/pdb/files/1CRN.CIF")
1496
+ fileformat || (fileformat="PDB")
1497
+ pdbid || (pdbid=prompt("Enter a 4-digit PDB ID:",_jmol.thismodel))
1498
+ if(!pdbid || pdbid.length != 4)return ""
1499
+ targetSuffix || (targetSuffix="0")
1500
+ optionalscript || (optionalscript="")
1501
+ var url=_jmol.defaultURL_RCSB.replace(/1CRN/g,pdbid.toUpperCase())
1502
+ fileformat=="CIF" || (url=url.replace(/CIF/,fileformat))
1503
+ _jmol.optionalscript=optionalscript
1504
+ _jmol.thismodel=pdbid
1505
+ _jmol.thistargetsuffix=targetSuffix
1506
+ _jmol.thisurl=url
1507
+ _jmol.modelArray = []
1508
+ url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
1509
+ _jmolDomScriptLoad(url)
1510
+ return url
1511
+ }
1512
+
1513
+
1514
+ ///////////////auto load NIH CACTVS data -- compound name or SMILES ///////////
1515
+
1516
+ function jmolLoadAjax_STOLAF_NIH(compoundid,optionalscript,targetSuffix){
1517
+ _jmol.thismodel || (_jmol.thismodel = "aspirin")
1518
+ _jmol.serverURL || (_jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm")
1519
+ _jmol.defaultURL_NIH || (_jmol.defaultURL_NIH="http://cactus.nci.nih.gov/chemical/structure/FILE/file?format=sdf&get3d=True")
1520
+ compoundid || (compoundid=prompt("Enter a compound name or a SMILES string:",_jmol.thismodel))
1521
+ if(!compoundid)return ""
1522
+ targetSuffix || (targetSuffix="0")
1523
+ optionalscript || (optionalscript="")
1524
+ var url=_jmol.defaultURL_NIH.replace(/FILE/g,compoundid)
1525
+ _jmol.optionalscript=optionalscript
1526
+ _jmol.thismodel=compoundid
1527
+ _jmol.thistargetsuffix=targetSuffix
1528
+ _jmol.thisurl=url
1529
+ _jmol.modelArray = []
1530
+ url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
1531
+ _jmolDomScriptLoad(url)
1532
+ return url
1533
+ }
1534
+
1535
+
1536
+ /////////////// St. Olaf College AJAX server -- ANY URL ///////////
1537
+
1538
+ function jmolLoadAjax_STOLAF_ANY(url, userid, optionalscript,targetSuffix){
1539
+ _jmol.serverURL="http://fusion.stolaf.edu/chemistry/jmol/getajaxjs.cfm"
1540
+ _jmol.thisurlANY || (_jmol.thisurlANY = "http://www.stolaf.edu/depts/chemistry/mo/struc/data/ycp3-1.mol")
1541
+ url || (url=prompt("Enter any (uncompressed file) URL:", _jmol.thisurlANY))
1542
+ userid || (userid="0")
1543
+ targetSuffix || (targetSuffix="0")
1544
+ optionalscript || (optionalscript="")
1545
+ _jmol.optionalscript=optionalscript
1546
+ _jmol.thistargetsuffix=targetSuffix
1547
+ _jmol.modelArray = []
1548
+ _jmol.thisurl = url
1549
+ url=_jmol.serverURL+"?returnfunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix+_jmolExtractPostData(url)
1550
+ _jmolDomScriptLoad(url)
1551
+ }
1552
+
1553
+
1554
+ /////////////// Mineralogical Society of America (MSA) data /////////
1555
+
1556
+ function jmolLoadAjax_MSA(key,value,optionalscript,targetSuffix){
1557
+
1558
+ _jmol.thiskeyMSA || (_jmol.thiskeyMSA = "mineral")
1559
+ _jmol.thismodelMSA || (_jmol.thismodelMSA = "quartz")
1560
+ _jmol.ajaxURL_MSA || (_jmol.ajaxURL_MSA="http://rruff.geo.arizona.edu/AMS/result.php?mineral=quartz&viewing=ajaxjs")
1561
+ key || (key=prompt("Enter a field:", _jmol.thiskeyMSA))
1562
+ if(!key)return ""
1563
+ value || (value=prompt("Enter a "+key+":", _jmol.thismodelMSA))
1564
+ if(!value)return ""
1565
+ targetSuffix || (targetSuffix="0")
1566
+ optionalscript || (optionalscript="")
1567
+ optionalscript == 1 && (optionalscript='load "" {1 1 1}')
1568
+ var url=_jmol.ajaxURL_MSA.replace(/mineral/g,key).replace(/quartz/g,value)
1569
+ _jmol.optionalscript=optionalscript
1570
+ _jmol.thiskeyMSA=key
1571
+ _jmol.thismodelMSA=value
1572
+ _jmol.thistargetsuffix=targetSuffix
1573
+ _jmol.thisurl=url
1574
+ _jmol.modelArray = []
1575
+ loadModel=_jmolLoadModel
1576
+ _jmolDomScriptLoad(url)
1577
+ return url
1578
+ }
1579
+
1580
+
1581
+
1582
+ function jmolLoadAjaxJS(url, userid, optionalscript,targetSuffix){
1583
+ userid || (userid="0")
1584
+ targetSuffix || (targetSuffix="0")
1585
+ optionalscript || (optionalscript="")
1586
+ _jmol.optionalscript=optionalscript
1587
+ _jmol.thismodel=userid
1588
+ _jmol.thistargetsuffix=targetSuffix
1589
+ _jmol.modelArray = []
1590
+ _jmol.thisurl = url
1591
+ url+="&returnFunction=_jmolLoadModel&returnArray=_jmol.modelArray&id="+targetSuffix
1592
+ _jmolDomScriptLoad(url)
1593
+ }
1594
+
1595
+
1596
+ //// in case Jmol library has already been loaded:
1597
+
1598
+ }catch(e){}
1599
+
1600
+ ///////////////moving atoms //////////////
1601
+
1602
+ // HIGHLY experimental!!
1603
+
1604
+ function jmolSetAtomCoord(i,x,y,z,targetSuffix){
1605
+ _jmolCheckBrowser();
1606
+ var applet=_jmolGetApplet(targetSuffix);
1607
+ if (applet) applet.getProperty('jmolViewer').setAtomCoord(i,x,y,z)
1608
+ }
1609
+
1610
+ function jmolSetAtomCoordRelative(i,x,y,z,targetSuffix){
1611
+ _jmolCheckBrowser();
1612
+ var applet=_jmolGetApplet(targetSuffix);
1613
+ if (applet) applet.getProperty('jmolViewer').setAtomCoordRelative(i,x,y,z)
1614
+ }
1615
+
1616
+
1617
+ ///////////////applet fake for testing buttons/////////////
1618
+
1619
+
1620
+ if(_jmol.useNoApplet){
1621
+ jmolApplet = function(w){
1622
+ var s="<table style='background-color:black' width="+w+"><tr height="+w+">"
1623
+ +"<td align=center valign=center style='background-color:white'>"
1624
+ +"Applet would be here"
1625
+ +"<p><textarea id=fakeApplet rows=5 cols=50></textarea>"
1626
+ +"</td></tr></table>"
1627
+ return _jmolDocumentWrite(s)
1628
+ }
1629
+
1630
+ _jmolFindApplet = function(){return jmolApplet0}
1631
+
1632
+ jmolApplet0 = {
1633
+ script: function(script){document.getElementById("fakeApplet").value="\njmolScript:\n"+script}
1634
+ ,scriptWait: function(script){document.getElementById("fakeApplet").value="\njmolScriptWait:\n"+script}
1635
+ ,loadInline: function(data,script){document.getElementById("fakeApplet").value="\njmolLoadInline data:\n"+data+"\n\nscript:\n"+script}
1636
+ }
1637
+ }
1638
+
1639
+
1640
+ ///////////////////////////////////////////
1641
+
1642
+ // This should no longer be needed, jmolResizeApplet() is better; kept for backwards compatibility
1643
+ /*
1644
+ Resizes absolutely (pixels) or by percent of window (w or h 0.5 means 50%).
1645
+ targetSuffix is optional and defaults to zero (first applet in page).
1646
+ Both w and h are optional, but needed if you want to use targetSuffix.
1647
+ h defaults to w
1648
+ w defaults to 100% of window
1649
+ If either w or h is between 0 and 1, then it is taken as percent/100.
1650
+ If either w or h is greater than 1, then it is taken as a size (pixels).
1651
+ */
1652
+ function jmolResize(w,h,targetSuffix) {
1653
+ _jmol.alerted = true;
1654
+ var percentW = (!w ? 100 : w <= 1 && w > 0 ? w * 100 : 0);
1655
+ var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0);
1656
+ if (_jmol.browser=="msie") {
1657
+ var width=document.body.clientWidth;
1658
+ var height=document.body.clientHeight;
1659
+ } else {
1660
+ var netscapeScrollWidth=15;
1661
+ var width=window.innerWidth - netscapeScrollWidth;
1662
+ var height=window.innerHeight-netscapeScrollWidth;
1663
+ }
1664
+ var applet = _jmolGetApplet(targetSuffix);
1665
+ if(!applet)return;
1666
+ applet.style.width = (percentW ? width * percentW/100 : w)+"px";
1667
+ applet.style.height = (percentH ? height * percentH/100 : (h ? h : w))+"px";
1668
+ //title=width + " " + height + " " + (new Date());
1669
+ }
1670
+
1671
+ // 13 Jun 09 -- makes jmolResize() obsolete (kept for backwards compatibility)
1672
+ function jmolResizeApplet(size,targetSuffix) {
1673
+ // See _jmolGetAppletSize() for the formats accepted as size [same used by jmolApplet()]
1674
+ // Special case: an empty value for width or height is accepted, meaning no change in that dimension.
1675
+ _jmol.alerted = true;
1676
+ var applet = _jmolGetApplet(targetSuffix);
1677
+ if(!applet)return;
1678
+ var sz = _jmolGetAppletSize(size, "px");
1679
+ sz[0] && (applet.style.width = sz[0]);
1680
+ sz[1] && (applet.style.height = sz[1]);
1681
+ }
1682
+
1683
+ function _jmolGetAppletSize(size, units) {
1684
+ /* Accepts single number or 2-value array, each one can be one of:
1685
+ percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.)
1686
+ [width, height] array of strings is returned, with units added if specified.
1687
+ Percent is relative to container div or element (which should have explicitly set size).
1688
+ */
1689
+ var width, height;
1690
+ if ( (typeof size) == "object" && size != null ) {
1691
+ width = size[0]; height = size[1];
1692
+ } else {
1693
+ width = height = size;
1694
+ }
1695
+ return [_jmolFixDim(width, units), _jmolFixDim(height, units)];
1696
+ }
1697
+
1698
+ function _jmolFixDim(x, units) {
1699
+ var sx = "" + x;
1700
+ return (sx.length == 0 ? (units ? "" : _jmol.allowedJmolSize[2])
1701
+ : sx.indexOf("%") == sx.length-1 ? sx
1702
+ : (x = parseFloat(x)) <= 1 && x > 0 ? x * 100 + "%"
1703
+ : (isNaN(x = Math.floor(x)) ? _jmol.allowedJmolSize[2]
1704
+ : x < _jmol.allowedJmolSize[0] ? _jmol.allowedJmolSize[0]
1705
+ : x > _jmol.allowedJmolSize[1] ? _jmol.allowedJmolSize[1]
1706
+ : x) + (units ? units : ""));
1707
+ }
1708
+
1709
+
1710
+
1711
+