Drawing the Tree

The main function that actually takes the information in the foldersTree object and produces all correct layers, images, links, and text is the initializeFolder function.

Here's a pseudocode version of the function:

function initializeFolder(level, lastNode, leftSide)
{
- add another element to the indexOfEntries array
- create link for node image (the one with plus or minus)
- draw folder, with layer info, images, links and text
- set whether node is the last node or not (that is, is the last node to appear within a
 certain folder)
- if the node has children (that is, if the folder has something in it), then create a
 loop over ...

Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.