Source code of Windows XP (NT5)
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.

479 lines
14 KiB

  1. <HTML id=dlgAnalyze STYLE="font-family: MS Shell Dlg; font-size: 8pt;
  2. width: 30em; height: 33em">
  3. <HEAD>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <META HTTP-EQUIV="MSThemeCompatible" CONTENT="Yes">
  6. <TITLE id=dialogTitle>
  7. Analyze Document
  8. </TITLE>
  9. <SCRIPT LANGUAGE="JavaScript" defer>
  10. #define HTMLKEYESCAPE 27
  11. window.onerror = HandleError
  12. //+-------------------------------------------------------------------
  13. //
  14. // Synopsis: Turns off error messages in dialogs
  15. //
  16. // Arguments: none
  17. //
  18. // returns: true (tells browser not to handle message)
  19. //
  20. //--------------------------------------------------------------------
  21. function HandleError(message, url, line)
  22. {
  23. var L_Dialog_ErrorMessage = "An error has occured in this dialog.";
  24. var L_ErrorNumber_Text = "Error: ";
  25. var str = L_Dialog_ErrorMessage + "\n\n"
  26. + L_ErrorNumber_Text + line + "\n"
  27. + message;
  28. alert (str);
  29. window.close();
  30. return true;
  31. }
  32. //+---------------------------------------------------------------------
  33. //
  34. // Synopsis: Returns the document object for the page to be analyzed
  35. //
  36. // Arguments: none
  37. //
  38. // returns: document object for the page to be analyzed
  39. //
  40. //----------------------------------------------------------------------
  41. function otherDocument()
  42. {
  43. return window.dialogArguments.document;
  44. }
  45. //+---------------------------------------------------------------------
  46. //
  47. // Synopsis: onload handler for this dialog. sets up events. Calls
  48. // analysis function.
  49. //
  50. // Arguments: none
  51. //
  52. // returns: none
  53. //
  54. //----------------------------------------------------------------------
  55. function loadBdy()
  56. {
  57. //
  58. // Bind events to controls. This is done here to load the dialog
  59. // quicker.
  60. //
  61. document.all.btnOk.onclick = new Function("window.close();");
  62. document.onkeyup = new Function("documentOnKeyUp()");
  63. runAnalysis();
  64. } // loadBdy
  65. //+---------------------------------------------------------------------
  66. //
  67. // Checks for the escape key and closes the dialog
  68. //
  69. //----------------------------------------------------------------------
  70. function documentOnKeyUp()
  71. {
  72. if (window.event.keyCode == HTMLKEYESCAPE)
  73. {
  74. window.close();
  75. }
  76. } // documentOnKeyUp
  77. //+---------------------------------------------------------------------
  78. //
  79. // Synopsis: Performs analysis function on primary document.
  80. // Initializes display error, then calls each of the individual
  81. // analysis functions in turn
  82. //
  83. // Arguments: none
  84. //
  85. // returns: none
  86. //
  87. //----------------------------------------------------------------------
  88. function runAnalysis()
  89. {
  90. var errorsFound, reportLocation;
  91. errorsFound = false;
  92. reportLocation = document.all.ReportArea;
  93. initializeResults(reportLocation);
  94. errorsFound = errorsFound || checkBodyWithinFrameset(reportLocation);
  95. errorsFound = errorsFound || checkAnythingAfterFrameset(reportLocation);
  96. errorsFound = errorsFound || checkUnloadedComponents(reportLocation);
  97. errorsFound = errorsFound || checkNonApartmentControls(reportLocation);
  98. errorsFound = errorsFound || checkUnloadedStyleSheets(reportLocation);
  99. if (errorsFound == false) {
  100. reportNothingFound(reportLocation);
  101. }
  102. }
  103. //+---------------------------------------------------------------------
  104. //
  105. // Synopsis: Sets the initial state of the results window - blank
  106. //
  107. // Arguments: none
  108. //
  109. // returns: none
  110. //
  111. //----------------------------------------------------------------------
  112. function initializeResults(reportLocation)
  113. {
  114. reportLocation.innerHTML = "&nbsp;";
  115. }
  116. //+---------------------------------------------------------------------
  117. //
  118. // Synopsis: If no errors found in document, reports that to user
  119. //
  120. // Arguments: none
  121. //
  122. // returns: none
  123. //
  124. //----------------------------------------------------------------------
  125. function reportNothingFound(reportLocation)
  126. {
  127. var L_NoErrors_Text = "No errors found.";
  128. reportLocation.innerHTML = L_NoErrors_Text;
  129. }
  130. //+---------------------------------------------------------------------
  131. //
  132. // Synopsis: Checks for existence of a frameset and a body on the same document
  133. //
  134. // Arguments: none
  135. //
  136. // returns: true if found, false if not
  137. //
  138. //----------------------------------------------------------------------
  139. function checkBodyWithinFrameset(reportLocation)
  140. {
  141. var theDocument;
  142. var framesets, bodies;
  143. var retVal;
  144. var L_FramesetInBody_Text = "This document might not display properly because there is a FRAMESET within the BODY of the document. The page author can resolve this problem by<OL><li>Removing the BODY tag.</li><li>Insuring that there is no additional HTML code between the HEAD of the document and the FRAMESET.</li></ol><br><hr>";
  145. retVal = false;
  146. theDocument = otherDocument();
  147. framesets = theDocument.all.tags("frameset");
  148. if (framesets.length > 0) {
  149. bodies = theDocument.all.tags("body");
  150. if (bodies.length > 0) {
  151. reportLocation.insertAdjacentHTML("BeforeEnd", L_FramesetInBody_Text );
  152. retVal = true;
  153. }
  154. }
  155. // tested case of implied body - looks like trident creates a body
  156. // tag even when one doesn't exist
  157. return retVal;
  158. }
  159. //+---------------------------------------------------------------------
  160. //
  161. // Synopsis: Checks for existence of any tags but comments after a frameset
  162. //
  163. // Arguments: none
  164. //
  165. // returns: true if found, false if not
  166. //
  167. //----------------------------------------------------------------------
  168. function checkAnythingAfterFrameset(reportLocation)
  169. {
  170. var L_ContentAfterFrameset_Text = "This document might not display properly because there is content after the FRAMESET.<br><hr>";
  171. var theDocument;
  172. var framesets;
  173. var i, startIndex;
  174. var retVal;
  175. retVal = false;
  176. theDocument = otherDocument();
  177. framesets = theDocument.all.tags("frameset");
  178. if (framesets.length > 0) {
  179. startIndex = framesets(0).sourceIndex;
  180. if (window.dialogArguments.anythingAfterFrameset) {
  181. reportLocation.insertAdjacentHTML("BeforeEnd", L_ContentAfterFrameset_Text );
  182. retVal = true;
  183. }
  184. }
  185. return retVal;
  186. }
  187. //+---------------------------------------------------------------------
  188. //
  189. // Synopsis: Checks for existence of objects, applets or embeds that are
  190. // readyState != complete
  191. //
  192. // Arguments: none
  193. //
  194. // returns: true if found, false if not
  195. //
  196. //----------------------------------------------------------------------
  197. function checkUnloadedComponents(reportLocation)
  198. {
  199. var theDocument;
  200. var objects, applets, embeds;
  201. var retVal;
  202. retVal = false;
  203. theDocument = otherDocument();
  204. objects = theDocument.all.tags("object");
  205. applets = theDocument.all.tags("applet");
  206. embeds = theDocument.all.tags("embed");
  207. retVal = checkReadyStateComplete(objects, reportLocation);
  208. retVal = retVal || checkReadyStateComplete(applets, reportLocation);
  209. retVal = retVal || checkReadyStateComplete(embeds, reportLocation);
  210. return retVal;
  211. }
  212. //+---------------------------------------------------------------------
  213. //
  214. // Synopsis: Checks for readystate = complete for collection passed in.
  215. // If any components found that are not readystate = complete
  216. // error is passed to reportLocation. Valid for object, applet
  217. // and embed
  218. //
  219. // Arguments: collection of elements to check for readystate = complete
  220. // area to report errors to
  221. //
  222. // returns: true if found, false if not
  223. //
  224. //----------------------------------------------------------------------
  225. function checkReadyStateComplete(objects, reportLocation)
  226. {
  227. var L_ObjectNotInstalled_Text = "The following OBJECT did not install properly.<BR>";
  228. var L_AppletNotInstalled_Text = "The following APPLET did not install properly.<BR>";
  229. var L_EmbedNotInstalled_Text = "The following EMBED did not install properly.<BR>";
  230. var L_ObjectNotInstalledReasons_Text = "<br><br>This might have been caused by one of the following conditions:<OL><LI>Your current security settings prevent this OBJECT from being used.</li><li>This OBJECT was not properly installed on your computer.</li><li>The page or OBJECT was authored incorrectly.</li></ul><hr>";
  231. var L_AppletNotInstalledReasons_Text = "<br><br>This might have been caused by one of the following conditions:<OL><LI>Your current security settings prevent this APPLET from being used.</li><li>This APPLET was not properly installed on your computer.</li><li>The page or APPLET was authored incorrectly.</li></ul><hr>";
  232. var L_EmbedNotInstalledReasons_Text = "<br><br>This might have been caused by one of the following conditions:<OL><LI>Your current security settings prevent this EMBED from being used.</li><li>This EMBED was not properly installed on your computer.</li><li>The page or EMBED was authored incorrectly.</li></ul><hr>";
  233. var strNotInstalled;
  234. var strNotInstalledReason;
  235. var i, element;
  236. var retVal;
  237. retVal = false;
  238. if (objects == null)
  239. return retVal;
  240. for (i=0; i < objects.length; i++) {
  241. element = objects(i);
  242. // looks like 4 = complete
  243. if (element.readyState != 4 && element.readyState != "complete") {
  244. switch (element.tagName.toLowerCase())
  245. {
  246. case "object":
  247. strNotInstalled = L_ObjectNotInstalled_Text;
  248. strNotInstalledReason = L_ObjectNotInstalledReasons_Text;
  249. break;
  250. case "applet":
  251. strNotInstalled = L_AppletNotInstalled_Text;
  252. strNotInstalledReason = L_AppletNotInstalledReasons_Text;
  253. break;
  254. case "embed":
  255. strNotInstalled = L_EmbedNotInstalled_Text;
  256. strNotInstalledReason = L_EmbedNotInstalledReasons_Text;
  257. break;
  258. }
  259. reportLocation.insertAdjacentHTML("BeforeEnd", strNotInstalled);
  260. reportLocation.insertAdjacentText("BeforeEnd", element.outerHTML);
  261. reportLocation.insertAdjacentHTML("BeforeEnd", strNotInstalledReason);
  262. retVal = true;
  263. }
  264. }
  265. return retVal;
  266. }
  267. //+---------------------------------------------------------------------
  268. //
  269. // Synopsis: Checks for existence ocx's that are known to be non-apartment
  270. // model
  271. //
  272. // Arguments: none
  273. //
  274. // returns: true if found, false if not
  275. //
  276. //----------------------------------------------------------------------
  277. function checkNonApartmentControls(reportLocation)
  278. {
  279. var L_ObjectNotApartmentModel_Text = "The following OBJECT may not work reliably in all circumstances because it doesn't use the Apartment threading model.<br>";
  280. var theDocument;
  281. var objects;
  282. var i;
  283. var retVal;
  284. retVal = false;
  285. theDocument = otherDocument();
  286. objects = theDocument.all.tags("object");
  287. for (i=0; i < objects.length; i++) {
  288. element = objects(i);
  289. nonApartmentModel = checkCLSIDForNonApartmentModel(element);
  290. retVal = retVal || nonApartmentModel;
  291. if (nonApartmentModel == true) {
  292. reportLocation.insertAdjacentHTML("BeforeEnd", L_ObjectNotApartmentModel_Text);
  293. reportLocation.insertAdjacentText("BeforeEnd", element.outerHTML);
  294. reportLocation.insertAdjacentHTML("BeforeEnd", "<br><hr>");
  295. }
  296. }
  297. return retVal;
  298. }
  299. //+---------------------------------------------------------------------
  300. //
  301. // Synopsis: Checks to see if specified clsid is for an apartment model
  302. // control
  303. //
  304. // Arguments: clsid to check
  305. //
  306. // returns: true if non-apartment model, false if apartment model
  307. //
  308. //----------------------------------------------------------------------
  309. function checkCLSIDForNonApartmentModel(element) {
  310. return !(window.dialogArguments.isApartmentModel(element));
  311. }
  312. //+---------------------------------------------------------------------
  313. //
  314. // Synopsis: Checks for any link tags where readyState != complete
  315. //
  316. // Arguments: none
  317. //
  318. // returns: true if found, false if not
  319. //
  320. //----------------------------------------------------------------------
  321. function checkUnloadedStyleSheets(reportLocation)
  322. {
  323. var theDocument;
  324. var links;
  325. var retVal;
  326. retVal = false;
  327. theDocument = otherDocument();
  328. links = theDocument.all.tags("link");
  329. retVal = checkLinkReadyStateComplete(links, reportLocation);
  330. return retVal;
  331. }
  332. //+---------------------------------------------------------------------
  333. //
  334. // Synopsis: Checks for readystate = complete for collection of links passed in.
  335. // If any links found that are not readystate = complete
  336. // error is passed to reportLocation. Note that separate function
  337. // is used for links because different error info needs to
  338. // be reported
  339. //
  340. // Arguments: collection of elements to check for readystate = complete
  341. // area to report errors to
  342. //
  343. // returns: true if found, false if not
  344. //
  345. //----------------------------------------------------------------------
  346. function checkLinkReadyStateComplete(objects, reportLocation)
  347. {
  348. var i, element;
  349. var retVal;
  350. var L_StyleSheetNotInstalled_Text = "This document might not display properly because the following style sheet did not get installed: ";
  351. retVal = false;
  352. if (objects == null)
  353. return retVal;
  354. for (i=0; i < objects.length; i++) {
  355. element = objects(i);
  356. if (element.rel.toLowerCase() == "stylesheet"
  357. || element.rel.toLowerCase() == "alternate stylesheet")
  358. {
  359. // looks like 4 = complete
  360. if (element.readyState != "complete" && element.readyState != 4) {
  361. reportLocation.insertAdjacentHTML("BeforeEnd", L_StyleSheetNotInstalled_Text + element.href + "<BR><hr>");
  362. retVal = true;
  363. }
  364. }
  365. }
  366. return retVal;
  367. }
  368. </SCRIPT>
  369. </HEAD>
  370. <BODY ID=bdy onLoad="loadBdy()" style="font-family: 'MS Shell Dlg';
  371. font-size: 8pt; background: threedface; color: windowtext;"
  372. topmargin=0 scroll=no>
  373. <br id=brAnalysis>&nbsp;&nbsp;Analysis of current document:<br>
  374. <br>
  375. <DIV id=ReportArea style="height: 75%; width: 93%;
  376. position: absolute; left: 5%; top: 12%; overflow: auto; padding: 3px;
  377. border-style: solid; border-width: 1px; border-color: threeddarkshadow">
  378. No errors found.
  379. </DIV>
  380. <br id=br2><P id=par1>&nbsp;</P>
  381. <DIV id=divButton style="font-family: MS Shell Dlg; font-size: 8pt;
  382. width: 8em; height: 2.2em; position: absolute;
  383. top: 27.1em; left: 20em; background: threedface;">
  384. </DIV>
  385. <BUTTON id=btnOk tabIndex=55
  386. style="font-family: MS Shell Dlg; font-size: 8pt;
  387. width: 7em; height: 2.2em; position: absolute;
  388. top: 27.5em; left: 21em" type=submit>
  389. OK
  390. </BUTTON>
  391. </BODY>
  392. </HTML>