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
/
IEERROR.JS
< prev
next >
Wrap
Text File
|
2008-01-19
|
10KB
|
402 lines
window.onerror = HandleError
document.ondragstart = NoDragging
function NoDragging()
{
window.event.returnValue = false;
}
var g_errList;
var g_detailsPaneOpen;
//+-------------------------------------------------------------------
//
// 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: Binds events to controls and do some last minute
// dialog formatting
//
// Arguments: none.
//
// Returns: nothing.
//
//-----------------------------------------------------------------------
function updateTabIndices()
{
if (g_detailsPaneOpen)
{
var nextIndex = 3;
if (!btnPrevErr.disabled)
{
btnPrevErr.tabindex = nextIndex++;
}
if (!btnNextErr.disabled)
{
btnNextErr.tabindex = nextIndex++;
}
chkAlwaysShowErrs.tabindex = nextIndex;
}
else
{
btnPrevErr.tabindex = -1;
btnNextErr.tabindex = -1;
chkAlwaysShowErrs.tabindex = 3;
}
}
function loadBdy()
{
g_errList = window.dialogArguments;
chkAlwaysShowErrs.checked = g_errList.getPerErrorDisplay();
// if the key didn't exist we got a default. if we took a
// default, it needs to become a real setting (non-default)
// because the nonexistence of the key indicates to us that
// we need to display the dialog but default to having
// "never show me again" checked. obviously we only want
// this behavioral exception to happen once. to make it
// become a non-default value, just write it out...
g_errList.setPerErrorDisplay(chkAlwaysShowErrs.checked);
// if the IEAK has locked the advanced options settings,
// then disable the checkbox so that people can't change
// the "Always present script error notifications" setting
// via the checkbox
chkAlwaysShowErrs.disabled = g_errList.getAlwaysShowLockState();
//
// set the details pane to be open or closed
// the easiest way to make sure all controls
// are set to their proper state is to just
// call the click function
//
g_detailsPaneOpen = g_errList.getDetailsPaneOpen();
assureControlState();
//
// Bind event to controls
//
btnOK.onclick = new Function("btnOKClick()");
btnOK.onkeydown = new Function("SwitchFocus()");
btnDetails.onclick = new Function("btnDetailsClick()");
btnDetails.onkeydown = new Function("SwitchFocus()");
btnNextErr.onclick = new Function("btnNextErrClick()");
btnNextErr.onkeydown = new Function("SwitchFocus()");
btnPrevErr.onclick = new Function("btnPrevErrClick()");
btnPrevErr.onkeydown = new Function("SwitchFocus()");
//
// Fill the dialog with error information
//
updateErrorInfo();
//
// set prev and next button's disabled state
//
if (!g_errList.canRetreatError())
{
btnPrevErr.disabled = true;
}
if (!g_errList.canAdvanceError())
{
btnNextErr.disabled = true;
}
btnOK.focus();
} // loadBdy
//+-----------------------------------------------------------------------
//
// Sysopsis: sets all the error specific controls to be in sync with
// the current error index
//
// Arguments: none
//
// Returns: nothing
//
//------------------------------------------------------------------------
function updateErrorInfo()
{
spnLine.innerText = g_errList.getErrorLine();
spnCharacter.innerText = g_errList.getErrorChar();
spnCode.innerText = g_errList.getErrorCode();
divError.innerText = g_errList.getErrorMsg();
divURL.innerText = g_errList.getErrorUrl();
}
//+-----------------------------------------------------------------------
//
// Synopsis: Handles keyboard-related shifting of focus among the
// varioud dialog controls.
//
// Notes: We're trying to pretend to be just like a normal dialog.
// Therefore, we need tab groups within which up/left
// shifts focus in the shift-tab diection, and right/down
// shifts focus in the tab direction. And we need a global
// tab order for tab and shift-tab to follow.
//
// Arguments: none
//
// Returns: nothing
//
//------------------------------------------------------------------------
function SwitchFocus()
{
var HTML_KEY_ARROWLEFT = 37;
var HTML_KEY_ARROWUP = 38;
var HTML_KEY_ARROWRIGHT = 39;
var HTML_KEY_ARROWDOWN = 40;
var iCode = event.keyCode;
var strSourceID = event.srcElement.id;
var fTabForward;
if (iCode < HTML_KEY_ARROWLEFT || iCode > HTML_KEY_ARROWDOWN)
{
return;
}
var fTabForward = iCode == HTML_KEY_ARROWRIGHT ||
iCode == HTML_KEY_ARROWDOWN;
if (g_detailsPaneOpen)
{
// arrow keys move back and forth between:
// 1) ok - details
// 2) previous - next
if (fTabForward)
{
if (strSourceID == "btnPrevErr")
{
if (!btnNextErr.disabled)
{
btnNextErr.focus();
}
}
else if (strSourceID == "btnOK")
{
btnDetails.focus();
}
else if (strSourceID == "chkAlwaysShowErrs")
{
btnOK.focus();
}
}
else
{
if (strSourceID == "btnNextErr")
{
if (!btnPrevErr.disabled)
{
btnPrevErr.focus();
}
}
else if (strSourceID == "btnDetails")
{
btnOK.focus();
}
else if (strSourceID == "btnOK")
{
chkAlwaysShowErrs.focus();
}
}
}
}
//+-------------------------------------------------------------------
//
// Synopsis: Closes the dialog
//
// Arguments: none
//
// Returns: nothing
//
//---------------------------------------------------------------------
function btnOKClick()
{
g_errList.setPerErrorDisplay(chkAlwaysShowErrs.checked);
g_errList.setDetailsPaneOpen(g_detailsPaneOpen);
window.close();
}
//+-------------------------------------------------------------------
//
// Synopsis: make sure things which are affected by the state
// of the details pane are in sync with the current
// state of the details pane
//
// Arguments: none
//
// Returns: nothing
//
//--------------------------------------------------------------------
function assureControlState()
{
if (g_detailsPaneOpen)
{
// update the button text
btnDetails.innerHTML = L_DetailsCollapse_Text;
// enlarge the window to show the error info
window.dialogHeight = 24.2;
// assure details info is visible
divDetails.style.display = "";
divButtons2.style.display = "";
trHR.style.display = "";
}
else
{
// update the button text
btnDetails.innerHTML = L_DetailsExpand_Text;
// assure details info is hidden
divDetails.style.display = "none";
divButtons2.style.display = "none";
trHR.style.display = "none";
// shrink the window to hide the error info
window.dialogHeight = 10.7;
}
}
//+-------------------------------------------------------------------
//
// Synopsis: provides user with details about accumulated script
// errors
//
// Arguments: none
//
// Returns: nothing
//
//--------------------------------------------------------------------
function btnDetailsClick()
{
g_detailsPaneOpen = !g_detailsPaneOpen;
assureControlState();
if (g_detailsPaneOpen)
{
// give focus to the "next" button if possible,
// otherwise try "previous", finally "ok"
if (!btnNextErr.disabled)
{
btnNextErr.focus();
}
else if (!btnPrevErr.disabled)
{
btnPrevErr.focus();
}
else
{
btnOK.focus();
}
}
else
{
// give focus to the "details" button
btnDetails.focus();
}
updateTabIndices();
}
//+-------------------------------------------------------------------
//
// Synopsis: updates error info to correspond to the next error
//
// Arguments: none
//
// Returns: nothing
//
//--------------------------------------------------------------------
function btnNextErrClick()
{
g_errList.advanceError();
updateErrorInfo();
if (btnPrevErr.disabled)
{
// no longer at beginning of error list
btnPrevErr.disabled = false;
}
if (!g_errList.canAdvanceError())
{
// at end of error list
btnNextErr.disabled = true;
btnPrevErr.focus();
}
updateTabIndices();
}
function btnPrevErrClick()
{
g_errList.retreatError();
updateErrorInfo();
if (btnNextErr.disabled)
{
// no longer at end of error list
btnNextErr.disabled = false;
}
if (!g_errList.canRetreatError())
{
// at beginning of error list
btnPrevErr.disabled = true;
btnNextErr.focus();
}
updateTabIndices();
}
function BodyOnKeyPress(nCode)
{
if (nCode == 27) //ESC
{
window.close();
return;
}
}