/////////////////////////////////////////////////////////////////////////////// function OnInit(data) { var resUrl = "http://resource.dopus.com/viewtopic.php?f=35&t=23192"; var resUID = "Column.Generic.ModifiedWithin"; data.name = "Column.Generic: ModifiedWithin"; data.desc = "Adds columns which indicate if a file has been modified within a configurable timespan."; data.copyright = "tbone 1o/2o14"; data.version = "0.1"; data.min_version = "11.7"; data.default_enable = true; /////////////////////////////////////////////////////////////////////////// function ConfigHelper(data){ this.data=data; this.descriptions=null; this.last=null; this.add = function(name, val, description){ this.data.config[name]=val; this.last=[this.data.config[name],name]; if (description!=undefined) this.des(description); return this;} this.des = function(description){ if (!(description && DOpus.version.AtLeast("11.6.1"))) return this; if (!this.descriptions){ this.descriptions=DOpus.NewMap(); data.config._descriptions=this.descriptions; } this.descriptions(this.last[1])=description; return this;} this.val = function(val){ if (typeof this.last[0]=="object") this.last[0].push_back(val); else this.last[0]=val; return this;} } /////////////////////////////////////////////////////////////////////////// var cfg = new ConfigHelper(data); cfg.add("CharsColumn.Timespan", 60). des("Within-timespan of modifification/creation date in minutes."); cfg.add("CharsColumn.Header", "*"). des("Column header text."); cfg.add("CharsColumn.Width", "60px"). des("In graph-mode 30px seems to fit well. In segment mode, a wider setting is recommended."); cfg.add("CharsColumn.Justify", DOpus.Create.Vector()). des("Column text alignment left,right,center."). val(0).val("right").val("left").val("center"); cfg.add("CharsColumn.MaxLength", 4). des("Number of chars representing the full timespan."); cfg.add("CharsColumn.Char", "■"). des("The char to use in segment mode."); cfg.add("e===============", ""); cfg.add("GraphColumn.Timespan", 60). des("Within-timespan of modifification/creation date in minutes."); cfg.add("GraphColumn.Header", "*"). des("Column header text."); cfg.add("GraphColumn.Width", "30px"). des("In graph-mode 30px seems to fit well. In segment mode, a wider setting is recommended."); } /////////////////////////////////////////////////////////////////////////////// function OnAddColumns(data){ var cmd = data.AddColumn(); cmd.multicol = true; cmd.name = "ModifiedWithin-Graph"; cmd.label = "Modified Within - Graph"; cmd.header = Script.config["GraphColumn.Header"]; cmd.method = "Column_ModifiedWithin"; cmd.autorefresh = true; cmd.namerefresh = true; cmd.defwidth = Script.config["GraphColumn.Width"]; cmd.type = "graph"; cmd.justify = "left"; var cmd = data.AddColumn(); cmd.multicol = true; cmd.name = "ModifiedWithin-Chars"; cmd.label = "Modified Within - Chars"; cmd.header = Script.config["CharsColumn.Header"]; cmd.method = "Column_ModifiedWithin"; cmd.autorefresh = true; cmd.namerefresh = true; cmd.defwidth = Script.config["CharsColumn.Width"]; cmd.type = "text"; var justify = ["left","right","center"]; cmd.justify = justify[Script.config["CharsColumn.Justify"]]; } /////////////////////////////////////////////////////////////////////////////// function Column_ModifiedWithin(data) { var dateMod = new Date(data.item.modify).valueOf(); var dateCre = new Date(data.item.create).valueOf(); var dateNow = new Date().valueOf(); var diffMin = (dateNow-dateMod)/60000; //setting defaults (no value to not clutter the columns) data.columns("ModifiedWithin-Graph").value = ""; data.columns("ModifiedWithin-Chars").value = ""; var diffMin = GetDiffMin(dateNow, dateMod, dateCre, Script.config["GraphColumn.Timespan"]) //handling graph column if (diffMin>0 && diffMin0 && diffMinminutes){ diffMin = (dateNow-dateCre)/60000; } return diffMin; } /////////////////////////////////////////////////////////////////////////////// function OnScriptConfigChange(data) { Script.InitColumns(); Script.RefreshColumn("ModifiedWithin-Graph"); Script.RefreshColumn("ModifiedWithin-Chars"); } /////////////////////////////////////////////////////////////////////////////// function OnAboutScript(data){ //v0.1 var cmd = DOpus.Create.Command(); if (!cmd.Commandlist('s').exists("ScriptAbout")){ if (DOpus.Dlg.Request("The 'ScriptAbout' command has not been found.\n\n"+ "Install 'ScriptHelper' from [resource.dopus.com]. It makes the dialog show and also offers "+ "auto-updating of scripts.","Yes, take me there!|Cancel", "No About.. ", data.window)) cmd.RunCommand('cmd /c start http://resource.dopus.com/viewforum.php?f=35');} else cmd.RunCommand('ScriptAbout WIN='+data.window+' FILE="'+Script.File+'"'); }