HTMLUtil.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace OpenSim.Region.UserStatistics
  5. {
  6. public static class HTMLUtil
  7. {
  8. public static void TR_O(ref StringBuilder o, string pclass)
  9. {
  10. o.Append("<tr");
  11. if (pclass.Length > 0)
  12. {
  13. GenericClass(ref o, pclass);
  14. }
  15. o.Append(">\n\t");
  16. }
  17. public static void TR_C(ref StringBuilder o)
  18. {
  19. o.Append("</tr>\n");
  20. }
  21. public static void TD_O(ref StringBuilder o, string pclass)
  22. {
  23. o.Append("<td");
  24. if (pclass.Length > 0)
  25. {
  26. GenericClass(ref o, pclass);
  27. }
  28. o.Append(">");
  29. }
  30. public static void TD_C(ref StringBuilder o)
  31. {
  32. o.Append("</td>");
  33. }
  34. public static void TABLE_O(ref StringBuilder o, string pclass)
  35. {
  36. o.Append("<table");
  37. if (pclass.Length > 0)
  38. {
  39. GenericClass(ref o, pclass);
  40. }
  41. o.Append(">\n\t");
  42. }
  43. public static void TABLE_C(ref StringBuilder o)
  44. {
  45. o.Append("</table>\n");
  46. }
  47. public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
  48. {
  49. o.Append("<blockquote");
  50. if (pclass.Length > 0)
  51. {
  52. GenericClass(ref o, pclass);
  53. }
  54. o.Append(" />\n");
  55. }
  56. public static void BLOCKQUOTE_C(ref StringBuilder o)
  57. {
  58. o.Append("</blockquote>\n");
  59. }
  60. public static void BR(ref StringBuilder o)
  61. {
  62. o.Append("<br />\n");
  63. }
  64. public static void HR(ref StringBuilder o, string pclass)
  65. {
  66. o.Append("<hr");
  67. if (pclass.Length > 0)
  68. {
  69. GenericClass(ref o, pclass);
  70. }
  71. o.Append(" />\n");
  72. }
  73. public static void UL_O(ref StringBuilder o, string pclass)
  74. {
  75. o.Append("<ul");
  76. if (pclass.Length > 0)
  77. {
  78. GenericClass(ref o, pclass);
  79. }
  80. o.Append(" />\n");
  81. }
  82. public static void UL_C(ref StringBuilder o)
  83. {
  84. o.Append("</ul>\n");
  85. }
  86. public static void OL_O(ref StringBuilder o, string pclass)
  87. {
  88. o.Append("<ol");
  89. if (pclass.Length > 0)
  90. {
  91. GenericClass(ref o, pclass);
  92. }
  93. o.Append(" />\n");
  94. }
  95. public static void OL_C(ref StringBuilder o)
  96. {
  97. o.Append("</ol>\n");
  98. }
  99. public static void LI_O(ref StringBuilder o, string pclass)
  100. {
  101. o.Append("<li");
  102. if (pclass.Length > 0)
  103. {
  104. GenericClass(ref o, pclass);
  105. }
  106. o.Append(" />\n");
  107. }
  108. public static void LI_C(ref StringBuilder o)
  109. {
  110. o.Append("</li>\n");
  111. }
  112. public static void GenericClass(ref StringBuilder o, string pclass)
  113. {
  114. o.Append(" class=\"");
  115. o.Append(pclass);
  116. o.Append("\"");
  117. }
  118. public static void InsertProtoTypeAJAX(ref StringBuilder o)
  119. {
  120. o.Append("<script type=\"text/javascript\" src=\"prototype.js\"></script>\n");
  121. o.Append("<script type=\"text/javascript\" src=\"updater.js\"></script>\n");
  122. }
  123. public static void InsertPeriodicUpdaters(ref StringBuilder o, string[] divID, int[] seconds, string[] reportfrag)
  124. {
  125. o.Append("<script type=\"text/javascript\">\n");
  126. o.Append(
  127. @"
  128. // <![CDATA[
  129. document.observe('dom:loaded', function() {
  130. /*
  131. first arg : div to update
  132. second arg : interval to poll in seconds
  133. third arg : file to get data
  134. */
  135. ");
  136. for (int i = 0; i < divID.Length; i++)
  137. {
  138. o.Append("new updater('");
  139. o.Append(divID[i]);
  140. o.Append("', ");
  141. o.Append(seconds[i]);
  142. o.Append(", '");
  143. o.Append(reportfrag[i]);
  144. o.Append("');\n");
  145. }
  146. o.Append(@"
  147. });
  148. // ]]>
  149. </script>");
  150. }
  151. public static void HtmlHeaders_O ( ref StringBuilder o)
  152. {
  153. o.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
  154. o.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"nl\">");
  155. o.Append("<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
  156. }
  157. public static void HtmlHeaders_C ( ref StringBuilder o)
  158. {
  159. o.Append("</HEAD>");
  160. o.Append("<BODY>");
  161. }
  162. }
  163. }