Below is simple JScript code I created for a custom ‘Add Folder Alias’ button in DOpus. The purpose of the code is to allow for a folder alias to be quickly created for the path of the currently selected tab. I simply navigate to a directory/folder I plan to alias and then click the ‘Add Folder Alias’ button to automatically insert the file path into a simple dialog box. The code is simple and does not have any checks or error handling (like saving without an alias name or doing something weird with the alias path). The JScript and resource code is below.
JScript code
/** @abstract JScript to create a folder alias (with the path defaulting to the currectly selected tab) @author w. Patrick Gale (May 2018) Scripted for Dopus version 12 This script could be integrated with the code from https://resource.dopus.com/t/command-to-edit-folder-aliases/26037 */ var dlg = DOpus.Dlg; dlg.template = "alias"; dlg.detach = true; dlg.Show(); var lister = DOpus.listers.LastActive; dlg.Control("aliasPath").value=lister.activetab.path; // default the alias path the currently selected tab var closeDialog; while (!closeDialog) { var Msg = dlg.GetMsg(); if (!Msg.result) break; switch (Msg.control) { case "btnSave" : onDialogSaveAlias(dlg); closeDialog = true; break; } } // save the alias name and path function onDialogSaveAlias(dlg) { var name = dlg.Control("aliasName").value; var path = dlg.Control("aliasPath").value; DOpus.aliases.Add(name, path); }
Script resources/template
<resources> <resource name="alias" type="dialog"> <dialog fontsize="8" height="102" lang="english" resize="yes" standard_buttons="cancel" title="Add a folder alias" width="354"> <control halign="left" height="8" name="static1" title="Alias name:" type="static" width="44" x="12" y="9" /> <control halign="left" height="12" name="aliasName" tip="Enter a name for the alias without the leading slash" type="edit" width="183" x="12" y="18" /> <control halign="left" height="8" name="static2" title="Path:" type="static" width="21" x="12" y="40" /> <control halign="left" height="12" name="aliasPath" type="edit" width="323" x="12" y="49" /> <control default="yes" height="14" name="btnSave" title="Save" type="button" width="50" x="247" y="84" /> </dialog> </resource> </resources>