-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync2.htm
More file actions
155 lines (136 loc) · 5.22 KB
/
Copy pathsync2.htm
File metadata and controls
155 lines (136 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="JSmol.min.js"></script>
<script type="text/javascript" src=js/Jmol2.js></script>
<script type="text/javascript">
// demonstrating applet synchronization as well as using "legacy" Jmol.js calls.
// Jmol.info could be moved into Jmol2.js for sites that have many pages.
Jmol.Info = {
jarPath: "..",
jarFile: "JmolApplet0.jar",
j2sPath: "j2s",
use: "HTML5", // could be JAVA or HTML5
disableJ2SLoadMonitor: false,
disableInitialConsole: true
}
//Jmol._debugCode = true
function doLoad() {
document.getElementById("info").reset()
}
function sync() {
var syncing = document.getElementById("drive").checked
var s = (syncing ? "sync * on;sync * \"set syncMouse TRUE\"": "sync * off")
jmolScript(s, "A");
}
</script>
</head>
<body onload = doLoad()>
<table border = 1 cellpadding=10>
<tr>
<td>
<form id=info>
<input type=checkbox id=drive onClick=sync() accessKey="1">Synchronize
</form>
<script>jmolApplet(200,"load data/1crn.pdb;cartoon on;color cartoon structure", "A")</script>
<br>File-derived structure
<br><br><br>
<script>
jmolApplet(200,"load data/1crn.pdb;calculate structure;cartoon on;color cartoon structure", "B");
</script>
<br>Jmol-derived structure
</td>
<td>
This page demonstrates how to synchronize applets in Jmol.
The two applets are jmolAppletA and jmolAppletB. Once the checkbox is checked, going to either one controls the other.
The command used here is simply:
<pre>
<code>
function sync() {
var syncing = document.getElementById("drive").checked
var s = (syncing ? 'sync * on; sync * "set syncMouse true"': 'sync * off')
jmolScript(s, "A");
}
</pre>
Alternatively, we could have used:
<br><br>
<code><a href='javascript:jmolScript("sync . ON;sync > SLAVE", "A")'>jmolScript("sync . ON;sync > SLAVE", "A")</a></code>
<br><br>
which would cause only the applet on the top to do the controlling, but allowed the bottom applet to be moved independently of that control.
Also, if you open a <a href='javascript:jmolScript("console","A")'>console</a> on one, you can give commands to the other using something like:
<pre>
<code>
<a href='javascript:jmolScript("sync > \"background black\"","A")'>sync > "background black"</a>
</code>
</pre>
The ">" means "all other synchronized applets".
Other options include "*" (all synchronized applets)
and "." (only this applet, if it is synchronized).
In addition, you can specify the applet by its extension, "A" or "B", or by its full name, "jmolAppletA" or "jmolAppletB" in this case.
<br><br>
Starting with Jmol 11.6, you can also use the <b>script</b> command with the APPLET option to send scripts to one or more applets. This operation is independent of the state of sync being ON or OFF.
<pre>
<code>
<a href='javascript:jmolScript("script APPLET * \"background yellow\"","A")'>script APPLET * "background yellow"</a>
</code>
</pre>
<br><br>
Also new in Jmol 11.6, you can use the Jmol math script() function to get information from another applet. Simply indicate the target applet as a second parameter to the script command. For example, from Applet A's <a href='javascript:jmolScript("console","A")'>console</a>, type:
<pre>
<code>
print script("show orientation","B")
</code>
</pre>
</td>
</tr>
<tr>
<td colspan=3>
<pre>
Jmol version=11.3.9
# new feature: synchronization of applets using Jmol scripts:
#
# sync .|>|*|appletId[syncId] ON|OFF|SLAVE|command
#
# The sync command allows two or more applets to be synchronized in
# terms of orientation. Move one with the mouse, and the other moves as well.
# In addition, the sync command allows ANY command to be sent to one or more
# other applets directly, without the intervention of JavaScript.
#
# Applets are identified by appletId (jmolApplet0, for instance)
# along with an optional bracketed sync group identifier -- generally a random
# number that identifies the page containing the controlling applet. If the
# syncId is not given, then the ID for the page containing the controlling applet
# is used. This feature is important for cross-frame synchronization only.
#
#
# . this applet only
# > all applets except this one
# * all applets
# appletId id of a specific applet
# [syncId] (optional) a unique string of digits -- brackets included
#
# ON sync as driver (default)
# OFF turn sync off
# SLAVE turn sync on, but not as driver
# command command to send
#
# for example:
#
# sync * # synchronize all applets as drivers
# sync jmolApplet1 #syncs this applet with jmolApplet1 both as drivers
# sync > "set echo top left;echo OK" # sends OK to top left of all OTHER applets
# sync jmolApplet2[254678942] OFF # turns sync off for an applet ON A DIFFERENT PAGE
# # or in a different FRAME
# sync . OFF # turns sync off for this applet
#
# new Jmol.js feature: jmolGetSyncId(); jmolSetSyncId(id);
# allows control over the sync ID via javascript. jmolSetSyncId(id)
# should be called prior to jmolApplet() and should incorporate some sort of
# random digits and no space characters. (A number is good.)
# This should only be necessary for multi-frame pages.
# -----------------------------------------------------------------------------
</pre>
</td></tr>
</table>
</body>
</html>