I use Javascript on the client side and I want to get a list of all the files in the folder, which, it seems to me, is located on the same server as my .html file. I am very unfamiliar with the terminology, so I apologize in advance if I am inaccurate or just wrong.
I am currently using d3.text("js/data/nodes#.csv", "text/csv", someFunction) to load the data file to work. I believe that since all the file names I want, the templates are the same, I can crack the solution by going through all possible numbers and getting only the names of the actual calls:
function getDirList() { var possiblePathsList = something predetermined; var directoryList = []; possiblePathsList.forEach(function(path){ if (isPath(path)) { directoryList.push(path); } }); return directoryList; } function isPath(path){ d3.text(path, "text/csv", function(data){ return (data !== null); }); }
Because I can get a list in this very trashy way, I guess there must be some kind of (much more elegant way to achieve my goal). Is it possible?
source share