home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
WindowsServerTrial
/
server.iso
/
sources
/
install.wim
/
2
/
Windows
/
System32
/
ieframe.dll
/
HTML
/
ANALYZE.JS
< prev
next >
Wrap
Text File
|
2008-01-19
|
12KB
|
427 lines
window.onerror = HandleError
var HTMLKEYESCAPE = 27
//+-------------------------------------------------------------------
//
// Synopsis: Turns off error messages in dialogs
//
// Arguments: none
//
// returns: true (tells browser not to handle message)
//
//--------------------------------------------------------------------
function HandleError(message, url, line)
{
var str = L_Dialog_ErrorMessage + "\n\n"
+ L_ErrorNumber_Text + line + "\n"
+ message;
alert (str);
window.close();
return true;
}
//+---------------------------------------------------------------------
//
// Synopsis: Returns the document object for the page to be analyzed
//
// Arguments: none
//
// returns: document object for the page to be analyzed
//
//----------------------------------------------------------------------
function otherDocument()
{
return window.dialogArguments.document;
}
//+---------------------------------------------------------------------
//
// Synopsis: onload handler for this dialog. sets up events. Calls
// analysis function.
//
// Arguments: none
//
// returns: none
//
//----------------------------------------------------------------------
function loadBdy()
{
//
// Bind events to controls. This is done here to load the dialog
// quicker.
//
document.all.btnOk.onclick = new Function("window.close();");
document.onkeyup = new Function("documentOnKeyUp()");
runAnalysis();
} // loadBdy
//+---------------------------------------------------------------------
//
// Checks for the escape key and closes the dialog
//
//----------------------------------------------------------------------
function documentOnKeyUp()
{
if (window.event.keyCode == HTMLKEYESCAPE)
{
window.close();
}
} // documentOnKeyUp
//+---------------------------------------------------------------------
//
// Synopsis: Performs analysis function on primary document.
// Initializes display error, then calls each of the individual
// analysis functions in turn
//
// Arguments: none
//
// returns: none
//
//----------------------------------------------------------------------
function runAnalysis()
{
var errorsFound, reportLocation;
errorsFound = false;
reportLocation = document.all.ReportArea;
initializeResults(reportLocation);
errorsFound = errorsFound || checkBodyWithinFrameset(reportLocation);
errorsFound = errorsFound || checkAnythingAfterFrameset(reportLocation);
errorsFound = errorsFound || checkUnloadedComponents(reportLocation);
errorsFound = errorsFound || checkNonApartmentControls(reportLocation);
errorsFound = errorsFound || checkUnloadedStyleSheets(reportLocation);
if (errorsFound == false) {
reportNothingFound(reportLocation);
}
}
//+---------------------------------------------------------------------
//
// Synopsis: Sets the initial state of the results window - blank
//
// Arguments: none
//
// returns: none
//
//----------------------------------------------------------------------
function initializeResults(reportLocation)
{
reportLocation.innerHTML = " ";
}
//+---------------------------------------------------------------------
//
// Synopsis: If no errors found in document, reports that to user
//
// Arguments: none
//
// returns: none
//
//----------------------------------------------------------------------
function reportNothingFound(reportLocation)
{
reportLocation.innerHTML = L_NoErrors_Text;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for existence of a frameset and a body on the same document
//
// Arguments: none
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkBodyWithinFrameset(reportLocation)
{
var theDocument;
var framesets, bodies;
var retVal;
retVal = false;
theDocument = otherDocument();
framesets = theDocument.all.tags("frameset");
if (framesets.length > 0) {
bodies = theDocument.all.tags("body");
if (bodies.length > 0) {
reportLocation.insertAdjacentHTML("BeforeEnd", L_FramesetInBody_Text );
retVal = true;
}
}
// tested case of implied body - looks like trident creates a body
// tag even when one doesn't exist
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for existence of any tags but comments after a frameset
//
// Arguments: none
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkAnythingAfterFrameset(reportLocation)
{
var theDocument;
var framesets;
var i, startIndex;
var retVal;
retVal = false;
theDocument = otherDocument();
framesets = theDocument.all.tags("frameset");
if (framesets.length > 0) {
startIndex = framesets(0).sourceIndex;
if (window.dialogArguments.anythingAfterFrameset) {
reportLocation.insertAdjacentHTML("BeforeEnd", L_ContentAfterFrameset_Text );
retVal = true;
}
}
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for existence of objects, applets or embeds that are
// readyState != complete
//
// Arguments: none
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkUnloadedComponents(reportLocation)
{
var theDocument;
var objects, applets, embeds;
var retVal;
retVal = false;
theDocument = otherDocument();
objects = theDocument.all.tags("object");
applets = theDocument.all.tags("applet");
embeds = theDocument.all.tags("embed");
retVal = checkReadyStateComplete(objects, reportLocation);
retVal = retVal || checkReadyStateComplete(applets, reportLocation);
retVal = retVal || checkReadyStateComplete(embeds, reportLocation);
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for readystate = complete for collection passed in.
// If any components found that are not readystate = complete
// error is passed to reportLocation. Valid for object, applet
// and embed
//
// Arguments: collection of elements to check for readystate = complete
// area to report errors to
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkReadyStateComplete(objects, reportLocation)
{
var strNotInstalled;
var strNotInstalledReason;
var i, element;
var retVal;
retVal = false;
if (objects == null)
return retVal;
for (i=0; i < objects.length; i++) {
element = objects(i);
// looks like 4 = complete
if (element.readyState != 4 && element.readyState != "complete") {
switch (element.tagName.toLowerCase())
{
case "object":
strNotInstalled = L_ObjectNotInstalled_Text;
strNotInstalledReason = L_ObjectNotInstalledReasons_Text;
break;
case "applet":
strNotInstalled = L_AppletNotInstalled_Text;
strNotInstalledReason = L_AppletNotInstalledReasons_Text;
break;
case "embed":
strNotInstalled = L_EmbedNotInstalled_Text;
strNotInstalledReason = L_EmbedNotInstalledReasons_Text;
break;
}
reportLocation.insertAdjacentHTML("BeforeEnd", strNotInstalled);
reportLocation.insertAdjacentText("BeforeEnd", element.outerHTML);
reportLocation.insertAdjacentHTML("BeforeEnd", strNotInstalledReason);
retVal = true;
}
}
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for existence ocx's that are known to be non-apartment
// model
//
// Arguments: none
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkNonApartmentControls(reportLocation)
{
var theDocument;
var objects;
var i;
var retVal;
retVal = false;
theDocument = otherDocument();
objects = theDocument.all.tags("object");
for (i=0; i < objects.length; i++) {
element = objects(i);
nonApartmentModel = checkCLSIDForNonApartmentModel(element);
retVal = retVal || nonApartmentModel;
if (nonApartmentModel == true) {
reportLocation.insertAdjacentHTML("BeforeEnd", L_ObjectNotApartmentModel_Text);
reportLocation.insertAdjacentText("BeforeEnd", element.outerHTML);
reportLocation.insertAdjacentHTML("BeforeEnd", "<br><hr>");
}
}
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks to see if specified clsid is for an apartment model
// control
//
// Arguments: clsid to check
//
// returns: true if non-apartment model, false if apartment model
//
//----------------------------------------------------------------------
function checkCLSIDForNonApartmentModel(element) {
return !(window.dialogArguments.isApartmentModel(element));
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for any link tags where readyState != complete
//
// Arguments: none
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkUnloadedStyleSheets(reportLocation)
{
var theDocument;
var links;
var retVal;
retVal = false;
theDocument = otherDocument();
links = theDocument.all.tags("link");
retVal = checkLinkReadyStateComplete(links, reportLocation);
return retVal;
}
//+---------------------------------------------------------------------
//
// Synopsis: Checks for readystate = complete for collection of links passed in.
// If any links found that are not readystate = complete
// error is passed to reportLocation. Note that separate function
// is used for links because different error info needs to
// be reported
//
// Arguments: collection of elements to check for readystate = complete
// area to report errors to
//
// returns: true if found, false if not
//
//----------------------------------------------------------------------
function checkLinkReadyStateComplete(objects, reportLocation)
{
var i, element;
var retVal;
retVal = false;
if (objects == null)
return retVal;
for (i=0; i < objects.length; i++) {
element = objects(i);
if (element.rel.toLowerCase() == "stylesheet"
|| element.rel.toLowerCase() == "alternate stylesheet")
{
// looks like 4 = complete
if (element.readyState != "complete" && element.readyState != 4) {
reportLocation.insertAdjacentHTML("BeforeEnd", L_StyleSheetNotInstalled_Text + element.href + "<BR><hr>");
retVal = true;
}
}
}
return retVal;
}