(function(){ //load data let menu = document.getElementById('menu'); var array = menu.innerHTML.split("\n") //remove empty (whitespace) strings var filtered = array.filter(function(str) { return /\S/.test(str); }); //remove whitespace in strings and split by forward slash paths = filtered.map(function(e){return e.trim();}); var hierarchy = paths.reduce(function(hier,path){ var x = hier; path.split('/').forEach(function(item){ if(!x[item]){ x[item] = {}; } x = x[item]; }); x.path = path; return hier; }, {}); var makeul = function(hierarchy, classname){ var dirs = Object.keys(hierarchy); var ul = '