Synchronize

File-derived structure


Jmol-derived structure
This page demonstrates a new way 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:

function sync() {
 var syncing = document.getElementById("drive").checked
 if(syncing)
   
 else
   
}
Note that with this setting, only the user's mouse movements are synchronized. You can still give independent orientation commands to each applet. For example, to jmolAppletA: . Alternatively, we could have forced the orientations of the two applets to coincide at all times using



You can also set the syncing so that commands given one applet, such as or get sent to the other applet as well, but mouse movements and orientation are not synchronized.



Now rotate one of the applets with the mouse. Note that they are independent. Still, commands such as and sent to one applet are applied to both applets. Setting both syncMouse and syncScript ON allows you to both synchronize mouse movements and synchronize scripting:



The "*" above means "all applets". We can set the synchronization to be directional using "." to indicate "this applet" and ">" to mean "all other applets". The following code sets the top applet to be the controller and the bottom applet to be the follower with full orientation syncing.



If you open a on jmolAppletA, you can give commands to the other applet, all applets, or just that applet using something like:



In these examples the indicated commands are sent to jmolAppletA (the top applet) only.
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. 
# -----------------------------------------------------------------------------