First off, I'm a complete novice with DOpus script — i.e., this is my first attempt at writing one.
Second, I know that DOpus has a "Synchronize left-to-right" option, but that's not quite what I'm after.
I would like a script that warns if the Left Lister is not the active Lister before each Synch operation is executed. There are many occasions where I move from left to right, clicking checkboxes, hiding items that won't be synched, etc., and I want to ensure that during that process, I don't inadvertently synch in the wrong direction (unless I explicitly choose to do so).
My first issue is that I can't seem to get the version, description, etc., to show up in the Script Management dialog. I choose File > Install, but the Version doesn't appear in the Install Script dialog; and if I choose OK to install the script, the script doesn't appear in the Script Management dialog, even though I get a "Script installed successfully" message.
Second, could someone please confirm that the script functionality looks correct?
So with all that said, here's my first kick at the script (which I haven't tried running yet):
function OnInit(initData) {
initData.name = "Check Sync Left"
initData.version = "0.1.0"
initData.author = "Trevor Morris"
initData.desc = "Checks if the Left Lister is the active Lister before starting a synchronization."
initData.default_enable = true;
}
function OnBeforeCommand(scriptCmdData) {
// ensure the command is Sync
if (scriptCmdData.func.command.name.toLowerCase() !== 'sync') return;
// get the Listers
var leftLister = scriptCmdData.func.sourcetab.lister;
var activeLister = DOpus.listers.lastactive;
// compare the active Lister with the Left Lister
if (leftLister != activeLister) {
// confirmation dialog
var dlg = DOpus.Dlg;
dlg.window = activeLister;
dlg.message = "The Left Lister is not the active Lister.\n\nDo you want to proceed with synchronization?";
dlg.buttons = "Yes|No";
dlg.icon = "warning";
var result = dlg.Show();
// abort Sync if "No" is selected
if (result == 2) {
scriptCmdData.func.command.RunCommand("@abort");
}
}
}
Thanks!