// Redo Operation // (c) 2017 Enternal // Threads Created by Enternal to Ask for Help to Develop Script: //https://resource.dopus.com/t/redo-operation-scripting-help/24602 //https://resource.dopus.com/t/how-to-get-the-gui-popuout-list-like-the-undo-list-item-in-the-toolbar/24617 //https://resource.dopus.com/t/quick-easy-way-to-search-an-array-vector-and-return-index/24622 //https://resource.dopus.com/t/enumerate-selected-items-into-a-simple-line-list/24627 //https://resource.dopus.com/t/how-to-insert-data-into-a-vector-not-through-push-back/24629 //https://resource.dopus.com/t/getcopyqueuenamedata-vs-dopus-listers-0-activetab-path/24740 // Misc Notes //https://resource.dopus.com/t/js-reusing-regular-global-variables-through-multiple-executions/20358 function OnInit(initData) { initData.name = "Redo Operation"; initData.version = "0.2.0"; initData.copyright = "(c) 2017 Enternal"; initData.url = "https://resource.dopus.com/t/redo-operations/24675"; initData.desc = "Quickly and easily redo copy/move operations to recent copied/moved to locations."; initData.default_enable = true; //initData.min_version = "12.3.4"; //https://resource.dopus.com/t/helper-confighelper-easier-config-item-handling/19129 // 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("Universal", false, "Recent operations are UNIVERSAL instead of recent COPY destinations are only available for copy operations and vice versa."); cfg.add("UniversalHistoryLength", "15", "Set the history length for UNIVERSAL recent 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; // https://resource.dopus.com/t/getcopyqueuenamedata-vs-dopus-listers-0-activetab-path/24740 // Directory Opus below version 12.3.4 beta had a bug where network locations that were mounted // onto a drive letter had their true path stripped down to the drive letters only. // Code below still kept since it may be useful for other debugging purposes. if (Script.config["Debug"] == true) { DOpus.ClearOutput ReOpsInitialize() Log("Redo Operation (Debug) - Path Checks") Log(" Redo Operation GetCopyQueueNameData.dest: " +GetCopyQueueNameData.dest) Log(" Redo Operation DOpus.listers(0).activetab.path: " +DOpus.listers(0).activetab.path) if (String(DOpus.listers(0).activetab.path) == String(GetCopyQueueNameData.dest)) { Log(" Redo Operation: GetCopyQueueNameData.dest and DOpus.listers(0).activetab.path Matches") } else { Log(" Redo Operation: GetCopyQueueNameData.dest and DOpus.listers(0).activetab.path Does Not Match") } } if (Script.config["Universal"] == true) { ReOpsInitialize() var ReOps_data_universal = DOpus.Vars.Get("ReOpsUniversal"); var index = searchVector(ReOps_data_universal, ReOps_dest); if (index != null) {for (var i=index.length-1; i>-1; i=i-1) {ReOps_data_universal.erase(index(i));}} ReOps_data_universal.insert(0, ReOps_dest); DOpus.Vars("ReOpsUniversal") = ReOps_data_universal; var UniversalHistoryLength = Script.config["UniversalHistoryLength"]; while (ReOps_data_universal.length>UniversalHistoryLength) { ReOps_data_universal.erase(ReOps_data_universal.length-1); DOpus.Vars("ReOpsUniversal") = ReOps_data_universal; } } else 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"); var ReOps_data_universal = DOpus.Vars.Get("ReOpsUniversal"); Log("Redo Operation (Debug) - General") Log(" Redo Operation ReOpsMove Exist: " +DOpus.Vars.Exists("ReOpsMove")) Log(" Redo Operation ReOpsCopy Exist: " +DOpus.Vars.Exists("ReOpsCopy")) Log(" Redo Operation ReOpsUniversal Exist: " +DOpus.Vars.Exists("ReOpsUniversal")) Log(" Redo Operation MOVE History: " +Script.config["MoveHistoryLength"]); Log(" Redo Operation COPY History: " +Script.config["CopyHistoryLength"]); Log(" Redo Operation UNIVERSAL History: " +Script.config["UniversalHistoryLength"]); 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