Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
7.3 KiB

  1. <%
  2. '-------------------------------------------------------------------------
  3. ' Server Appliance Web Framework Tree Widget
  4. ' Copyright (c) Microsoft Corporation. All rights reserved.
  5. '-------------------------------------------------------------------------
  6. Call SAI_EnablePageCaching(TRUE)
  7. %>
  8. <!-- #include file="inc_framework.asp" -->
  9. <%
  10. If Len(Trim(Request.QueryString("TreeContainer"))) > 0 Then
  11. Call SA_RenderTree(Request.QueryString("TreeContainer"))
  12. End If
  13. Function SA_RenderTree(ByVal sContainer)
  14. Call SA_TreeEmitPageHeader()
  15. Response.Write("<table><tr><td nowrap>")
  16. Call WriteLine("<form name='frmTreeWidget' method='post' action=""sh_tree.asp?TreeContainer="+Server.URLEncode(sContainer)+""" >")
  17. Call SA_RenderTreeNodes(sContainer, "" )
  18. Call WriteLine("<input type='hidden' name='" & SAI_FLD_PAGEKEY & "' value='" & SAI_GetPageKey() & "' >")
  19. Call WriteLine("<input type='hidden' name=fieldSelectedElement value='"+Request.Form("fieldSelectedElement")+"' >")
  20. Call WriteLine("<input type='hidden' name=fieldImageLeaf value='"+GetImageParam("fieldImageLeaf")+"' >")
  21. Call WriteLine("<input type='hidden' name=fieldImageNodeOpened value='"+GetImageParam("fieldImageNodeOpened")+"' >")
  22. Call WriteLine("<input type='hidden' name=fieldImageNodeClosed value='"+GetImageParam("fieldImageNodeClosed")+"' >")
  23. Call WriteLine("</form>")
  24. Response.Write("</td></tr></table>")
  25. Call SA_TreeEmitPageFooter()
  26. End Function
  27. Function SA_RenderTreeNodes(ByVal sContainer, ByVal sSelectedHelpTOC)
  28. On Error Resume Next
  29. Err.Clear
  30. Dim oContainer
  31. Dim oElement
  32. Dim sHelpLoc
  33. Dim bIsContainer
  34. Dim sCurrentElementID
  35. sCurrentElementID = Request.Form("fieldSelectedElement")
  36. Set oContainer = GetElements(sContainer)
  37. If ( Err.Number <> 0 ) Then
  38. Call SA_TraceOut("SH_TREE", "GetElements("+sContainer+") returned error: " + CStr(Hex(Err.Number)) )
  39. Err.Clear
  40. Exit Function
  41. End If
  42. Call SA_GetHelpRootDirectory(sHelpLoc)
  43. If ( oContainer.Count > 0 ) Then
  44. WriteLine("<DIV class=HelpTOCItem>")
  45. For each oElement in oContainer
  46. Dim sImageURL
  47. Dim sCaption
  48. Dim sHelpURL
  49. Dim sOnClickHandler
  50. Dim sClassAttribute
  51. Dim F_IsLeafSelected
  52. Dim ElementID
  53. ElementID = oElement.GetProperty("ElementID")
  54. F_IsLeafSelected = Request.Form(ElementID)
  55. If ( Trim(F_IsLeafSelected) <> "1" ) Then
  56. F_IsLeafSelected = "0"
  57. End If
  58. sHelpURL = sHelpLoc+oElement.GetProperty("URL")
  59. If ( SA_IsParentNode(ElementID) ) Then
  60. bIsContainer = TRUE
  61. If ( Int(F_IsLeafSelected) > 0 ) Then
  62. sImageURL = GetImageParam("fieldImageNodeClosed")
  63. Else
  64. sImageURL = GetImageParam("fieldImageNodeOpened")
  65. End If
  66. sOnClickHandler = "onClick=""return SA_OnTreeClick('"+sHelpURL+"', '"+ElementID+"' );"" "
  67. WriteLine("<input type=hidden value='"+F_IsLeafSelected+"' name='"+ElementID+"' >")
  68. If ( (ElementID = sCurrentElementID) ) Then
  69. sClassAttribute=" class='ActiveTreeNode' "
  70. Else
  71. sClassAttribute=" class='InActiveTreeNode' "
  72. End If
  73. Else
  74. bIsContainer = FALSE
  75. sImageURL = GetImageParam("fieldImageLeaf")
  76. sOnClickHandler = "onClick=""return SA_OnTreeClick('"+sHelpURL+"', '"+ElementID+"' );"" "
  77. WriteLine("<input type=hidden value='0' name='"+ElementID+"' >")
  78. If ( F_IsLeafSelected ) Then
  79. sClassAttribute=" class='ActiveTreeNode' "
  80. Else
  81. sClassAttribute=" class='InActiveTreeNode' "
  82. End If
  83. End If
  84. sCaption = GetLocString(oElement.GetProperty("Source"), oElement.GetProperty("CaptionRID"), "" )
  85. WriteLine("<SPAN ")
  86. WriteLine(sClassAttribute)
  87. WriteLine(sOnClickHandler)
  88. WriteLine(" >")
  89. WriteLine("<img src='"+sImageURL+"' >")
  90. WriteLine(sCaption)
  91. WriteLine("</SPAN><BR>")
  92. If ( bIsContainer ) Then
  93. If ( Int(F_IsLeafSelected) > 0 ) Then
  94. Call SA_RenderTreeNodes(ElementID, "")
  95. End If
  96. End If
  97. Next
  98. WriteLine("</DIV>")
  99. End If
  100. End Function
  101. Function SA_IsParentNode(ByVal sContainer)
  102. On Error Resume Next
  103. Err.Clear
  104. SA_IsParentNode = FALSE
  105. Dim oContainer
  106. Set oContainer = GetElements(sContainer)
  107. If ( Err.Number <> 0 ) Then
  108. Call SA_TraceOut("SH_TREE", "GetElements("+sContainer+") returned error: " + CStr(Hex(Err.Number)) )
  109. Err.Clear
  110. Exit Function
  111. End If
  112. If ( oContainer.Count > 0 ) Then
  113. 'Call SA_TraceOut("SH_TREE", "Container: " + sContainer + " contains " + CStr(oContainer.Count) + " elements.")
  114. SA_IsParentNode = TRUE
  115. End If
  116. Set oContainer = nothing
  117. End Function
  118. Function GetHelpLoc()
  119. GetHelpLoc = "help" + "/"
  120. End Function
  121. Function SA_TreeEmitPageHeader()
  122. %>
  123. <html>
  124. <!-- Web Framework End User Help -->
  125. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  126. <head>
  127. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  128. <%
  129. Call SA_EmitAdditionalStyleSheetReferences("")
  130. %>
  131. <script language="JavaScript" src="<%=m_VirtualRoot%>sh_page.js"></script>
  132. <script>
  133. function SA_OnTreeClick(sHelpURL, sElementID)
  134. {
  135. //
  136. // Show the HELP page
  137. var i;
  138. //alert("SA_OnTreeClick("+sHelpURL+")");
  139. sHelpURL = SA_MungeURL(sHelpURL, SAI_FLD_PAGEKEY, g_strSAIPageKey);
  140. parent.IFrameHelpContent.location = sHelpURL;
  141. //
  142. // Expand the tree
  143. if ( sElementID.length > 0 )
  144. {
  145. var i, j;
  146. for( i = 0; i < window.document.forms.length; i++ )
  147. {
  148. //
  149. // Locate the Tree Widget FORM
  150. if ( window.document.forms[i].name == 'frmTreeWidget' )
  151. {
  152. //
  153. // Locate the selected tree NODE
  154. for( j = 0; j < window.document.forms[i].elements.length; j++)
  155. {
  156. if ( window.document.forms[i].elements[j].name == 'fieldSelectedElement' )
  157. {
  158. //
  159. // Store the currently selected element id
  160. //
  161. window.document.forms[i].elements[j].value = sElementID;
  162. }
  163. else if ( window.document.forms[i].elements[j].name == sElementID )
  164. {
  165. //
  166. // Toggle the selection state
  167. //
  168. if (window.document.forms[i].elements[j].value == '1')
  169. {
  170. window.document.forms[i].elements[j].value = '0';
  171. }
  172. else
  173. {
  174. window.document.forms[i].elements[j].value = '1';
  175. }
  176. }
  177. }
  178. window.document.forms[i].submit();
  179. }
  180. }
  181. }
  182. return true;
  183. }
  184. </script>
  185. </head>
  186. <body>
  187. <%
  188. End Function
  189. Function SA_TreeEmitPageFooter()
  190. %>
  191. </body>
  192. </html>
  193. <%
  194. End Function
  195. Function WriteLine(ByRef sLine)
  196. Response.Write(sLine+vbCrLf)
  197. End Function
  198. Private Function GetImageParam(ByVal sWhichImage)
  199. Dim sImage
  200. Select Case (UCase(sWhichImage))
  201. Case UCase("fieldImageLeaf")
  202. sImage = Request("fieldImageLeaf")
  203. If ( Len(sImage) <= 0 ) Then
  204. sImage = "images/book_page.gif"
  205. End If
  206. Case UCase("fieldImageNodeOpened")
  207. sImage = Request("fieldImageNodeOpened")
  208. If ( Len(sImage) <= 0 ) Then
  209. sImage = "images/book_closed.gif"
  210. End If
  211. Case UCase("fieldImageNodeClosed")
  212. sImage = Request("fieldImageNodeClosed")
  213. If ( Len(sImage) <= 0 ) Then
  214. sImage = "images/book_opened.gif"
  215. End If
  216. Case Else
  217. sImage = Request("fieldImageLeaf")
  218. If ( Len(sImage) <= 0 ) Then
  219. sImage = "images/book_page.gif"
  220. End If
  221. End Select
  222. GetImageParam = sImage
  223. End Function
  224. %>