home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 June
/
CHIP_CD_2004-06.iso
/
bonus
/
buhgal
/
files
/
M12USWEB.exe
/
RCDATA
/
CABINET
/
money.cab
/
msmoney.chm
/
jsonstart.js
< prev
next >
Wrap
Text File
|
2003-06-18
|
10KB
|
392 lines
/*
Microsoft Money
Copyright (c) 2001 Microsoft Corporation
All rights reserved
File : jsOnstart.js
Modified : Dec 19 2001
*********************************************************************/
var mhTpc = new Object();
var mhThmbnl;
//********************************************************************
function DataObject(
fValidate,
fResolve,
fPreserve,
bolAsync,
pListener)
{
this.XMLDOM = new ActiveXObject("Microsoft.XMLDOM");
this.XMLDOM.validateOnParse = fValidate;
this.XMLDOM.resolveExternals = fResolve;
this.XMLDOM.preserveWhiteSpace = fPreserve;
this.XMLDOM.async = bolAsync;
if(null != pListener) this.XMLDOM.onreadystatechange = pListener;
this.loadData = function()
{
this.XMLDOM.load(this.dataSource);
}
}
//********************************************************************
function Main()
{
mhTpc["MoneyData"] = new DataObject(false,false,false,true,null);
mhTpc["Locale"] = new DataObject(false,false,false,true,FetchProductSku);
mhTpc["ProductSku"] = new DataObject(false,false,false,true,FetchIncludes);
mhTpc["StyleRules"] = new Array("enabled","disabled");
var szSku = "hhsku.xml";
var szRsrc = "msmoney.xml";
var szPrefs = "hhprefs.xml";
var szDfltSku = "hhstd";
var szLocale = "hhusa";
mhTpc["MoneyData"].dataSource = GetFilePath(szRsrc);
mhTpc["Locale"].dataSource = GetFilePath(szPrefs);
mhTpc["Locale"].defaultValue = szLocale;
mhTpc["ProductSku"].defaultValue = szDfltSku;
mhTpc["ProductSku"].dataSource = GetFilePath(szSku);
mhTpc["ProductSku"].legalValues = new Array("std","dlx","biz","stddlx","dlxbiz","core");
mhTpc["Includes"] = new Array();
mhTpc["MoneyData"].loadData();
}
//********************************************************************
function FetchProductSku()
{
if(4 == mhTpc["Locale"].XMLDOM.readyState)
{
mhTpc["Locale"].value = (0 == mhTpc["Locale"].XMLDOM.parseError)
?
mhTpc["Locale"].XMLDOM.documentElement.selectSingleNode("country").text.toLowerCase()
:
mhTpc["Locale"].defaultValue
;
mhTpc["ProductSku"].loadData();
}
}
//********************************************************************
function FetchIncludes()
{
if(4 == mhTpc["ProductSku"].XMLDOM.readyState)
{
mhTpc["ProductSku"].value = FetchTopicSku();
var iStyle = SelectStyleSheet(); // dependent on product SKU
mhTpc["StyleRules"].styleType = mhTpc["StyleRules"][iStyle];
if(LoadIncludes())
{
var cbCnt = 0;
mhTpc["Includes"].stackSize = mhTpc["Includes"].length;
for(;cbCnt < mhTpc["Includes"].stackSize;)
{
mhTpc["Includes"][cbCnt].loadData();
cbCnt++
}
}
else
{
FinishTransformations();
}
}
}
//********************************************************************
function FetchTopicSku()
{
var szRtrn = mhTpc["ProductSku"].defaultValue;
if(0 == mhTpc["ProductSku"].XMLDOM.parseError)
{
try
{
szRtrn = mhTpc["ProductSku"].XMLDOM.documentElement.selectSingleNode("type").text.toLowerCase();
}
catch(e)
{
szRtrn = mhTpc["ProductSku"].defaultValue;
}
}
return szRtrn;
}
//********************************************************************
function SelectStyleSheet()
{
if("object" == typeof document.XMLDocument)
{
var bRtrn;
var szDsply;
var rxSku = new RegExp();
var cbCnt = 0;
var kbIsEnbld = 0;
var kbIsDsbld = 1;
var hStyle = document.createStyleSheet("csOnstart.css");
var szSku = document.XMLDocument.documentElement.getAttribute("sku").toLowerCase();
switch(mhTpc["ProductSku"].value)
{
case "hhstd" :
rxSku = /^(?:std(dlx)?)$/
break;
case "hhdlx" :
rxSku = /^(?:(std)?(dlx)(biz)?)$/
break;
case "hhbiz" :
rxSku = /^(?:(dlx)?biz)$/
break;
}
if("core" == szSku)
{
bRtrn = kbIsEnbld;
}
else
{
bRtrn = (rxSku.test(szSku))
?
kbIsEnbld
:
kbIsDsbld
;
}
for(;cbCnt < mhTpc["ProductSku"].legalValues.length;)
{
szDsply = (rxSku.test(mhTpc["ProductSku"].legalValues[cbCnt]))
?
"inline"
:
"none"
;
hStyle.addRule(".Frgmnt__" + mhTpc["ProductSku"].legalValues[cbCnt],
"display:" + szDsply);
cbCnt++;
}
hStyle.rules[1].style.color = (kbIsEnbld == bRtrn) ? "#000000" : "#93948e";
return bRtrn;
}
}
//********************************************************************
function LoadIncludes()
{
var fRtrn = false;
if("object" == typeof document.XMLDocument)
{
mhTpc["Clone"] = document.XMLDocument.cloneNode(true);
var iLkup;
var hIncld;
var szHref;
var bInPrcss = 0;
var szTkn = "#xpointer(";
var rghInclude = mhTpc["Clone"].selectNodes("//include");
if(rghInclude.length > 0)
{
hIncld = rghInclude.nextNode();
while(hIncld)
{
szHref = hIncld.getAttribute("href");
if(szHref)
{
mhTpc["Includes"][bInPrcss] = new DataObject(false,false,false,true,HandleIncludes);
mhTpc["Includes"][bInPrcss].designTimeNode = hIncld;
iLkup = szHref.lastIndexOf(szTkn);
mhTpc["Includes"][bInPrcss].queryPath = (iLkup > 0)
?
szHref.substr(iLkup + szTkn.length,szHref.length - iLkup - szTkn.length - 1)
:
null
;
if(iLkup > 0)
{
szHref = szHref.substr(0,iLkup);
}
mhTpc["Includes"][bInPrcss].dataSource = szHref;
bInPrcss++;
}
hIncld = rghInclude.nextNode();
}
fRtrn = (mhTpc["Includes"].length > 0);
}
}
return fRtrn;
}
//********************************************************************
function HandleIncludes()
{
var cbCnt = 0;
var cbRdy = 0;
for(;cbCnt < mhTpc["Includes"].length;)
{
if((mhTpc["Includes"][cbCnt] != null)
&& (mhTpc["Includes"][cbCnt].XMLDOM.readyState == 4))
{
if(mhTpc["Includes"][cbCnt].XMLDOM.parseError != 0)
{
mhTpc["Includes"].stackSize -= 1;
mhTpc["Includes"][cbCnt] = null;
}
else if(mhTpc["Includes"][cbCnt].XMLDOM.url != "")
{
cbRdy++;
}
}
cbCnt++;
}
if(cbRdy == mhTpc["Includes"].stackSize)
{
cbCnt = 0;
for(;cbCnt < mhTpc["Includes"].length;)
{
if((null != mhTpc["Includes"][cbCnt])
&& (0 == mhTpc["Includes"][cbCnt].XMLDOM.parseError))
{
TransformIncludes(cbCnt);
}
else
{
//alert("This help topic is still partially\nunder construction, and may have\nproblems displaying properly.");
}
cbCnt++;
}
FinishTransformations();
}
}
//********************************************************************
function TransformIncludes(iLkup)
{
var hNw;
var hDom = mhTpc["Includes"][iLkup].XMLDOM;
var szQry = mhTpc["Includes"][iLkup].queryPath;
var hIncld = mhTpc["Includes"][iLkup].designTimeNode;
var bErr = hDom.parseError;
if(0 == bErr)
{
hNw = hDom.createDocumentFragment();
if(szQry != null)
{
var rghQry = hDom.selectNodes(szQry);
var hNxt = rghQry.nextNode();
while(hNxt)
{
hNxt.setAttribute("href",GetFileName(hDom.url));
if(hNxt.text.length < 1)
{
hNxt.setAttribute("type","uarvw");
}
hNw.appendChild(hNxt);
hNxt = rghQry.nextNode();
}
}
}
hIncld.parentNode.replaceChild(hNw,hIncld);
}
//********************************************************************
function FinishTransformations()
{
try
{
mhTpc["Clone"].documentElement.selectSingleNode("content").setAttribute("styleType",mhTpc["StyleRules"].styleType);
if(mhTpc["Locale"].value == "hhcdn")
{
mhTpc["Clone"].documentElement.selectSingleNode("content").setAttribute("preference","cdn");
}
if(mhTpc["Clone"].documentElement.selectNodes("//thumbnail").length > 0)
{
mhThmbnl = window.createPopup();
}
document.body.innerHTML = mhTpc["Clone"].transformNode(Transformation);
ReadUpdateList();
ResetHeaderHtml();
window.onresize = function()
{
ResetHeaderHtml();
}
}
catch(e)
{
document.body.innerHTML = "Unable to load topic. <A HREF='#' onclick='location.reload()'>Click here</A> to try again.";
}
document.body.oncontextmenu = function()
{
return false;
}
}
//********************************************************************
function ReadUpdateList()
{
if((4 == mhTpc["MoneyData"].XMLDOM.readyState)
&& (0 == mhTpc["MoneyData"].XMLDOM.parseError))
{
try
{
var lTnum = document.XMLDocument.documentElement.getAttribute("tNum");
var hTrgt = document.all.MSMNYUPDATE;
var hUpdt = mhTpc["MoneyData"].XMLDOM.documentElement.selectNodes("update[@id='" + lTnum + "']");
if(hUpdt.length && hTrgt)
{
hTrgt.innerHTML = hUpdt.item(0).text;
hTrgt.style.display = "block";
}
}
catch(e)
{
return;
}
}
}
//********************************************************************
function ResetHeaderHtml()
{
if(HeaderExpandText)
{
HeaderExpandText.style.display = (document.body.clientWidth >= 200) ? "none" : "block";
}
if(HeaderContractText)
{
HeaderContractText.style.display = (document.body.clientWidth < 200) ? "none" : "block";
}
}
//********************************************************************
function GetFilePath(szName)
{
var szPath;
var bRgt;
var bLft;
var szLctn = location.href;
bRgt = szLctn.lastIndexOf("\\") + 1;
bLft = (2 == szLctn.search(/:/))
?
14
:
7
;
szPath = (0 == bRgt)
?
szName
:
unescape("file:///" + szLctn.substring(bLft, bRgt) + szName)
;
return szPath;
}
//********************************************************************
function GetFileName(szPath)
{
var rgszPrts = (4 == szPath.search(/:/))
?
szPath.split("\\")
:
szPath.split("/")
;
return rgszPrts[rgszPrts.length - 1];
}
//********************************************************************
window.onload = function()
{
mhTpc["Locale"].loadData();
}
Main();