InitChildList()
Set CreateChild = New TreeNode
CreateChild.Value = szValue
CreateChild.ExpandImage = ExpandImage
CreateChild.CollapseImage = CollapseImage
CreateChild.LeafImage = LeafImage
mcolChildren.Add mcolChildren.Count + 1, CreateChild
End Function
Public Sub Draw()
LoadState()
Response.Write "<table border=""0"">" & vbCrLf
Response.Write "<tr><td>" & vbCrLf
If Expanded Then
Response.Write "<a href=""javascript:collapseNode(''" & mszName & "'')""><img src=""" & CollapseImage & """ border=""0""></a>" & vbCrLf
ElseIf Not mbChildrenInitialized Then
Response.Write "<img src=""" & LeafImage & """ border=0>" & vbCrLf
Else
Response.Write "<a href=""javascript:expandNode(''" & mszName & "'')""><img src=""" & ExpandImage & """ border=""0""></a>" & vbCrLf
End If
Response.Write "</td>" & vbCrLf
Response.Write "<td>" & Value & "</td></tr>" & vbCrLf
If Expanded Then
Response.Write "<input type=""hidden"" name=""" & mszName & """ value=""1"">" & vbCrLf
If mbChildrenInitialized Then
Response.Write "<tr><td> </td>" & vbCrLf
Response.Write "<td>" & vbCrLf
For Each ChildNode In mcolChildren.Items
ChildNode.Draw()
Next
Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
End If
End If
Response.Write "</table>" & vbCrLf
End Sub
End Class
Class Tree
Public Top
Public Left
Public ExpandImage
Public CollapseImage
Public LeafImage
Private mszPosition
Private mcolChildren
Public Property Let Absolute(bData)
If bData Then mszPosition = "absolute" Else mszPosition = "relative"
End Property
Public Property Get Absolute()
Absolute = CBool(mszPosition = "absolute")
End Property
Private Sub Class_Initialize()
Set mcolChildren = Server.CreateObject("Scripting.Dictionary")
mnTop = 0
mnLeft = 0
mszPosition = "absolute"
End Sub
Private Sub Class_Terminate()
mcolChildren.RemoveAll()
Set mcolChildren = Nothing
End Sub
Public Function CreateChild(szValue)
Set CreateChild = New TreeNode
CreateChild.Value = szValue
CreateChild.ExpandImage = ExpandImage
CreateChild.CollapseImage = CollapseImage
CreateChild.LeafImage = LeafImage
mcolChildren.Add mcolChildren.Count + 1, CreateChild
End Function
Public Sub LoadTemplate(szFileName)
Dim objWorkingNode
Dim colNodeStack
Dim fsObj, tsObj
Dim szLine
Dim nCurrDepth, nNextDepth
Set colNodeStack = Server.CreateObject("Scripting.Dictionary")
Set fsObj = CreateObject("Scripting.FileSystemObject")
Set tsObj = fsObj.OpenTextFile(szFileName, 1)
nCurrDepth = 0
While Not tsObj.AtEndOfLine
nNextDepth = 1
szLine = tsObj.ReadLine()
If nCurrDepth = 0 Then
Set objWorkingNode = CreateChild(Trim(szLine))
nCurrDepth = 1
Else
While Mid(szLine,nNextDepth,1) = vbTab Or Mid(szLine,nNextDepth,1) = " "
nNextDepth = nNextDepth + 1
WEnd
If nNextDepth > 1 Then szLine = Trim(Mid(szLine,nNextDepth))
If szLine <> "" Then
If nNextDepth > nCurrDepth Then
If colNodeStack.Exists(nCurrDepth) Then
Set colNodeStack.Item(nC