// GoExisting // Written by jon // // This is a script for Directory Opus. // See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information. // // Also see http://resource.dopus.com/viewtopic.php?p=129596#p129596 // // Called by Directory Opus to initialize the script function OnInit(initData) { //uid added via script wizard (do not change after publishing this script) var uid = "DE0EC74C-FBBE-4ED9-9EF4-770486B03541"; //resource center url added via script wizard (required for updating) var url = "http://resource.dopus.com/viewtopic.php?f=35&t=23972"; initData.name = "GoExisting"; initData.desc = "Opens specified path. If it already exists on either side of a dual lister, focus that tab."; initData.copyright = "written by jon"; initData.version = "1.0.2"; initData.default_enable = false; var cmd = initData.AddCommand(); cmd.name = "GoExisting"; cmd.method = "OnGoExisting"; cmd.desc = "Equivalent of Go NEWTAB=findexistingdual"; cmd.label = "GoExisting"; cmd.template = "PATH"; } // Implement the GoExisting command function OnGoExisting(scriptCmdData) { if (scriptCmdData.func.sourcetab.lister.dual == 0) scriptCmdData.func.command.RunCommand('Go "' + scriptCmdData.func.args.path + '" NEWTAB=findexisting'); else if (!DoGoExisting(scriptCmdData, scriptCmdData.func.sourcetab.lister.tabs)) scriptCmdData.func.command.RunCommand('Go "' + scriptCmdData.func.args.path + '" NEWTAB'); } function DoGoExisting(scriptCmdData, tabs) { var FSUtil = DOpus.FSUtil(); var e = new Enumerator(tabs); var index = new Array(0, 0); e.moveFirst(); while (!e.atEnd()) { if (FSUtil.ComparePath(e.item().path, scriptCmdData.func.args.path)) { if (scriptCmdData.func.sourcetab.right != e.item().right) scriptCmdData.func.command.AddLine('Set FOCUS=toggle'); scriptCmdData.func.command.AddLine('Go TABSELECT ' + index[e.item().right ? 1 : 0]); scriptCmdData.func.command.Run(); return true; } ++index[e.item().right ? 1 : 0]; e.moveNext(); } return false; } /////////////////////////////////////////////////////////////////////////////// function OnAboutScript(data){ //v0.1 var cmd = DOpus.Create.Command(); if (!cmd.Commandlist('s').exists("ScriptWizard")){ if (DOpus.Dlg.Request("The 'ScriptWizard' add-in has not been found.\n\n"+ "Install 'ScriptWizard' from [resource.dopus.com].\nThe add-in enables this dialog and also offers "+ "easy updating of scripts and many more.","Yes, take me there!|Cancel", "No About.. ", data.window)) cmd.RunCommand('http://resource.dopus.com/viewtopic.php?f=35&t=23179');} else cmd.RunCommand('ScriptWizard ABOUT WIN='+data.window+' FILE="'+Script.File+'"'); } //MD5 = "66157dec4acbf496d1338c284846839a"; DATE = "2015.06.19 - 14:32:08"