OverrideFormats - an event based DO extension, which allows to override the folder format chosen by DO (or switch viewmode and columns only).
Since v0.3, the expression syntax has changed. Now functions are used to set view/format etc.
Description:
This extends the currently available content-type detection in DO by also taking the number of folders and files into account (e.g.). You can configure simple expressions (rules), to define when to use what viewmode or folder-format. So in case you always want folders containing more than 1000 files to use details mode, here you go.
Features:
- Black listing of folders (regex based)
- White listing of folders (regex based)
- Javascript expressions to define rules
- Call additional commands after folderchange
- Debug output (to help nail down any problems with black/white lists and your expressions)
Usage:
The most important thing to know is, how to setup things in the scripts config section under "Expressions". There, you have predefined getter-variables to check the situation. These are "data" (=OnBeforeFolderChangeData), "folderCount", "fileCount", "curView" and "curPath" (which is the DO path object). There's an ifPath() and ifLabel() function as well to tests for paths and drive labels easily (watch default expression for example).
To override a format, there are several function available to modifiy the lister appearance since v0.3:
addCol() - to add a column
remCol() - to remove a column
setView() - to set a view mod (accepts any option of the "Set VIEW" command)
setFormat() - to set a folder format (accepts any option of "Set FORMAT" or "Set CONTENTFORMAT")
setPat() - to switch a path
noQuit() - to not quit on evaluation
Watch these two examples..
//use details view, if more than 3 folders)
folderCount>3 && setView('details')
//switch path to C:\ for empty folders o)
folderCount==0 && fileCount==0 && setPath('C:\\')
These expressions need to be valid javascript code.
Config-Notes:
I won't go into details on how to setup the black and whitelists for folders, you can disable these lists completly or simply put regular expressions in there to restrict the overrider to special locations. There are some sensible regular expressions already included. In case you mess up an expression or folderlist, you'll find errors in the console if debug output is enabled. So go and check this place in case things do not work as expected. If enabled, the whitelist is going to override the blacklist.
Demo-Output - showing all crucial details and expression evaluation results:
Installation:
To install the script, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts.
Comments and bug reports welcome. o)
cya, tbone
Download:
-
Latest: v0.3.2 - prevent exception for "empty" command object, ifPath() method non-casesensitive:
Event.GUI_OverrideFormats.js.txt (37.7 KB) -
v0.3.1 - added ifLabel() to enable format/column/viewmode changes for specific drivelabels:
Event.GUI_OverrideFormats.js.txt (36.9 KB) -
v0.3 - usage of data.tab.format.locked, supports onafterfolderchange event, allows adding/removing of columns, supports updates/scriptwizard:
Event.GUI_OverrideFormats.js.txt (18.1 KB)