diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs | 263 |
1 files changed, 263 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs b/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs new file mode 100644 index 0000000..c07619f --- /dev/null +++ b/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs | |||
@@ -0,0 +1,263 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Region.UserStatistics | ||
33 | { | ||
34 | public static class HTMLUtil | ||
35 | { | ||
36 | |||
37 | public static void TR_O(ref StringBuilder o, string pclass) | ||
38 | { | ||
39 | o.Append("<tr"); | ||
40 | if (pclass.Length > 0) | ||
41 | { | ||
42 | GenericClass(ref o, pclass); | ||
43 | } | ||
44 | o.Append(">\n\t"); | ||
45 | } | ||
46 | |||
47 | public static void TR_C(ref StringBuilder o) | ||
48 | { | ||
49 | o.Append("</tr>\n"); | ||
50 | } | ||
51 | |||
52 | public static void TD_O(ref StringBuilder o, string pclass) | ||
53 | { | ||
54 | TD_O(ref o, pclass, 0, 0); | ||
55 | } | ||
56 | |||
57 | public static void TD_O(ref StringBuilder o, string pclass, int rowspan, int colspan) | ||
58 | { | ||
59 | o.Append("<td"); | ||
60 | if (pclass.Length > 0) | ||
61 | { | ||
62 | GenericClass(ref o, pclass); | ||
63 | } | ||
64 | if (rowspan > 1) | ||
65 | { | ||
66 | o.Append(" rowspan=\""); | ||
67 | o.Append(rowspan); | ||
68 | o.Append("\""); | ||
69 | } | ||
70 | if (colspan > 1) | ||
71 | { | ||
72 | o.Append(" colspan=\""); | ||
73 | o.Append(colspan); | ||
74 | o.Append("\""); | ||
75 | } | ||
76 | o.Append(">"); | ||
77 | } | ||
78 | |||
79 | public static void TD_C(ref StringBuilder o) | ||
80 | { | ||
81 | o.Append("</td>"); | ||
82 | } | ||
83 | |||
84 | public static void TABLE_O(ref StringBuilder o, string pclass) | ||
85 | { | ||
86 | o.Append("<table"); | ||
87 | if (pclass.Length > 0) | ||
88 | { | ||
89 | GenericClass(ref o, pclass); | ||
90 | } | ||
91 | o.Append(">\n\t"); | ||
92 | } | ||
93 | |||
94 | public static void TABLE_C(ref StringBuilder o) | ||
95 | { | ||
96 | o.Append("</table>\n"); | ||
97 | } | ||
98 | |||
99 | public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass) | ||
100 | { | ||
101 | o.Append("<blockquote"); | ||
102 | if (pclass.Length > 0) | ||
103 | { | ||
104 | GenericClass(ref o, pclass); | ||
105 | } | ||
106 | o.Append(" />\n"); | ||
107 | } | ||
108 | |||
109 | public static void BLOCKQUOTE_C(ref StringBuilder o) | ||
110 | { | ||
111 | o.Append("</blockquote>\n"); | ||
112 | } | ||
113 | |||
114 | public static void BR(ref StringBuilder o) | ||
115 | { | ||
116 | o.Append("<br />\n"); | ||
117 | } | ||
118 | |||
119 | public static void HR(ref StringBuilder o, string pclass) | ||
120 | { | ||
121 | o.Append("<hr"); | ||
122 | if (pclass.Length > 0) | ||
123 | { | ||
124 | GenericClass(ref o, pclass); | ||
125 | } | ||
126 | o.Append(" />\n"); | ||
127 | } | ||
128 | |||
129 | public static void UL_O(ref StringBuilder o, string pclass) | ||
130 | { | ||
131 | o.Append("<ul"); | ||
132 | if (pclass.Length > 0) | ||
133 | { | ||
134 | GenericClass(ref o, pclass); | ||
135 | } | ||
136 | o.Append(" />\n"); | ||
137 | } | ||
138 | |||
139 | public static void UL_C(ref StringBuilder o) | ||
140 | { | ||
141 | o.Append("</ul>\n"); | ||
142 | } | ||
143 | |||
144 | public static void OL_O(ref StringBuilder o, string pclass) | ||
145 | { | ||
146 | o.Append("<ol"); | ||
147 | if (pclass.Length > 0) | ||
148 | { | ||
149 | GenericClass(ref o, pclass); | ||
150 | } | ||
151 | o.Append(" />\n"); | ||
152 | } | ||
153 | |||
154 | public static void OL_C(ref StringBuilder o) | ||
155 | { | ||
156 | o.Append("</ol>\n"); | ||
157 | } | ||
158 | |||
159 | public static void LI_O(ref StringBuilder o, string pclass) | ||
160 | { | ||
161 | o.Append("<li"); | ||
162 | if (pclass.Length > 0) | ||
163 | { | ||
164 | GenericClass(ref o, pclass); | ||
165 | } | ||
166 | o.Append(" />\n"); | ||
167 | } | ||
168 | |||
169 | public static void LI_C(ref StringBuilder o) | ||
170 | { | ||
171 | o.Append("</li>\n"); | ||
172 | } | ||
173 | |||
174 | public static void GenericClass(ref StringBuilder o, string pclass) | ||
175 | { | ||
176 | o.Append(" class=\""); | ||
177 | o.Append(pclass); | ||
178 | o.Append("\""); | ||
179 | } | ||
180 | |||
181 | public static void InsertProtoTypeAJAX(ref StringBuilder o) | ||
182 | { | ||
183 | o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n"); | ||
184 | o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n"); | ||
185 | } | ||
186 | |||
187 | public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag) | ||
188 | { | ||
189 | o.Append("<script type=\"text/javascript\">\n"); | ||
190 | o.Append( | ||
191 | @" | ||
192 | // <![CDATA[ | ||
193 | document.observe('dom:loaded', function() { | ||
194 | /* | ||
195 | first arg : div to update | ||
196 | second arg : interval to poll in seconds | ||
197 | third arg : file to get data | ||
198 | */ | ||
199 | "); | ||
200 | for (int i = 0; i < divID.Length; i++) | ||
201 | { | ||
202 | |||
203 | o.Append("new updater('"); | ||
204 | o.Append(divID[i]); | ||
205 | o.Append("', "); | ||
206 | o.Append(seconds[i]); | ||
207 | o.Append(", '"); | ||
208 | o.Append(reportfrag[i]); | ||
209 | o.Append("');\n"); | ||
210 | } | ||
211 | |||
212 | o.Append(@" | ||
213 | }); | ||
214 | // ]]> | ||
215 | </script>"); | ||
216 | } | ||
217 | |||
218 | public static void HtmlHeaders_O(ref StringBuilder o) | ||
219 | { | ||
220 | o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"); | ||
221 | o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">"); | ||
222 | o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />"); | ||
223 | } | ||
224 | |||
225 | public static void HtmlHeaders_C(ref StringBuilder o) | ||
226 | { | ||
227 | o.Append("</HEAD>"); | ||
228 | o.Append("<BODY>"); | ||
229 | } | ||
230 | |||
231 | public static void AddReportLinks(ref StringBuilder o, Dictionary<string, IStatsController> reports, string pClass) | ||
232 | { | ||
233 | int repcount = 0; | ||
234 | foreach (string str in reports.Keys) | ||
235 | { | ||
236 | if (reports[str].ReportName.Length > 0) | ||
237 | { | ||
238 | if (repcount > 0) | ||
239 | { | ||
240 | o.Append("| "); | ||
241 | } | ||
242 | A(ref o, reports[str].ReportName, str, pClass); | ||
243 | o.Append(" "); | ||
244 | repcount++; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | public static void A(ref StringBuilder o, string linktext, string linkhref, string pClass) | ||
250 | { | ||
251 | o.Append("<A"); | ||
252 | if (pClass.Length > 0) | ||
253 | { | ||
254 | GenericClass(ref o, pClass); | ||
255 | } | ||
256 | o.Append(" href=\""); | ||
257 | o.Append(linkhref); | ||
258 | o.Append("\">"); | ||
259 | o.Append(linktext); | ||
260 | o.Append("</A>"); | ||
261 | } | ||
262 | } | ||
263 | } | ||