// Redo Operation // (c) 2017 Enternal // Threads Created by Enternal to Ask for Help to Develop Script: //http://resource.dopus.com/viewtopic.php?f=12&t=28677 //http://resource.dopus.com/viewtopic.php?f=12&t=28694 //http://resource.dopus.com/viewtopic.php?f=12&t=28699 //http://resource.dopus.com/viewtopic.php?f=12&t=28704 //http://resource.dopus.com/viewtopic.php?f=12&t=28706 // Misc Notes //https://resource.dopus.com/viewtopic.php?t=24251 //http://resource.dopus.com/viewtopic.php?t=24063 function OnInit(initData) { initData.name = "Redo Operation"; initData.version = "0.1.0"; initData.copyright = "(c) 2017 Enternal"; initData.url = "http://resource.dopus.com/viewtopic.php?f=35&t=28756"; initData.desc = "Track copy/move operations and allow redo for other selected items"; initData.default_enable = true; //initData.min_version = "12.0"; //http://resource.dopus.com/viewtopic.php?t=22979 Helper: ConfigHelper (easier config item handling) by tbone 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(initData); cfg.add("MoveHistoryLength", "15", "Set the history length for recent MOVE operations."); cfg.add("CopyHistoryLength", "15", "Set the history length for recent COPY operations."); cfg.add("Debug", false, "Set debug to on."); var cmd = initData.AddCommand(); cmd.name = "RedoOperation" cmd.method = "OnRedoOperation"; cmd.desc = initData.desc; cmd.label = "Redo Operation" cmd.template = "CLEAR/N,LISTMOVE/N,LISTCOPY/N" } // Called when a copy or move operation take place function OnGetCopyQueueName(GetCopyQueueNameData) { var ReOps_dest = GetCopyQueueNameData.dest; var ReOps_move = GetCopyQueueNameData.move; if (ReOps_move == true) { ReOpsInitialize() var ReOps_data_move = DOpus.Vars.Get("ReOpsMove"); var index = searchVector(ReOps_data_move, ReOps_dest); if (index != null) {for (var i=index.length-1; i>-1; i=i-1) {ReOps_data_move.erase(index(i));}} ReOps_data_move.insert(0, ReOps_dest); DOpus.Vars("ReOpsMove") = ReOps_data_move; var MoveHistoryLength = Script.config["MoveHistoryLength"]; while (ReOps_data_move.length>MoveHistoryLength) { ReOps_data_move.erase(ReOps_data_move.length-1); DOpus.Vars("ReOpsMove") = ReOps_data_move; } } else { ReOpsInitialize() var ReOps_data_copy = DOpus.Vars.Get("ReOpsCopy"); var index = searchVector(ReOps_data_copy, ReOps_dest); if (index != null) {for (var i=0; iCopyHistoryLength) { ReOps_data_copy.erase(ReOps_data_copy.length-1); DOpus.Vars("ReOpsCopy") = ReOps_data_copy; } } if (Script.config["Debug"] == true) { //DOpus.ClearOutput ReOpsInitialize() var ReOps_data_move = DOpus.Vars.Get("ReOpsMove"); var ReOps_data_copy = DOpus.Vars.Get("ReOpsCopy"); Log("Redo Operation (Debug)") Log(" Redo Operation ReOpsMove Exist: " +DOpus.Vars.Exists("ReOpsMove")) Log(" Redo Operation ReOpsCopy Exist: " +DOpus.Vars.Exists("ReOpsCopy")) Log(" Redo Operation MOVE History: " +Script.config["MoveHistoryLength"]); Log(" Redo Operation COPY History: " +Script.config["CopyHistoryLength"]); Log(" Redo Operation MOVE Events"); if (ReOps_data_move && ReOps_data_move.length) { Log(" Vector Length: " +ReOps_data_move.length); for (var i=0; i