//v0.1 - initial version 12/2o15 //- supports custom title, message, buttons and icon //- supports showing of number of selected items/files/dirs {#selitems$}, {#seldirs$}, {#selfiles$} //- supports resolving of all DO variables (global, tab or lister-scoped) /////////////////////////////////////////////////////////////////////////////// function OnInit(data){ //uid added via script wizard (do not change after publishing this script) var uid = "2D3171EA-858B-4285-BDF6-5F7F65D4588B"; data.name = "Command.GUI: Confirm"; data.desc = "Replacement for the @confirm modifier to show confirmation or notification requesters."; data.copyright = "tbone"; data.version = "0.1"; data.default_enable = true; var cmd = data.AddCommand(); cmd.name = "Confirm"; cmd.template = "TITLE/O,MSG/O,BUTTONS/O,ICON/O"; cmd.method = "Command_Confirm"; cmd.desc = data.desc; } /////////////////////////////////////////////////////////////////////////////// var COMMAND_USERABORT = true; var COMMAND_PROCEED = false; /////////////////////////////////////////////////////////////////////////////// function Command_Confirm(data) { data.func.command.deselect = false; var arg = data.func.args; var msg = arg.msg || "Proceed?"; var tit = arg.title || "Confirmation"; var btn = arg.buttons || "Ok|Cancel"; var icn = arg.icon || "question"; msg = msg.replace(/\\n/g,"\n"); msg = ReplaceVars(msg, /\{\$.*?\}/gi, DOpus.Vars, "$"); msg = ReplaceVars(msg, /\{\$glob\:.*?\}/gi, DOpus.Vars, "$glob:"); if (data.func.sourcetab){ msg = msg.replace(/\{\#selitems\$\}/g, data.func.sourcetab.selected.count); msg = msg.replace(/\{\#seldirs\$\}/g, data.func.sourcetab.selected_dirs.count); msg = msg.replace(/\{\#selfiles\$\}/g, data.func.sourcetab.selected_files.count); msg = ReplaceVars(msg, /\{\$lst\:.*?\}/gi, data.func.sourcetab.lister.vars, "$lst:"); msg = ReplaceVars(msg, /\{\$src\:.*?\}/gi, data.func.sourcetab.vars, "$src:"); } if (data.func.desttab) msg = ReplaceVars(msg, /\{\$dst\:.*?\}/gi, data.func.desttab.vars, "$dst:"); var dlg = DOpus.Dlg; dlg.title = tit; dlg.message = msg; dlg.buttons = btn; dlg.icon = icn; var result = dlg.Show(); if (!result) return COMMAND_USERABORT; return COMMAND_PROCEED; } /////////////////////////////////////////////////////////////////////////////// function ReplaceVars( text, re, vars, id ) { text = text.replace(re, function(strMatch,index,strFull){ var varName = strMatch.substring(1+id.length,strMatch.length-1); var varValue = strMatch; if (vars.Exists(varName)) varValue = vars.Get(varName); return varValue; } ) return text; } /////////////////////////////////////////////////////////////////////////////// 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 = "ec29857c9a2e73b5deec727e210c4988"; DATE = "2015.12.28 - 20:56:47"