디렉토리 트리 구조를 생성하는 클래스 정보
이 프로그램에는 두 개의 파일 Test.asp, Tree.asp 및 일부 아이콘 파일이 있습니다.
1. test.asp 호출 클래스 스패닝 트리 코드는 다음과 같습니다.
<%@ language = vbscript%> <html> <head> <link rel = "스타일 시트"href = "tree.css"> <title> tree </title> </head> <!-#include file = "tree.asp"-> <%=============================== '======================================== ' This approach would be best suited for building ' dynamic trees using For..Next loops and such. set mytree2 = new tree mytree2.top = 10 mytree2.left = 10 mytree2.expandimage = "plus.gif"mytree2.collapseimage = "minus.gif"mytree2.leafimage = "webpage.gif" 'hierarchy set node1 = mytree2를 나타내는 데 사용되는 들여 쓰기. Node1.CreateChild ( "Server") SECSUBNODE1 = SUBNODE1.CREATECHILD ( "HTML") SECSUBNODE1.CREATECHILD "<a href =" ""http://127.0.0.0.1/ ""> asp </a> "Secsubnode1.createChild"<a href = ""http://127.0.0.1/ ""> php </a> "secsubnode1.createchild"<a href = ""http://127.0.0.1/ "" "> jsp </a>"set subnode2 = node1.createchild ( "Os") <<</creat.creat. " href = ""#""> winnt </a> "subnode2.createchild"<a href = "#" "#" "> win2000 </a>"set node2 = mytree2.createchild ( "goodtop") node2.createchild "<a href ="#""> 영역 코드 xookup < ""<a href = ""##"##"#" WHOIS 검색 </a> "node2.createChild"<a href = ""#""> World Time Zone Map </a> "myTree2.Draw () set myTree2 = nothing %> </body> </html>
2. tree.asp 클래스의 정의 코드는 다음과 같습니다.
<% '************************************************************ ' Author: Jacob Gilley ' Email: [email protected] ' My Terms: You can use this control in anyway you see fit ' cause I have no means to enforce any guidelines ' or BS that most developers think they can get ' you to agree to by spouting out words like ' "intellectual property" and "The Code 신 ". '-Viva La Microsoft! '****************************************************************** Dim gblTreeNodeCount:gblTreeNodeCount = 1 Class TreeNode Public Value Public ExpandImage Public CollapseImage Public LeafImage Public Expanded Private mszName Private mcolChildren Private mbChildrenInitialized Public Property Get ChildCount() ChildCount = mcolChildren.Count 엔드 속성 개인 sub class_initialize () mszname = "node"& cstr (gbltreenodecount) gbltreenodecount = gbltreenodedecount + 1 mbchildreninitialized = false subdepded = false sub class_terminate () if mbchildreninitialized 및 isobject (mcolchildren) nothing mcolchildren. 종료 IF 개인 하위 initchildList () set mcolchildren = server.createObject ( "scripting.dictionary") mbchildrenInitialized = true end sub private sub substate () request (mszname) = "1"또는 요청 ( "togglenode") = mszname = mmbalder (szval) (szvallen) (szvalud) (szvalud infed sub functions). 그런 다음 initchildlist () set createchild = new Treenode revingechild.value = szvalue createchild.expandimage = expandimage createChild.collapseimage = Collapseimage createChild.Leafimage = LeafImage McOlchildren.add McOlchildren.count + 1, CreateChild Sub () <alload -write () "" "" "" "" "" "" ""< & vbcrlf response.write "<tr> <td>"& vbcrlf resport.write "<a href =" "javaScript : caprapsenode ( '"& mszname & "'" "> <img src =" "" "& auspseimage &" ""0 "> </a>"& vbcrlf elseif not mbchildennininindinindinindinified resonation. "<img src =" "& leafimage &" "" "border = 0>"& vbcrlf else response.write "<a href =" "javaScript : expandNode ( '"& mszname & "')" "> <img src =" "" ""& expandimage & "" "0 </a>"& vbcrf end. vbcrlf response.write "<td>"& value & "</td> </tr>"& vbcrlf response.write "<input type ="hidden ""name = "" "& mszname &" ""value = ""<td> ""<td> ""<td> ""<td> ""<td> "" "<td>" "vbcrlf. vbcrlf response.write "<td>"& vbcrlf는 mcolchildren.items childnode.draw () next response.write "</td>"& vbcrlf response.write "</tr>"& vbcrlf public public public explat gend public public explate "& vbcrlf replation"& vbcrlf end public public expse LeafImage Private MSZPosition Private McOlchildren Public Property Public Property Let Absolute (BDATA) BDATA (BDATA)라면 MSZPosition = "절대"Else "MSZPosition ="상대적 "END PROPULE PROPIL PROPULE PROPULE PROPULE PROPULE PROPULE () 절대 = CBOOL (MSZPosition ="Absolute ") END Property Class_Initialize () SET MCOLCHILDREN = MCOLCHILDREN = 0 MNITOTATIATATIOT.") mnposition = "절대"엔드 하위 개인 sub class_terminate () mcolchildren.removeall () set mcolchildren = nody end sub public function createChild (szvalue) set createChild = new Treenode createChild.value = szValue createChild.expandimage = expandimuled.collapsimage = createchild.collapsimage mcolchildren.add mcolchildren.count + 1, createchild end function public sub loadtemplate (szfilename) dim colnodestack dim fsobj, tsobj dim szline dim ncurrdepth, nnextdepth set colnodestack = server.createobject ( "scripting.")))). createobject ( "scripting.filesystemobject") set tsobj = fsobj.opentextfile (szfilename, 1) ncurrdepth = 0 tsobj.atendofline nnextdepth = 1 szline = tsobj.readline ()이면 ncurrdepth = 0이면 createChild (trime). ncurrdepth = 1 whiled mid (szline, nnextdepth, 1) = vbtab 또는 mid (szline, nnextdepth, 1) = ""nnextDepth = nnextDepth + 1 if nnextDepth> 1이면 szline = trim (szline, nnextDepth)이면 nnextdepth < ""if nnextdepth < " 그런 다음 colnodestack.exists (ncurrdepth)를 설정하면 colnodestack.item (ncurrdepth) = objworkingNode else colnodestack.add ncurrdepth, objworkingnode end를 설정하면 objworkingnode.createchild (szline) ncurrdepth = ncurrdepth + 1 elsefth + 1 elsefth + 1 ncurrdepth 그러면 nnextDepth> 1이라면 nnextDepth = nnextDepth -1은 colnodestack.exists (nnextDepth) 및 nnextDepth> 1 nnextDepth = nnextDepth -1 wend set set objworkingnode = colnodestack.item (nnextdepth) set objworkingnode = objworkingnode.createchild (szline) nnextdepth = nnextDepth + 1 else set objworkingnode = createChild (szline) 끝 If ncurrdepth = nnextDepth END IF END IF WEND TSOBJ.CLOSE (set tsobj = nothing fsobj = nothing enlodestack.removealestack.removealestack.removealestack. sub draw () addclientscript () response.write "<div id =" "treectrl" "style =" "왼쪽 :"& left & "px; 상단 : "& TOP &"PX; 위치 : "& mszposition &"; ""> "& vbcrlf response.write"<form name = ""treectrlfrm ""action = "" "& request.servervariables ("script_name ") &" "method =" "get" ">"<td> "" "& vbcrlf. vbcrlf response.write "<input type =" "hidden" "name =" "togglenode" "value =" "" ""> "& vbcrlf response.write"</form> "& vbcrlf response.write"</div> "& vbcrlf 개인 서브 클리언트 스크립트 () %> <javaScript"> function "> function"> function "> javclf response"</div> " if (document.layers! = null) {document.treectrl.document.treectrlfrm.togglenode.value = sznodename; All [treectrlfrm "]. upply ()} inture collapsenode (sznodename) {null). document.trectrlfrm.Elements [sznodename] .Value = -1; document.treectlfrm.submit (); }} </script> < % end sub end class %>