// Erod Keaton Baybay (erodb@vt.edu) // Macro Deploying Tool - For Hauf Lab Macros // Version Requirement versionFIJI = "1.53b"; requires(versionFIJI); // Fetch Macros var macrosDirectory = getDirectory("macros") + "Hauf_Macros/"; var macros = getFileList(macrosDirectory); var macroMenu = cleanArray(getFileList(macrosDirectory)); // Menu var menuList = Array.concat(Array.concat(newArray("Hauf Lab Website", "Pomegranate Documentation", "WEKA-FISH Documentation", "-"), macroMenu), "-", "Options"); var HLT = newMenu("Hauf Lab Menu Tool", menuList); var advancedPrompt = false; // Hauf Lab Menu Tool - Macro Body macro "Hauf Lab Menu Tool - C059 T0b14H T9b14L" { HLrun = getArgument(); actions = newArray("Run " + HLrun, "View source code for " + HLrun); // Useful URLs if (HLrun == "Hauf Lab Website") run("URL...", "url=https://www.hauflab.org/"); else if (HLrun == "Pomegranate Documentation") run("URL...", "url=https://github.com/erodb/Pomegranate"); else if (HLrun == "WEKA-FISH Documentation") run("URL...", "url=https://www.hauflab.org/404"); // Hauf Lab Tools Settings else if (HLrun == "Options") { Dialog.create("Hauf Lab Macros - Options"); Dialog.addMessage("Additional Actions Prompt - (Disabled by default) Enabling Additional Actions offers the \noption to open the source code when selecting a macro from the Hauf Lab Tools menu."); Dialog.addCheckbox("Additional Actions Prompt", advancedPrompt); Dialog.show(); advancedPrompt = Dialog.getCheckbox(); } // Macros else { currentAction = NaN; if (advancedPrompt) { Dialog.create("Hauf Lab Macros - Additional Actions"); Dialog.addChoice("Action", actions); Dialog.show(); currentAction = Dialog.getChoice(); if (currentAction == actions[0]) runMacro(macrosDirectory + matchItem(macros, HLrun)); else if (currentAction == actions[1]) open(macrosDirectory + matchItem(macros, HLrun)); } else runMacro(macrosDirectory + matchItem(macros, HLrun)); } } // Formats macro list into menu items (removes file extensions, and underscores) function cleanArray(arr) { arrNew = newArray() for (i = 0; i < arr.length; i++) if (endsWith(arr[i], ".ijm")) { // Clean up cleanItem = arr[i]; cleanItem = replace(cleanItem,".ijm",""); cleanItem = replace(cleanItem,"_"," "); cleanItem = replace(cleanItem,"-"," "); // Apply arrNew = Array.concat(arrNew, cleanItem); } arrNew = Array.sort(arrNew) return arrNew; } // Matches menu choice with macro from macro list function matchItem(arr, cleanItem) { outputItem = NaN; for (i = 0; i < arr.length; i++) { // Clean up uncleanItem = arr[i]; uncleanItem = replace(uncleanItem,".ijm",""); uncleanItem = replace(uncleanItem,"_"," "); uncleanItem = replace(uncleanItem,"-"," "); if (uncleanItem == cleanItem) outputItem = arr[i]; } return outputItem; }