//v0.1 - o4/2o15 //- initial //v0.3 - o5/2o15 //- new feature "ITEM", select item (supports full paths if the USEPATH switch is used, // which doesn't work with the native select) //- new feature "TOVAR", save current selection to memory (persistent storage) //- new feature "TOFILE", save current selection to file //- new feature "FROMVAR", load selection from memory //- new feature "NTH", select every n-th item //- new feature "RANDOM", select items randomly (formerly known as SelectRandom script command) //- new feature "LINEAR", select items linear (same as RANDOM, but not random o) //- new feature "AUTO", trigger for autoselection (simulate onafterfolderchange) //- new feature "SIMILARMETA", select files with similar meta data //- new feature "SIMILARMETAJS", select files with similar meta data using a jscript snippet //- new feature "FILTERDROP", un/select, un/hide items by choosing a filter from a dropdown //- new feature "FILTERLIST", un/select, un/hide items by choosing (multiple) filters from a list //- new switch "SKIPITEMSWITHPATH", skip items with paths when selecting from clip/file/mem //- new switch "SKIPITEMSWITHOUTPATH", skip items with no path when selecting from clip/file/mem //- new switch "USEPATH", select by full path instead of using only the names from clip/file/mem //- new option "PT" = pass through, to pass arguments through to the native select command //- new option "DESELECTNOMATCH", works like native DESELECTNOMATCH switch (deselects first) //- new option "NODESELECT", works like native @nodeselect modifier //- new option "APPEND", append selected items to files, memorized-variables, clipboard //- new option "GO", switches folder to the first item in clip/file/memory before selecting //- new option "MAKEVISIBLE", works like native MAKEVISIBLE switch (scroll into view), // but can also be used "standalone" to scroll to currently selected/checked items //- new option "EXACT", works like native EXACT switch (do not interpret pattern-chars) //- new option "XLOG", enable output and set level (defaults to normal if no value given) //Includes generic/enhanced variants of following addins: //- "SelectFromTxt (select files from text file)" (http://resource.dopus.com/viewtopic.php?f=35&t=23130) //- "Select every nth files in a lister" (http://resource.dopus.com/viewtopic.php?f=3&t=20185) //- "SelectRandom" (http://resource.dopus.com/viewtopic.php?f=35&t=23142) //- "Auto-select items when entering folders" (http://resource.dopus.com/viewtopic.php?f=35&t=24306) //- "Select by Filter buttons" (http://resource.dopus.com/viewtopic.php?f=35&t=22311) //- "Select Similar Dimensions" menu button" (http://resource.dopus.com/viewtopic.php?f=35&t=22428) //- "ScrollSelectionIntoView" (http://resource.dopus.com/viewtopic.php?f=35&t=22450) //v0.4 - o5/2o15 //- removed unused code, minor tweaks //- option SETTABVAR renamed to SETVAR //- option SETENVVAR renamed to SETENV //- new feature FROMVARDROP to easify picking of memorized selections //v0.4.1 - o5/2o15 //- no need for a selected item when using SIMILARMETAJS //v0.4.2 - o5/2o15 //- distance() function available for simple fuzzy selections //- new OPTION "JSBREAK" for custom rules on when to stop item selection/picking //- TOFILE and APPEND options now also work in conjunction with RANDOM/LINEAR //v0.4.3 - o6/2o15 //- MAKEVISIBLE fixed, threw error in previous upload //- JSBREAK finetuning: return true to stop item picking, false to skip item and null/undefined will select/pick //- JSFILTER performance gain //- Usage of Confighelper v1.2 and XLog 0.3 //v0.4.4 - o6/2o15 //- TOFILE/FROMFILE encoding-awareness added (did not always load selection-files correctly) //- new script config "AutoSelect.DeselectNoMatch" to deselect automatically selected first file //v0.4.5 - o6/2o15 //- the AUTO feature, to trigger auto-selection from commandline and not automatically by entering a folder, is now independent from the "AutoSelect" script configs (despite the list). //That means you can disable AutoSelect and still use it occasionally from a "SelectEx AUTO" button. AutoSelect.MakeVisible/DeselectNoMatch also don't apply anymore if invoked manually (use the regular switches for that). //issues //- error message "Variable uses an Automation type not supported in JScript ..." // when using an /M type argument (desired for ITEM arg) //-todo //- re-test clearfiles() problem on data.func.command in top of SelectArrayItems() /////////////////////////////////////////////////////////////////////////////// var template = //main features.. "FROMCLIP/S,FROMFILE/K,FROMVAR/O,FROMVARDROP/S,TOCLIP/S,TOFILE/K,TOVAR/O,ITEM/K,NTH/K,RANDOM/S,LINEAR/S,AUTO/S,SIMILARMETA/K,"+ "SIMILARMETAJS/K,FILTERDROP/O[,deselect,hide,hidenomatch],MAKEVISIBLE/O[checked],"+ //fromfile, fromclip, fromvar, fromvardrop "SKIPITEMSWITHPATH/S,SKIPITEMSWITHOUTPATH/S,EXACT/S,GO/S,GOPT/R,"+ //fromfile, fromclip, fromvar, item "USEPATH/S,"+ //tofile, tovar, toclip "APPEND/S,"+ //random, linear "PATH/K,RECURSE/S,SETVAR/K,SETENV/K,FOLDERS/S,FILES/S,SINGLEFOLDER/S,SINGLEFOLDERMINCOUNT/K,"+ "ITEMCOUNTRND/S,ITEMCOUNT/K,ITEMCOUNTPERC/K,ACTION/K,NAME/K,MINSIZE/K,MAXSIZE/K,MAXSIZETOTAL/K,"+ "JSFILTER/K,JSBREAK/K,ECHO/S,COPYTOCOLL/K,COMMANDS/R,"+ //shared misc "DESELECTNOMATCH/S,NODESELECT/S,XLOG/O[off,xit,error,warning,info,,trace,dump],PT/R"; //and MAKEVISIBLE /////////////////////////////////////////////////////////////////////////////// function OnInit(data){ //uid added via script wizard (do not change after publishing this script) var uid = "D6E6CF87-1FFB-4285-85F2-6C69727D2BD8"; //resource center url added via script wizard (required for updating) var url = "http://resource.dopus.com/viewtopic.php?f=35&t=24414"; data.name = "Command.Generic: SelectEx"; data.log_prefix = "SelectEx"; data.desc = "Extended Select command."; data.copyright = "tbone"; data.version = "0.4.5"; data.min_version = "11.5"; data.default_enable = true; var cmd = data.AddCommand(); cmd.name = "SelectEx"; cmd.method = "Command_SelectEx"; cmd.desc = data.desc; cmd.label = "SelectEx"; cmd.template = template; /////////////////////////////////////////////////////////////////////////// function ConfigHelper(data){ //v1.2 var t=this; t.d=data; t.c=data.config; t.cd=DOpus.Create.Map(); t.add=function(name, val, des){ t.l={n:name,ln:name. toLowerCase()}; return t.val(val).des(des);} t.des=function(des){ if (!des) return t; if (t.cd.empty) t.d.config_desc=t.cd; t.cd(t.l.n)=des; return t;} t.val=function(val){ var l=t.l; if (l.v!==l.x&&typeof l.v=="object") l.v.push_back(val);else l.v=t.c[l.n]=val;return t;} t.trn=function(){return t.des(t("script.config."+t.l.ln));}} /////////////////////////////////////////////////////////////////////////// var cfg = new ConfigHelper(data); cfg.add('XLog', DOpus.Create.Vector()). val(5).val("Off").val("Exception").val("Error").val("Warning").val("Info").val("Normal").val("Trace").val("Dump"). des('Console output level. The higher, the more output will be visible in the console window. '); cfg.add('AutoSelect', false). des('Enable automatic selection of items.'); cfg.add('AutoSelect.MakeVisible', true). des('Enable scrolling to automatically selected items.'); cfg.add('AutoSelect.DeselectNoMatch', true). des('Deselect items before automatic selection is applied (deselects automatically selected first file in folder if enabled e.g.).'); cfg.add('AutoSelect.List', DOpus.Create.Vector()). des('List of folder names and items to be selected automatically. '+ 'Paths and item names support regex if prefixed with "REGEX=", regular paths will be resolved (for aliases/env-vars).'). val(';you can use ; or // or # to comment out lines'). val(';syntax is: [REGEX=] => [REGEX=]'). val(''). val(';standard path (select program files)'). val('C:\\ => Program Files'). val(''). val(';alias for path and regex for item'). val('/home => REGEX=dopus.exe|dopusrt.exe'). val(''). val(';env-var in path and regex for item (all log files)'). val('%windir% => REGEX=.+\\.log$'). val(''). val(';using regex for the path'). val('REGEX=.*\\\\drivers\\\\etc => hosts'); } /////////////////////////////////////////////////////////////////////////////// var COMMAND_FAILURE = true; var COMMAND_USERABORT = true; var COMMAND_BADPARAMS = true; var COMMAND_SUCCESS = false; var fm = new FSMagic(); var gThis = this; /////////////////////////////////////////////////////////////////////////////// String.prototype.lTrim = function(chr){chr=chr||"\\s";return new String(this.replace(new RegExp("^"+chr+"*"),''));} String.prototype.rTrim = function(chr){chr=chr||"\\s";return new String(this.replace(new RegExp(chr+"*$"),''));} String.prototype.trim = function(chr){return this.lTrim(chr).rTrim(chr);} String.prototype.left = function(chrs){return this.substring(0,chrs);} String.prototype.right = function(chrs){return this.substring(this.length-chrs);} /////////////////////////////////////////////////////////////////////////////// function Command_SelectEx(data){ var args = ArgsMagic(data, null, template), result = null; //DumpObject(args); //return; if (args["XLOG"].exists) XLog = args["XLOG"].value; Log("CmdLine: " + data.cmdline,"D"); if (args["NODESELECT"].exists) data.func.command.deselect = false; if (0); else if (args["AUTO"].exists) return SelectEx_AUTO(data.func.command, data.func.sourcetab, args); else if (args["SIMILARMETA"].exists) return SelectEx_SIMILARMETA(data.func.command, data.func.sourcetab, args); else if (args["SIMILARMETAJS"].exists) return SelectEx_SIMILARMETAJS(data.func.command, data.func.sourcetab, args); else if (args["FILTERDROP"].exists) return SelectEx_FILTERMENU(data.func.dlg, data.func.command, data.func.sourcetab, args, "dropdown"); else if (args["FILTERLIST"].exists) return SelectEx_FILTERMENU(data.func.dlg, data.func.command, data.func.sourcetab, args, "multilist"); else if (args["FROMCLIP"].exists) return SelectEx_FROMCLIP(data.func.command, data.func.sourcetab, args); else if (args["FROMFILE"].exists) return SelectEx_FROMFILE(data.func.command, data.func.sourcetab, args); else if (args["FROMVAR"].exists) return SelectEx_FROMVAR(data.func.command, data.func.sourcetab, args); else if (args["FROMVARDROP"].exists) return SelectEx_FROMVARDROP(data.func.dlg, data.func.command, data.func.sourcetab, args); else if (args["ITEM"].exists) return SelectEx_ITEM(data.func.command, args, null); else if (args["NTH"].exists) return SelectEx_NTH(data.func.command, data.func.sourcetab, args); else if (args["RANDOM"].exists) return SelectEx_RNDLINEAR(data.func.command, data.func.sourcetab, args, true); else if (args["LINEAR"].exists) return SelectEx_RNDLINEAR(data.func.command, data.func.sourcetab, args, false); else if (args["TOCLIP"].exists) return SelectEx_TOCLIP(data.func.command, data.func.sourcetab, args); else if (args["TOFILE"].exists) return SelectEx_TOFILE(data.func.command, data.func.sourcetab, args); else if (args["TOVAR"].exists) return SelectEx_TOVAR(data.func.command, data.func.sourcetab, args); else if (args["MAKEVISIBLE"].exists) return SelectEx_MAKEVISIBLE(data.func.command, data.func.sourcetab, args, null); if (result===null){ Log("Bad/incomplete params.","X"); return COMMAND_BADPARAMS; } return result; } /////////////////////////////////////////////////////////////////////////////// function SelectEx_MAKEVISIBLE(cmd, sourcetab, args, item){ Log("SelectEx_MAKEVISIBLE():","T",1); /////////////////////////////////////////////////////////////////////////// function SwitchCheckboxMode( truefalse, cmd, sourcetab){ Log('SwitchCheckboxMode():',"T",1); var targetState = "off"; if (truefalse) targetState = "on"; cmd.RunCommand('Set CheckboxMode='+targetState); cmd.Clear(); sourcetab.Update(); var abort = 0; while ((truefalse != sourcetab.selstats.checkbox_mode) && (abort++ < 100)){ Log('Setting CheckboxMode failed to set:' + sourcetab.selstats.checkbox_mode + " target:"+targetState,"E"); DOpus.Delay(10); sourcetab.Update(); } if (abort){ Log('Setting CheckboxMode finally:' + sourcetab.selstats.checkbox_mode,"E"); Log('Took: '+ abort*10 +' milliseconds!',"E"); } Log("-","T",-1); return sourcetab.selstats.checkbox_mode; } cmd.ClearFiles(); cmd.deselect = false; sourcetab.Update(); //update tab for changed selection, fetch first selected item //and select it once more to make the MAKEVISIBLE switch work // for (var iEnum = new Enumerator(sourcetab.selected); !iEnum.atEnd();){ // var item = iEnum.item(); //iEnum.moveNext(); // DOpus.Output(" Running SelectEx MAKEVISIBLE.." + item.realpath); // cmd.RunCommand('SelectEx ITEM="'+item.realpath+'" EXACT MAKEVISIBLE'); // break; // } ///////////////////////// var wasCheckboxMode = (sourcetab.selstats.checkbox_mode==true); var isCheckboxMode = wasCheckboxMode; var numSelItems = sourcetab.stats.selitems; var numCheItems = sourcetab.stats.checkeditems; if (numCheItems+numSelItems==0){ Log("Aborting, nothing selected","D"); Log("-", "T",-1); return COMMAND_SUCCESS; } var prioCBSelection = args["MAKEVISIBLE"].options["checked"] || false; Log("PRIOCHECKED : " + prioCBSelection,"D"); Log("CHECKBOXMODE: " + isCheckboxMode,"D"); if (isCheckboxMode && numSelItems && (prioCBSelection==false || numCheItems==0)){ Log("Disabling checkbox mode to scroll for regular selection (has prio)","D"); isCheckboxMode = SwitchCheckboxMode( false, cmd, sourcetab); } Log("Scrolling selected items into view for "+(isCheckboxMode ? "CheckboxMode" : "RegularMode"),"D"); if (!item){ var selectedItems = new Enumerator(sourcetab.selected); var firstSelected = selectedItems.item(); item = new String(firstSelected.realpath); } //cmd.AddLine('Select "'+firstSelected.name+'" MAKEVISIBLE EXACT'); //cmd.Run(); Log("item : " + item,"D"); args["EXACT"] = {exists:true}; SelectEx_ITEM(cmd, args, new String(item)) if (wasCheckboxMode && !isCheckboxMode){ Log("Turning checkboxes back on","D"); isCheckboxMode = SwitchCheckboxMode( true, cmd, sourcetab); } Log("-","T",-1); return COMMAND_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// function SelectEx_RNDLINEAR(cmd, sourcetab, args, random){ Log("SelectEx_RNDLINEAR():","T",1); var fso = new ActiveXObject("Scripting.FilesystemObject"); var params = { path : args.Get("PATH", null, false), recurse : args.Get("RECURSE", null, false), setVar : args.Get("SETVAR", null, ""), setEnv : args.Get("SETENV", null, ""), folders : args.Get("FOLDERS", null, null), files : args.Get("FILES", null, null), deselectNoMatch : args.Get("DESELECTNOMATCH", null, false), singleFol : args.Get("SINGLEFOLDER", null, false), singleFolMin : args.Get("SINGLEFOLDERMINCOUNT", null, 1), action : args.Get("ACTION", null, ""), itemCount : args.Get("ITEMCOUNT", null, 1), itemCountPerc : args.Get("ITEMCOUNTPERC", null, null), itemCountRND : args.Get("ITEMCOUNTRND", null, false), commands : args.Get("COMMANDS", null, ""), name : args.Get("NAME", null, null), minSize : args.Get("MINSIZE", null, null), maxSize : args.Get("MAXSIZE", null, null), maxSizeTotal : args.Get("MAXSIZETOTAL", null, null), jsFilter : args.Get("JSFILTER", null, null), jsBreak : args.Get("JSBREAK", null, null), copyToColl : args.Get("COPYTOCOLL", null, null), echo : args.Get("ECHO", null, false) } /////////////////////////////////////////////////////////////////////////// function FriendlySizeToBytes(friendlySize){ var size = parseFloat(friendlySize=friendlySize.toLowerCase()); if (isNaN(size)) return null; if (friendlySize.match(/(\d|\s)(b|bytes?)$/)) ; else if (friendlySize.match(/(kb|kilobytes?)$/)) size*=1024; else if (friendlySize.match(/(mb|megabytes?)$/)) size*=1024*1024; else if (friendlySize.match(/(gb|gigabytes?)$/)) size*=1024*1024*1024; else if (friendlySize.match(/(tb|terabytes?)$/)) size*=1024*1024*1024*1024; else if (friendlySize.match(/(pb|petabytes?)$/)) size*=1024*1024*1024*1024*1024; else if (friendlySize.match(/(eb|exabytes?)$/)) size*=1024*1024*1024*1024*1024*1024; else size = null; return size; } /////////////////////////////////////////////////////////////////////////// function Filter( item, itemSize, nameWild, minSize, maxSize, file, folder, SRFilter){ if (nameWild && !nameWild.Match(item.name)) return "name"; if (minSize!==null && minSize>itemSize) return "minsize"; //(!item.is_dir || (item.is_dir && item.got_size)) if (maxSize!=null && maxSizemaxSizeTotal)) return true; return false; } /////////////////////////////////////////////////////////////////////// cmd.ClearFiles(); if (jsBreak){ try{ var SRBreak = new Function("item", jsBreak); } catch(e){ Log("Creating function from JSBreak failed: " + e,"X"); throw new Error("Creating function from JSBreak failed: " + e); } } var sizeTotal = 0; if (random) { var randomsUsed = { "dummy":true }; var r = "dummy"; for (var i=0;i0) params.itemCount = items.count*(params.itemCountPerc/100); } if (params.itemCount > items.count) params.itemCount = items.count; if (params.itemCountRND){ if (params.itemCount>1) params.itemCount = Math.floor((Math.random()*params.itemCount)+1); else params.itemCount = Math.floor((Math.random()*items.count)+1); } return params.itemCount; } /////////////////////////////////////////////////////////////////////////// function JoinItemsToString(collection, separator){ separator = separator || "\n"; var itemsSeparated = ""; for (var iEnum = new Enumerator(collection); !iEnum.atEnd();){ var item = iEnum.item(); iEnum.moveNext(); itemsSeparated += item.realpath + (!iEnum.atEnd()?separator:""); } return itemsSeparated; } /////////////////////////////////////////////////////////////////////////// function GetCollectionToPickFrom(filteredItemCollections, params){ if (params.singleFol && (params.singleFolMin <= filteredItemCollections.dirs.count)){ params.itemCountRND = false; params.itemCount = 1; params.itemCountPerc = null; return filteredItemCollections.dirs; } if (params.folders && !params.files) return filteredItemCollections.dirs; if (params.files && !params.folders) return filteredItemCollections.files; return filteredItemCollections.all; } /////////////////////////////////////////////////////////////////////////// function SelectItemsInFiledisplay(params, cmd){ if (!params.path){ Log("Selecting items..","D"); cmd.RunCommand("Select FROMSCRIPT EXACT"+ (params.deselectNoMatch?" DESELECTNOMATCH":"")+ (args["MAKEVISIBLE"].exists?" MAKEVISIBLE":"") ); return true; } return false; } /////////////////////////////////////////////////////////////////////////// function SetResults(sourcetab, params, cmd, args){ var content = null; if (params.setVar || params.setEnv || args["TOFILE"].exists) content = JoinItemsToString(cmd.files, "\n"); if (params.setVar || params.setEnv) SetResultVariables(sourcetab, params, content); if (args["TOFILE"].exists){ var fm = new FSMagic(); var file = fm.OpenFile(args["TOFILE"].value, args["APPEND"].exists?"a":"w"); if (file!==null){ file.WriteLine(content); file.Close(); } } return (content!==null); } /////////////////////////////////////////////////////////////////////////// function TriggerFileTypeActions(params, cmd){ if (params.action){ Log("Triggering action ["+params.action+"]..","D"); cmd.RunCommand("FileType ACTION="+params.action); return true; } return false; } /////////////////////////////////////////////////////////////////////////// function ExecuteCommands(params, cmd){ if (params.commands && cmd.files.count){ Log("Running commands..","D"); var commands = params.commands.split("\\n"); for(var c=0;c maxLen) maxLen = param.length; for(param in params){ var pad = ""; while (pad.length+param.length"); if (parts.length!=2) continue; Log("Entry: " + list(i),"D"); var path = parts[0].trim(); if (path.substring(0,6)=="REGEX="){ path = path.substring(6); } else { path = path!=""?new String(DOpus.FSUtil.Resolve(path)):path; path = path.replace(/\\/g,'\\\\')+"$"; } Log(" Path: " + path,"D"); Log(" TabPath: " + tabPath,"D"); if (!tabPath.match(new RegExp(path,"i"))){ Log(" No path match","D"); continue; } var item = parts[1].trim(); selItems[selItems.length] = item; } if (selItems.length){ Log("SelItems: " + selItems,"D"); args["USEPATH"] = {exists:true}; SelectArrayItems(cmd, sourcetab, args, selItems); } Log("-","T",-1); return; } /////////////////////////////////////////////////////////////////////////////// function SelectEx_FILTERMENU(dlg, cmd, sourcetab, args, type){ Log("SelectEx_FILTERMENU():","T",1); /////////////////////////////////////////////////////////////////////////// function GetFilterNamesVector(){ var filtersPath = DOpus.FSUtil.Resolve("/dopusdata\\filters"); var fEnum = DOpus.FSUtil.ReadDir(filtersPath); if (fEnum.error!=0 && fEnum.error!=18 && fEnum.error!=2 ) //18 = empty folder, 2=drive root throw new Error(0,"ReadDir ["+filtersPath+"] failed, fEnum.error ["+fEnum.error+"]"); var list = DOpus.Create.Vector(); while (!fEnum.complete){ var filterItem = fEnum.next(); if (filterItem.is_dir == true) continue; if (filterItem.ext.toLowerCase() != ".ofi") continue; list.push_back(filterItem.name_stem); } return list; } /////////////////////////////////////////////////////////////////////////// function OpenMenu(dlg, type, filters, filterFlags){ dlg.title = "Select Filters"; dlg.message = "Check filters to "+filterFlags.replace(",",", ")+" items:" dlg.buttons = "Ok|Cancel"; dlg.choices = filters; if (type=="dropdown") dlg.menu = 0; if (type=="multilist") dlg.list = 0; dlg.Show(); return dlg.result; } /////////////////////////////////////////////////////////////////////////// function AddSelection(cmd, filterName, filterFlags){ var cmdLine = 'Select "'+filterName+'" FILTER FILTERFLAGS="'+filterFlags+'"'+ (args["MAKEVISIBLE"].exists?' MAKEVISIBLE':'')+ (args["PT"].exists?' '+args["PT"].value:'') ; cmd.AddLine(cmdLine); Log("Command: " + cmdLine,"D"); } /////////////////////////////////////////////////////////////////////////// Log("DESELECTNOMATCH: " + args["DESELECTNOMATCH"].exists,"D"); Log("MAKEVISIBLE : " + args["MAKEVISIBLE"].exists,"D"); Log("PT : " + args["PT"].value,"D"); cmd.deselect = false; if (args["DESELECTNOMATCH"].exists){ Log("cmd.AddLine(Select NONE);","D"); cmd.AddLine('Select NONE'); } if (type=="dropdown") var filterFlags = args["FILTERDROP"].value; if (type=="multilist") var filterFlags = args["FILTERLIST"].value; var filters = GetFilterNamesVector(); if (!filters.count){ Log("No filters found.","X"); Log("-","T",-1); return COMMAND_FAILURE; } var result = OpenMenu(dlg, type, filters, filterFlags); if (result==0){ Log("User abort.","T",-1); return COMMAND_USERABORT; } if (type=="multilist") for(var c=0;c str2.length) { return 1 - distance / str1.length; } else { return 1 - distance / str2.length; } } /////////////////////////////////////////////////////////////////////////// //work in progess function dis(selStr, str) { selStr = selStr.toLowerCase().replace(/[#0123456789\.\-\(\)]/g,""); str = str.toLowerCase().replace(/[#0123456789\.\-\(\)]/g,""); selStr = selStr.toLowerCase().replace(/^|\sthe\s|$/g,""); str = str.toLowerCase().replace(/^|\sthe\s|$/g,""); //DOpus.Output(str); return false; var selItemWords = new String(selStr).split(" "), selItemWords2 = []; var itemWords = new String(str).split(" "), itemWords2 = []; for(var i=0;i 0.9) { match = true; break; } } if (match) matches++; //DOpus.Output("itemWords2[i]="+itemWords2[i]); //DOpus.Output(" selStr="+selStr); } var perc = (matches*100)/itemWords.length; //var perc = (itemWords.length*100)/matches; //DOpus.Output(selStr + " " + perc.toFixed(2)); if (perc>15){ return true; } return false; //if (matches != itemWords.length) return 0; return matches; } /////////////////////////////////////////////////////////////////////////////// function SelectEx_SIMILAR(cmd, sourcetab, args, metas, jsCompare){ Log("SelectEx_SIMILAR():","T",1); /////////////////////////////////////////////////////////////////////////// var selFilesEnum = new Enumerator(sourcetab.selected_files), selItem = null; if (!selFilesEnum.atEnd()) selItem = selFilesEnum.item(); if (!selItem){ Log("No item selected or passed.","W"); //Log("-","T",-1); //return COMMAND_FAILURE; } if (metas){ var selItemMetas = [] for (var i=0;i"); if (parts.length>1) opValue = parts.slice(1).join(""); this.options[opName] = opValue; } if (!(!this.value && subOpsTemplate)) return; if (!(match = subOpsTemplate.match(/\<(.+?)\>/))) return; this.options[match[1]] = true; this.value = match[1]; } /////////////////////////////////////////////////////////////////////////// var types = {s:"switch",k:"keyword",o:"optional",n:"numeric",m:"multiple",r:"raw"}; var names = template.replace(/\/(.)\,/g,"/$1;").replace(/\]\,/g,"];").split(";"), args = []; for(arg in names) { var parts = names[arg].split("/"); var name=parts[0].toUpperCase(), subOpsTemplate=null; var parts2 = parts[1].split("["); var type=parts2[0].toLowerCase(); if (parts2.length>1) subOpsTemplate = parts2[1].substring(0,parts2[1].length-1); var exists=(data&&data.func.args.got_arg[name])||(jsonData&&(jsonData[name]!=undefined))||false; var value = (data && data.func.args[name]) || (jsonData && jsonData[name]) || undefined; args.push( args[name] = new Arg(name, types[type], exists, value, subOpsTemplate )); } /////////////////////////////////////////////////////////////////////////// args.Get = function( argName, configName, noneValue){ var arg = this[argName = argName.toUpperCase()]; if (!arg) throw new Error(0, "Unknown parameter ["+argName+"]"); if (arg.exists) return arg.value; //DOpus.Output("argName: " + argName); //DOpus.Output("configName: " + configName); if (!configName) return noneValue; if (typeof Script.config[configName] == "string") return new String(""+Script.config[configName]); return Script.config[configName]; } return args; } /////////////////////////////////////////////////////////////////////////////// function DumpObject(o, name, upperCaseProps, self, level){ this.version = 0.4; name = name || "unnamed"; if (self == undefined) DOpus.Output("DumpObject(): ["+name+"]"); var maxLen = 0; upperCaseProps = upperCaseProps || false; self = self || false; level = level || " "; for(prop in o) if (prop.length > maxLen) maxLen = prop.length; for(prop in o) { var pad = ""; while (pad.length+prop.length