Debian Codegraph @

docs/csharp/LoadIndexKeywords.aspx

raw
1 <%@ Page Language="C#" EnableViewState="False" %>
2
3 <script runat="server">
4 //=============================================================================
5 // System : Sandcastle Help File Builder
6 // File : LoadIndexKeywords.aspx
7 // Author : Eric Woodruff ([email protected]) from code by Ferdinand Prantl
8 // Updated : 04/01/2008
9 // Note : Copyright 2008, Eric Woodruff, All rights reserved
10 // Compiler: Microsoft C#
11 //
12 // This file contains the code used to search for keywords within the help
13 // topics using the full-text index files created by the help file builder.
14 //
15 // This code is published under the Microsoft Public License (Ms-PL). A copy
16 // of the license should be distributed with the code. It can also be found
17 // at the project website: http://SHFB.CodePlex.com. This notice, the
18 // author's name, and all copyright notices must remain intact in all
19 // applications, documentation, and source files.
20 //
21 // Version Date Who Comments
22 // ============================================================================
23 // 1.6.0.7 04/01/2008 EFW Created the code
24 //=============================================================================
25
26 /// <summary>
27 /// Render the keyword index
28 /// </summary>
29 /// <param name="writer">The writer to which the results are written</param>
30 protected override void Render(HtmlTextWriter writer)
31 {
32 XmlDocument ki;
33 XmlNode root, node;
34 StringBuilder sb = new StringBuilder(10240);
35 int startIndex = 0, endIndex;
36 string url, target;
37
38 ki = new XmlDocument();
39 ki.Load(Server.MapPath("WebKI.xml"));
40 root = ki.SelectSingleNode("HelpKI");
41
42 if(Request.QueryString["StartIndex"] != null)
43 startIndex = Convert.ToInt32(Request.QueryString["StartIndex"]) * 128;
44
45 endIndex = startIndex + 128;
46
47 if(endIndex > root.ChildNodes.Count)
48 endIndex = root.ChildNodes.Count;
49
50 if(startIndex > 0)
51 {
52 sb.Append("<div class=\"IndexItem\">\r\n" +
53 "<span>&nbsp;</span><a class=\"UnselectedNode\" " +
54 "onclick=\"javascript: return ChangeIndexPage(-1);\" " +
55 "href=\"#\"><b><< Previous page</b></a>\r\n</div>\r\n");
56 }
57
58 while(startIndex < endIndex)
59 {
60 node = root.ChildNodes[startIndex];
61
62 if(node.Attributes["Url"] == null)
63 {
64 url = "#";
65 target = String.Empty;
66 }
67 else
68 {
69 url = node.Attributes["Url"].Value;
70 target = " target=\"TopicContent\"";
71 }
72
73 sb.AppendFormat("<div class=\"IndexItem\">\r\n" +
74 "<span>&nbsp;</span><a class=\"UnselectedNode\" " +
75 "onclick=\"javascript: return SelectIndexNode(this);\" " +
76 "href=\"{0}\"{1}>{2}</a>\r\n", url, target,
77 HttpUtility.HtmlEncode(node.Attributes["Title"].Value));
78
79 if(node.ChildNodes.Count != 0)
80 foreach(XmlNode subNode in node.ChildNodes)
81 sb.AppendFormat("<div class=\"IndexSubItem\">\r\n" +
82 "<img src=\"Item.gif\"/><a class=\"UnselectedNode\" " +
83 "onclick=\"javascript: return SelectIndexNode(this);\" " +
84 "href=\"{0}\" target=\"TopicContent\">{1}</a>\r\n</div>\r\n",
85 subNode.Attributes["Url"].Value,
86 HttpUtility.HtmlEncode(subNode.Attributes["Title"].Value));
87
88 sb.Append("</div>\r\n");
89
90 startIndex++;
91 }
92
93 if(startIndex < root.ChildNodes.Count)
94 sb.Append("<div class=\"IndexItem\">\r\n" +
95 "<span>&nbsp;</span><a class=\"UnselectedNode\" " +
96 "onclick=\"javascript: return ChangeIndexPage(1);\" " +
97 "href=\"#\"><b>Next page >></b></a>\r\n</div>\r\n");
98
99 writer.Write(sb.ToString());
100 }
101
102 </script>