aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/UserStatistics/HTMLUtil.cs
blob: bc21c55d6cfadd8b036b89c50906a3d5d062ec61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
 * Copyright (c) Contributors, http://opensimulator.org/
 * See CONTRIBUTORS.TXT for a full list of copyright holders.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSimulator Project nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace OpenSim.Region.UserStatistics
{
    public static class HTMLUtil
    {

        public static void TR_O(ref StringBuilder o, string pclass)
        {
            o.Append("<tr");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(">\n\t");
        }
        public static void TR_C(ref StringBuilder o)
        {
            o.Append("</tr>\n");
        }

        public static void TD_O(ref StringBuilder o, string pclass)
        {
            o.Append("<td");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(">");
        }
        public static void TD_C(ref StringBuilder o)
        {
            o.Append("</td>");
        }
        public static void TABLE_O(ref StringBuilder o, string pclass)
        {
            o.Append("<table");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(">\n\t");
        }
        public static void TABLE_C(ref StringBuilder o)
        {
            o.Append("</table>\n");
        }
        
        public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
        {
            o.Append("<blockquote");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(" />\n");
        }

        public static void BLOCKQUOTE_C(ref StringBuilder o)
        {
            o.Append("</blockquote>\n");
        }

        public static void BR(ref StringBuilder o)
        {
            o.Append("<br />\n");
        }

        public static void HR(ref StringBuilder o, string pclass)
        {
            o.Append("<hr");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(" />\n");
        }

        public static void UL_O(ref StringBuilder o, string pclass)
        {
            o.Append("<ul");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(" />\n");
        }

        public static void UL_C(ref StringBuilder o)
        {
            o.Append("</ul>\n");
        }

        public static void OL_O(ref StringBuilder o, string pclass)
        {
            o.Append("<ol");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(" />\n");
        }

        public static void OL_C(ref StringBuilder o)
        {
            o.Append("</ol>\n");
        }

        public static void LI_O(ref StringBuilder o, string pclass)
        {
            o.Append("<li");
            if (pclass.Length > 0)
            {
                GenericClass(ref o, pclass);
            }
            o.Append(" />\n");
        }

        public static void LI_C(ref StringBuilder o)
        {
            o.Append("</li>\n");
        }

        public static void GenericClass(ref StringBuilder o, string pclass)
        {
            o.Append(" class=\"");
            o.Append(pclass);
            o.Append("\"");
        }

        public static void InsertProtoTypeAJAX(ref StringBuilder o)
        {
            o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n");
            o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n");
        }

        public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag)
        {
            o.Append("<script type=\"text/javascript\">\n");
            o.Append(
                @"
                // <![CDATA[
                document.observe('dom:loaded', function() {
                    /*
                    first arg    : div to update
                    second arg    : interval to poll in seconds
                    third arg    : file to get data
                    */
");
            for (int i = 0; i < divID.Length; i++)
            {
            
                o.Append("new updater('");
                o.Append(divID[i]);
                o.Append("', ");
                o.Append(seconds[i]);
                o.Append(", '");
                o.Append(reportfrag[i]);
                o.Append("');\n");
            }

            o.Append(@"
                });
                // ]]>
                </script>");

        }

        public static void HtmlHeaders_O ( ref StringBuilder o)
        {
            o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
            o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">");
            o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");


        }
        public static void HtmlHeaders_C ( ref StringBuilder o)
        {
            o.Append("</HEAD>");
            o.Append("<BODY>");
        }
    }
}