Skip to content

Instantly share code, notes, and snippets.

@dorukcan
Last active June 9, 2017 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorukcan/7f174b17baa1add87ce37273dd202974 to your computer and use it in GitHub Desktop.
Save dorukcan/7f174b17baa1add87ce37273dd202974 to your computer and use it in GitHub Desktop.
var arr = d.aNodes;
document.write('<ul>')
getNodes(-1);
document.write('</ul>')
function getNodes(parentId) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].parentid == parentId) {
if (arr[i].url == undefined) {
document.write("<li>");
document.write("<a href='#'>" + arr[i].name + "</a>");
document.write("<ul>");
getNodes(arr[i].id);
document.write("</ul>");
document.write("</li>");
}
else {
document.write("<li><a href='" + arr[i].url + "'>" + arr[i].name + "</a></li>");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment