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.

290 lines
7.3 KiB

  1. //
  2. // file globals.
  3. //
  4. var bRunOnce = false;
  5. var oTSDiagObject = null;
  6. var bAllVisible = false;
  7. function SwitchShowHide ()
  8. {
  9. bAllVisible = !bAllVisible
  10. //
  11. // call show hide to update our display.
  12. //
  13. ShowHide();
  14. document.returnValue = true;
  15. }
  16. function ShowHide()
  17. {
  18. strMouseHover = "status='Hi';return false ";
  19. if (bAllVisible)
  20. {
  21. // document.all.ResultTableId.caption.innerHTML = "<A href='javascript:;' onClick='ShowHide();return false;' >Show All results</A>";
  22. document.all.ResultTableId.caption.innerHTML = "<A href='javascript:;' onMouseover='status=\"Click this link to view all tests performed\"; return true' onClick='ShowHide();return false;' >Show All results</A>";
  23. }
  24. else
  25. {
  26. // document.all.ResultTableId.caption.innerHTML = "<A href='javascript:;' onClick='ShowHide();return false;' >Show Problems only</A>";
  27. document.all.ResultTableId.caption.innerHTML = "<A href='javascript:;' onMouseover='status=\"Click this link to view only problems detected\"; return true' onClick='ShowHide();return false;' >Show Problems Only</A>";
  28. }
  29. bAllVisible = !bAllVisible;
  30. for (i=0; i < document.all.ResultTableBody.rows.length; i++)
  31. {
  32. if (document.all.ResultTableBody.rows(i).style.color == "red")
  33. {
  34. // this is problem row.
  35. }
  36. else
  37. {
  38. if (bAllVisible)
  39. {
  40. document.all.ResultTableBody.rows(i).style.display="";
  41. }
  42. else
  43. {
  44. document.all.ResultTableBody.rows(i).style.display="none";
  45. }
  46. }
  47. }
  48. }
  49. function ExecuteIt (p_command)
  50. {
  51. if (oTSDiagObject)
  52. oTSDiagObject.ExecuteCommand(p_command);
  53. }
  54. function BuildTableHeader(oTableHeader, strText)
  55. {
  56. var oRow, oCell;
  57. // Insert a row into the header.
  58. oRow = oTableHeader.insertRow();
  59. oCell = oRow.insertCell();
  60. oCell.style.fontWeight = "bold";
  61. oCell.style.backgroundColor = "lightskyblue";
  62. oCell.colSpan = "4";
  63. oCell.innerText = strText;
  64. }
  65. function RunSuite(p_testsuite, p_machinename)
  66. {
  67. var bShowFailed = true;
  68. var bShowPassed = true;
  69. var bShowUnknown = true;
  70. var bShowFailedToExecute = true;
  71. var bShowTest = true;
  72. //
  73. // if we have run once already remove the previously created table.
  74. //
  75. if (bRunOnce)
  76. {
  77. oResultTable.removeChild(document.all.ResultTableId);
  78. }
  79. bRunOnce = true;
  80. //
  81. // create a table.
  82. //
  83. oTable = document.createElement("TABLE");
  84. var oTHead = document.createElement("THEAD");
  85. var oTBody0 = document.createElement("TBODY");
  86. oCaption = document.createElement("CAPTION");
  87. oCaption.style.fontSize = "10";
  88. oCaption.align = "left";
  89. oTable.appendChild(oTHead);
  90. oTable.appendChild(oTBody0);
  91. oTable.appendChild(oCaption);
  92. oTable.id = "ResultTableId";
  93. oTBody0.id = "ResultTableBody";
  94. //
  95. // now create our activex object.
  96. //
  97. try
  98. {
  99. oTSDiagObject = new ActiveXObject("TSDiag.TSDiagnosis");
  100. }
  101. catch (e)
  102. {
  103. alert("failed to create activex object. Please modify your browser's security settings and try again.");
  104. return;
  105. }
  106. try
  107. {
  108. //
  109. // if we are supplied a machine set it
  110. //
  111. if ((typeof(p_machinename) != "undefined") && p_machinename != "")
  112. {
  113. oTSDiagObject.MachineName = p_machinename;
  114. }
  115. else
  116. {
  117. oTSDiagObject.MachineName = "";
  118. }
  119. //
  120. // get the test suite supplied.
  121. //
  122. var oThisSuite = oTSDiagObject.Suites(p_testsuite);
  123. if (oThisSuite.IsApplicable)
  124. {
  125. //
  126. // since the suite is applicable will run test.
  127. //
  128. var bAllPassed = true;
  129. var numTests = oThisSuite.Count;
  130. for (i = 0; i < oThisSuite.Count; i++)
  131. {
  132. var oTest = oThisSuite(i);
  133. if (oTest.IsApplicable)
  134. {
  135. oTest.Execute();
  136. var oRow = oTBody0.insertRow();
  137. //
  138. // test name
  139. //
  140. var oCell = oRow.insertCell();
  141. oCell.innerText = oTest.Name;
  142. //
  143. // result string
  144. //
  145. oCell = oRow.insertCell();
  146. oCell.innerText = oTest.ResultString;
  147. if (oTest.Result == 0)
  148. {
  149. //
  150. // failed.
  151. //
  152. // oRow.style.color = "red";
  153. oCell.style.color = "red";
  154. oRow = oTBody0.insertRow();
  155. oCell = oRow.insertCell();
  156. oCell.colSpan = "4";
  157. oCell.innerHTML = oTest.ResultDetails;
  158. oRow.style.color = "red";
  159. oRow.style.fontWeight = "bold";
  160. bAllPassed = false;
  161. }
  162. else if (oTest.Result == 1)
  163. {
  164. // ePassed
  165. if (!bShowPassed)
  166. {
  167. oRow.style.display = "none";
  168. }
  169. }
  170. else if (oTest.Result == 2)
  171. {
  172. // eUnknown.
  173. if (!bShowUnknown)
  174. {
  175. oRow.style.display = "none";
  176. }
  177. }
  178. else if (oTest.Result == 4)
  179. {
  180. // eFailedToExecute
  181. if (!bShowFailedToExecute)
  182. {
  183. oRow.style.display = "none";
  184. }
  185. }
  186. else
  187. {
  188. // we do not know this result type.
  189. window.alert("unknown test result");
  190. }
  191. }
  192. }
  193. //
  194. // set the header accordingly
  195. //
  196. if (bAllPassed)
  197. {
  198. BuildTableHeader(oTHead, "No Problems were detected with this tool. For more information refer to terminal server help");
  199. }
  200. else
  201. {
  202. BuildTableHeader(oTHead, "Following problems were found. Please review them, click on links to fix the problems if available.");
  203. }
  204. }
  205. else
  206. {
  207. //
  208. // since the suite is NOT applicable we havent run the tests.
  209. // pupulate header describing why suite cannot be run.
  210. //
  211. BuildTableHeader(oTHead, oThisSuite.WhyNotApplicable);
  212. }
  213. oResultTable.appendChild(oTable);
  214. //
  215. // showhide swiches the bAllVisible to negate its effect switch it
  216. // before calling show hide.
  217. //
  218. bAllVisible = !bAllVisible;
  219. //
  220. // call showhide to create a caption link.
  221. //
  222. ShowHide();
  223. }
  224. catch (e)
  225. {
  226. alert("failed while running tsdiag. sorry bout that. ");
  227. return;
  228. }
  229. }