\n")
redrawNode(foldersTree, doc, 0, 1, "")
doc.close()
}
//recursive function over the tree structure called by redrawTree
function redrawNode(foldersNode, doc, level, lastNode, leftSide)
{
var j=0
var i=0
var numberOfFolders
var numberOfDocs
doc.write("\n")
doc.write("\n\n")
doc.write(leftSide)
if (level>0)
if (lastNode) //the last 'brother' in the children array
{
doc.write("")
leftSide = leftSide + ""
}
else
{
doc.write("")
leftSide = leftSide + ""
}
displayIconAndLabel(foldersNode, doc)
doc.write(" |
\n\n")
if (foldersNode.length > 4 && foldersNode[0]) //there are sub-nodes and the folder is open
{
numberOfFolders = foldersNode.length - 4 - foldersNode[2]
// display the folders
level = level + 1
for (i=4 ; i < 4 + numberOfFolders; i++)
{
if (i == (foldersNode.length - 1))
redrawNode(foldersNode[i], doc, level, 1, leftSide)
else
redrawNode(foldersNode[i], doc, level, 0, leftSide)
}
// display the documents
for ( i = 4 + numberOfFolders; i < foldersNode.length ; i++ )
{
doc.write("")
doc.write("")
doc.write(leftSide)
if (i == foldersNode.length - 1)
doc.write("")
else
doc.write("")
doc.write(" | ")
doc.write(foldersNode[i])
doc.write(" |
")
doc.write("
")
}
}
}
//builds the html code to display a folder and its label
function displayIconAndLabel(foldersNode, doc)
{
doc.write("")
}
else
{
doc.write("onMouseOver='window.status=\"Open folder\"; return true'>")
}
doc.write("")
doc.write(""+foldersNode[3]+"")
}
//**********************
// Recursive functions
//when a parent is closed all children also are
function closeFolders(foldersNode)
{
var i=0
for (i=4; i< foldersNode.length - foldersNode[2]; i++)
closeFolders(foldersNode[i])
foldersNode[0] = 0
foldersNode[1] = 0
}
//recursive over the tree structure
//called by openbranch
function clickOnFolderRec(foldersNode, folderName)
{
var i=0
if (foldersNode[3] == folderName)
{
if (foldersNode[0])
closeFolders(foldersNode)
else
{
foldersNode[0] = 1
foldersNode[1] = 1
}
}
else
{
for (i = 4 ; i < foldersNode.length - foldersNode[2]; i++)
clickOnFolderRec(foldersNode[i], folderName)
}
}
// ********************
// Event handlers
//called when the user clicks on a folder
function openBranch(branchName)
{
clickOnFolderRec(foldersTree, branchName)
if (branchName==foldersTree[3] && foldersTree[0]==0)
top.folderFrame.location="libcompmain.htm" //closing the root folder
//makes the welcome page to show
timeOutId = setTimeout("redrawTree()",100)
}
//called after this html file is loaded
function initializeTree()
{
generateTree()
redrawTree()
}
var foldersTree = 0
var timeOutId = 0
var USETEXTLINKS = 0
generateTree() //sometimes when the user reloads the document Netscape 3.01 does not trigger the onLoad event (!!)
// end hiding contents from old browsers -->
|