// Erod Keaton Baybay (erodb@vt.edu) // Macro Deploying Tool - For Hauf Lab Macros // Fetch Macros var macrosDirectory = getDirectory("macros") + "Hauf_Macros/"; var macros = getFileList(macrosDirectory); var macroMenu = cleanArray(getFileList(macrosDirectory)); // Menu var menuList = Array.concat(newArray("Hauf Lab Website", "Documentation", "-"), macroMenu); var HLT = newMenu("Hauf Lab Menu Tool", menuList); macro "Hauf Lab Menu Tool - C059 T0b14H T9b14L" { HLrun = getArgument(); // Useful URLs if (HLrun == "Hauf Lab Website") run("URL...", "url=https://www.hauflab.org/"); else if (HLrun == "Documentation") run("URL...", "url=https://www.hauflab.org/404"); else { if (getBoolean("Are you sure you wish to run " + HLrun + "?", "Run", "Do Not Run")) runMacro(macrosDirectory + matchItem(macros, HLrun)); else exit(); } } // "Cleans" an Array (for aesthetics) - Removes File Extensions, Hyphenation, 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; } // Return "Unclean" Item from "Unclean Array" that closely matches "Clean" Item 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; }