2004-12-17 16:18:33 +05:00
|
|
|
// WebHelp 5.10.007
|
2004-06-16 21:45:26 +06:00
|
|
|
var gaHSLoad=new Array();
|
|
|
|
var gnMinIdx=0;
|
|
|
|
var gnInsIdx=-1;
|
|
|
|
var gsLoadingDivID="LoadingDiv";
|
|
|
|
var gsLoadingMsg="Loading, click here to cancel...";
|
|
|
|
var gaProj=null;
|
|
|
|
var gaTocs=new Array();
|
|
|
|
var goChunk=null;
|
|
|
|
var gbReady=false;
|
2004-12-17 16:18:33 +05:00
|
|
|
var gbToc=false;
|
2004-06-16 21:45:26 +06:00
|
|
|
var gbXML=false;
|
|
|
|
var gaRoot=new Array();
|
|
|
|
var gnCC=-1;
|
|
|
|
var gsTP="";
|
|
|
|
var gaBTPs="";
|
|
|
|
var gsCTPath="";
|
|
|
|
var gnLT=-1;
|
|
|
|
var gsPathSplit="\n";
|
|
|
|
var gsBgColor="#ffffff";
|
|
|
|
var gsBgImage="";
|
|
|
|
var goFont=null;
|
|
|
|
var goHFont=null;
|
|
|
|
|
|
|
|
var gsMargin="0pt";
|
|
|
|
var gsIndent="15pt";
|
|
|
|
var gsABgColor="#cccccc";
|
|
|
|
|
|
|
|
var giBookClose="";
|
|
|
|
var giBookOpen="";
|
|
|
|
var giBookItem="";
|
|
|
|
var giURLItem="";
|
|
|
|
var giNewBookClose="";
|
|
|
|
var giNewBookOpen="";
|
|
|
|
var giNewBookItem="";
|
|
|
|
var giNewURLItem="";
|
|
|
|
var gnImages=0;
|
|
|
|
var gnLoadedImages=0;
|
|
|
|
var gaImgs=new Array();
|
|
|
|
var gbLoadData=false;
|
|
|
|
var gobj=null;
|
|
|
|
var gaTocsNs61Fix=null;
|
|
|
|
var gbWhTHost=false;
|
|
|
|
var gBookItems=new Array();
|
|
|
|
var gInSync=false;
|
2004-12-17 16:18:33 +05:00
|
|
|
var gbLData=false;
|
|
|
|
var gbNeedFillStub=false;
|
|
|
|
var gbLoadToc=false;
|
|
|
|
|
|
|
|
function chunkInfoQueue()
|
|
|
|
{
|
|
|
|
this.aContent=new Array();
|
|
|
|
this.inQueue=function(cInfo)
|
|
|
|
{
|
|
|
|
this.aContent[this.aContent.length]=cInfo;
|
|
|
|
}
|
|
|
|
this.deQueue=function()
|
|
|
|
{
|
|
|
|
var cInfo=null;
|
|
|
|
if(this.aContent.length>0)
|
|
|
|
{
|
|
|
|
cInfo=this.aContent[0];
|
|
|
|
for(var i=1;i<this.aContent.length;i++)
|
|
|
|
this.aContent[i-1]=this.aContent[i];
|
|
|
|
this.aContent.length--;
|
|
|
|
}
|
|
|
|
return cInfo;
|
|
|
|
}
|
|
|
|
this.length=function()
|
|
|
|
{
|
|
|
|
return this.aContent.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var gchunkRequestQueue=new chunkInfoQueue();
|
|
|
|
|
|
|
|
function chunkInfo(nIdx, bLocal)
|
|
|
|
{
|
|
|
|
this.nIdx=nIdx;
|
|
|
|
this.bLocal=bLocal;
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
|
|
|
|
function setBackground(sBgImage)
|
|
|
|
{
|
|
|
|
gsBgImage=sBgImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setBackgroundcolor(sBgColor)
|
|
|
|
{
|
|
|
|
gsBgColor=sBgColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setFont(sType,sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration)
|
|
|
|
{
|
|
|
|
var vFont=new whFont(sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration);
|
|
|
|
if(sType=="Normal") goFont=vFont;
|
|
|
|
else if(sType=="Hover") goHFont=vFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActiveBgColor(sBgColor){gsABgColor=sBgColor;}
|
|
|
|
|
|
|
|
function setMargin(sMargin){gsMargin=sMargin;}
|
|
|
|
|
|
|
|
function setIndent(sIndent){gsIndent=sIndent;}
|
|
|
|
|
|
|
|
function setIcon(sType,sURL)
|
|
|
|
{
|
|
|
|
if(sType=="BookOpen")
|
|
|
|
giBookOpen=sURL;
|
|
|
|
else if(sType=="BookClose")
|
|
|
|
giBookClose=sURL;
|
|
|
|
else if(sType=="Item")
|
|
|
|
giBookItem=sURL;
|
|
|
|
else if(sType=="RemoteItem")
|
|
|
|
giURLItem=sURL;
|
|
|
|
else if(sType=="NewBookClose")
|
|
|
|
giNewBookClose=sURL;
|
|
|
|
else if(sType=="NewBookOpen")
|
|
|
|
giNewBookOpen=sURL;
|
|
|
|
else if(sType=="NewItem")
|
|
|
|
giNewBookItem=sURL;
|
|
|
|
else if(sType=="NewRemoteItem")
|
|
|
|
giNewURLItem=sURL;
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function bookItem(sTarget,sURL)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(sTarget)
|
2004-06-16 21:45:26 +06:00
|
|
|
this.sTarget=sTarget;
|
|
|
|
else
|
|
|
|
this.sTarget="bsscright";
|
|
|
|
this.sURL=sURL;
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function addBookItem(sBookId,sTarget,sURL)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
gBookItems[sBookId]=new bookItem(sTarget,sURL);
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function tocChunk(sPPath,sDPath)
|
|
|
|
{
|
|
|
|
this.sPPath=sPPath;
|
|
|
|
this.sDPath=sDPath;
|
|
|
|
this.nMI=-1;
|
|
|
|
this.aTocs=null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addTocChunk(sPPath,sDPath)
|
|
|
|
{
|
|
|
|
var oChunk=new tocChunk(sPPath,sDPath);
|
|
|
|
gaTocs[gaTocs.length]=oChunk;
|
|
|
|
return oChunk;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isHSLoad(nIdx)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
for(var i=0;i<gaHSLoad.length;i++)
|
2004-06-16 21:45:26 +06:00
|
|
|
if(gaHSLoad[i]==nIdx)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHSLoad(nIdx)
|
|
|
|
{
|
|
|
|
if(!isHSLoad(nIdx))
|
|
|
|
{
|
|
|
|
var len=gaHSLoad.length;
|
2004-12-17 16:18:33 +05:00
|
|
|
for(var i=0;i<len;i++)
|
2004-06-16 21:45:26 +06:00
|
|
|
if(gaHSLoad[i]==-1)
|
|
|
|
{
|
|
|
|
gaHSLoad[i]=nIdx;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gaHSLoad[len]=nIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHSUnLoad(nIdx)
|
|
|
|
{
|
|
|
|
if(isHSLoad(nIdx))
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
for(var i=0;i<gaHSLoad.length;i++)
|
2004-06-16 21:45:26 +06:00
|
|
|
if(gaHSLoad[i]==nIdx)
|
|
|
|
{
|
|
|
|
gaHSLoad[i]=-1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function removeLoadingDiv()
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var eLoadingDiv=getElement(gsLoadingDivID);
|
|
|
|
if(eLoadingDiv)
|
|
|
|
removeThis(eLoadingDiv);
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkBookItem(nIdx)
|
|
|
|
{
|
|
|
|
if(!gInSync)
|
|
|
|
{
|
|
|
|
var sBookId=getBookId(nIdx);
|
|
|
|
if(gBookItems[sBookId])
|
|
|
|
{
|
|
|
|
window.open(gBookItems[sBookId].sURL,gBookItems[sBookId].sTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertBookItems(nIdx,num)
|
|
|
|
{
|
|
|
|
checkBookItem(nIdx);
|
|
|
|
var sChildBookId=getCBId(nIdx);
|
|
|
|
var eChildDiv=getElement(sChildBookId);
|
|
|
|
if(eChildDiv){
|
|
|
|
if((eChildDiv.childNodes&&eChildDiv.childNodes.length==0)||
|
|
|
|
(eChildDiv.all&&eChildDiv.all.length==0)){
|
|
|
|
var sHTML=writeBookItems(nIdx,num);
|
|
|
|
eChildDiv.innerHTML=sHTML;
|
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ExpandIt(nIdx);
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function isBookEmpty(nIdx)
|
|
|
|
{
|
|
|
|
var num=getItemContentsNum(nIdx);
|
|
|
|
if (num>0)
|
|
|
|
{
|
|
|
|
var nCIdx=0;
|
|
|
|
do {
|
|
|
|
nCIdx++;
|
|
|
|
var i=nIdx+nCIdx;
|
|
|
|
var nItemType=getItemType(i);
|
|
|
|
if(nItemType==1){
|
|
|
|
if (!isBookEmpty(i))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(nItemType==4){
|
|
|
|
var sSrc=getRefURL(i);
|
|
|
|
var nProj=getProject(sSrc);
|
|
|
|
if(nProj!=-1){
|
|
|
|
sSrc=gaRoot[nProj].sToc;
|
|
|
|
if(sSrc)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(nItemType==2||nItemType==16||nItemType==8)
|
|
|
|
return false;
|
|
|
|
} while(nCIdx<num);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeBook(nIdx)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
|
|
|
var sIcon=getBookImage(nIdx,true);
|
|
|
|
var sName=_textToHtml(getItemName(nIdx));
|
|
|
|
sIcon=_textToHtml_nonbsp(sIcon);
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
var nType=getItemType(nIdx);
|
|
|
|
var bLocal=(nType==1);
|
|
|
|
var bLocalProject=(nType!=4);
|
|
|
|
|
|
|
|
var sHTML="<div id=\""+getPBId(nIdx)+"\" class=";
|
|
|
|
if(bLocal)
|
|
|
|
{
|
|
|
|
if (!isBookEmpty(nIdx))
|
|
|
|
{
|
|
|
|
sHTML+="parent><p><nobr><a id=\""+getBookId(nIdx)+"\" href=\"javascript:void(0);\" onfocus=\"markBook("+nIdx+");\" onclick=\"";
|
|
|
|
sHTML+="insertBookItems("+nIdx+", "+getItemContentsNum(nIdx);
|
|
|
|
sHTML+=");return false;\" title=\""+sName+"\"><img alt=\"Book\" name=\""+getBId(nIdx)+"\" src=\""+sIcon+"\" border=0 align=\"absmiddle\">";
|
|
|
|
sHTML+=" "+sName+"</a></nobr></p></div>";
|
|
|
|
var sURL=_textToHtml_nonbsp(getItemURL(nIdx));
|
|
|
|
if(sURL!="")
|
|
|
|
addBookItem(getBookId(nIdx),_textToHtml_nonbsp(getTopicTarget(nIdx)),sURL);
|
|
|
|
sHTML+="<div id=\""+getCBId(nIdx)+"\" class=child></div>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sHTML="";
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
else
|
2004-12-17 16:18:33 +05:00
|
|
|
{
|
|
|
|
sHTML+="stub></div>";
|
|
|
|
gbNeedFillStub=true;
|
|
|
|
setTimeout("fillStub("+nIdx+","+bLocalProject+");",100);
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
return sHTML;
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function checkFillStub()
|
|
|
|
{
|
|
|
|
if(!gbLData)
|
|
|
|
{
|
|
|
|
if(gchunkRequestQueue.length()>0)
|
|
|
|
{
|
|
|
|
var cInfo=gchunkRequestQueue.deQueue();
|
|
|
|
if(cInfo)
|
|
|
|
{
|
|
|
|
fillStub(cInfo.nIdx,cInfo.bLocal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(gbNeedFillStub)
|
|
|
|
{
|
|
|
|
gbNeedFillStub=false;
|
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillStub(nIdx,bLocalProject)
|
|
|
|
{
|
|
|
|
if(!gbLData)
|
|
|
|
{
|
|
|
|
gbLData=true;
|
|
|
|
var sObj=getElement(getPBId(nIdx));
|
|
|
|
if(sObj!=null)
|
|
|
|
{
|
|
|
|
tocExpandHelpSet(nIdx,bLocalProject);
|
|
|
|
gbNeedFillStub=false;
|
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
setTimeout("fillStub("+nIdx+","+bLocalProject+");",100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gchunkRequestQueue.inQueue(new chunkInfo(nIdx,bLocalProject));
|
|
|
|
}
|
|
|
|
|
2004-06-16 21:45:26 +06:00
|
|
|
function getBookId(nIdx){return "B_"+nIdx;}
|
|
|
|
|
|
|
|
function getItemId(nIdx){return "I_"+nIdx;}
|
|
|
|
|
|
|
|
function markBook(nIdx)
|
|
|
|
{
|
|
|
|
var obj=getElement(getItemId(nIdx));
|
|
|
|
if(obj==null)
|
|
|
|
obj=getElement(getBookId(nIdx));
|
|
|
|
if(gbNav6)
|
|
|
|
{
|
|
|
|
gobj=obj;
|
|
|
|
setTimeout("delayMarkObj();",1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
markObj(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
function delayMarkObj()
|
|
|
|
{
|
|
|
|
if(gobj)
|
|
|
|
{
|
|
|
|
markObj(gobj);
|
|
|
|
gobj=null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function markObj(obj)
|
|
|
|
{
|
|
|
|
if(obj!=null)
|
|
|
|
{
|
|
|
|
HighLightElement(obj,gsABgColor,"transparent");
|
|
|
|
var sPath=calTocPath(obj);
|
|
|
|
if(gsCTPath!=sPath)
|
|
|
|
gsCTPath=sPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function markItem(nIdx)
|
|
|
|
{
|
|
|
|
var obj=getElement(getItemId(nIdx));
|
|
|
|
if(gbNav6)
|
|
|
|
{
|
|
|
|
gobj=obj;
|
|
|
|
setTimeout("delayMarkObj();",1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
markObj(getElement(getItemId(nIdx)));
|
|
|
|
}
|
|
|
|
|
|
|
|
function calTocPath(obj)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var sPath=getInnerText2(obj);
|
2004-06-16 21:45:26 +06:00
|
|
|
var pObj=getParentNode(obj);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
while(pObj!=null&&!isCBId(pObj.id)) pObj=getParentNode(pObj);
|
|
|
|
if(pObj!=null)
|
|
|
|
{
|
|
|
|
var nId=getIdByCBId(pObj.id);
|
|
|
|
var sObj=getElement(getPBId(nId));
|
|
|
|
if(sObj!=null)
|
|
|
|
{
|
|
|
|
var objs=getItemsByBook(sObj);
|
|
|
|
for(var i=0;i<objs.length;i++)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var sText=getInnerText2(objs[i]);
|
2004-06-16 21:45:26 +06:00
|
|
|
if(sText.length!=0)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
sPath=sText+gsPathSplit+sPath;
|
2004-06-16 21:45:26 +06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pObj=getParentNode(pObj);
|
|
|
|
}
|
|
|
|
}while(pObj!=null);
|
|
|
|
return sPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeAnItem(nIdx)
|
|
|
|
{
|
|
|
|
var sTarget=_textToHtml_nonbsp(getTopicTarget(nIdx));
|
|
|
|
var sIcon=getItemIcon(nIdx,0);
|
|
|
|
if(sIcon=="")
|
|
|
|
{
|
|
|
|
var nItemType=getItemType(nIdx);
|
|
|
|
if(nItemType&2)
|
|
|
|
sIcon=getItemImage(nIdx,false);
|
|
|
|
else
|
|
|
|
sIcon=getItemImage(nIdx,true);
|
|
|
|
}
|
|
|
|
sIcon=_textToHtml_nonbsp(sIcon);
|
|
|
|
var sName=_textToHtml(getItemName(nIdx));
|
|
|
|
var sHTML="<p><nobr><a id=\""+getItemId(nIdx)+"\" onfocus=\"markItem("+nIdx+");\""
|
|
|
|
var sAltString="";
|
2004-12-17 16:18:33 +05:00
|
|
|
if(nItemType&2)
|
2004-06-16 21:45:26 +06:00
|
|
|
sAltString="Page";
|
|
|
|
else
|
|
|
|
sAltString="Remote Page";
|
|
|
|
if(sTarget!="")
|
|
|
|
sHTML+="target=\""+sTarget+"\" ";
|
|
|
|
sHTML+="href=\""+_textToHtml_nonbsp(getItemURL(nIdx))+"\" title=\""+sName+"\"><img alt=\""+sAltString+"\" src=\""+sIcon+"\" border=0 align=\"absmiddle\"> "+sName+"</a></nobr></p>";
|
|
|
|
return sHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeBookItems(nIdx,num)
|
|
|
|
{
|
|
|
|
var sHTML="";
|
|
|
|
if(num>0){
|
|
|
|
var nCIdx=0;
|
|
|
|
do{
|
|
|
|
nCIdx++;
|
|
|
|
var i=nIdx+nCIdx;
|
|
|
|
var nItemType=getItemType(i);
|
2004-12-17 16:18:33 +05:00
|
|
|
if(nItemType==1||nItemType==4||nItemType==8){
|
2004-06-16 21:45:26 +06:00
|
|
|
sHTML+=writeBook(i);
|
|
|
|
nCIdx+=getItemContentsNum(i);
|
|
|
|
}
|
|
|
|
else if(nItemType==2||nItemType==16){
|
|
|
|
sHTML+=writeAnItem(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while(nCIdx<num);
|
|
|
|
}
|
|
|
|
return sHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
function tocExpandHelpSet(nIdx,bLocal)
|
|
|
|
{
|
|
|
|
checkBookItem(nIdx);
|
2004-12-17 16:18:33 +05:00
|
|
|
removeLoadingDiv();
|
|
|
|
if(!isHSLoad(nIdx))
|
|
|
|
{
|
2004-06-16 21:45:26 +06:00
|
|
|
setHSLoad(nIdx);
|
|
|
|
var sSrc="";
|
|
|
|
if(bLocal){
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
{
|
|
|
|
goChunk=addTocChunk(oChunk.sPPath,oChunk.sDPath);
|
|
|
|
sSrc=oChunk.aTocs[nIdx-oChunk.nMI].sRefURL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
sSrc=getRefURL(nIdx);
|
|
|
|
var nProj=getProject(sSrc);
|
|
|
|
if(nProj!=-1)
|
|
|
|
{
|
|
|
|
sSrc=gaRoot[nProj].sToc;
|
2004-12-17 16:18:33 +05:00
|
|
|
if(sSrc)
|
|
|
|
goChunk=addTocChunk(gaProj[nProj].sPPath,gaProj[nProj].sDPath);
|
|
|
|
else
|
|
|
|
goChunk=null;
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goChunk=null;
|
|
|
|
}
|
|
|
|
if(goChunk)
|
|
|
|
{
|
|
|
|
PrepareLoading(nIdx);
|
2004-12-17 16:18:33 +05:00
|
|
|
gbToc=false;
|
2004-06-16 21:45:26 +06:00
|
|
|
loadData2(goChunk.sPPath+goChunk.sDPath+sSrc);
|
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gbLData=false;
|
|
|
|
checkFillStub();
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getProject(sSrc)
|
|
|
|
{
|
|
|
|
for(var i=0;i<gaProj.length;i++)
|
|
|
|
if(isSamePath(getPath(sSrc),gaProj[i].sPPath))
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPath(sPath)
|
|
|
|
{
|
|
|
|
if(sPath!="")
|
|
|
|
{
|
|
|
|
sPath=_replaceSlash(sPath);
|
|
|
|
var nPosFile=sPath.lastIndexOf("/");
|
|
|
|
sPath=sPath.substring(0,nPosFile+1);
|
|
|
|
}
|
|
|
|
return sPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isSamePath(sPath1,sPath2)
|
|
|
|
{
|
|
|
|
return (sPath1.toLowerCase()==sPath2.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
function PrepareLoading(nIdx)
|
|
|
|
{
|
|
|
|
gnInsIdx=nIdx;
|
|
|
|
if(!gsTP)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var oObj=getElement(getPBId(gnInsIdx));
|
2004-06-16 21:45:26 +06:00
|
|
|
if(oObj)
|
2004-12-17 16:18:33 +05:00
|
|
|
oObj.insertAdjacentHTML("afterEnd",writeLoadingDiv(nIdx));
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeLoadingDiv(nIdx)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return"<div id=\""+gsLoadingDivID+"\" class=parent onclick=\"removeLoadingDiv();\" style=\"padding-left:4px;background-color:ivory;border-width:1;border-style:solid;border-color:black;width:150px;\">"+gsLoadingMsg+"</div>";
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getItemName(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
return oChunk.aTocs[nIdx-oChunk.nMI].sItemName;
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemContentsNum(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
return oChunk.aTocs[nIdx-oChunk.nMI].nContents;
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemType(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
return oChunk.aTocs[nIdx-oChunk.nMI].nType;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemURL(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
{
|
|
|
|
var sPath=oChunk.aTocs[nIdx-oChunk.nMI].sItemURL;
|
|
|
|
if(!(sPath==null||sPath==""))
|
|
|
|
{
|
|
|
|
return _getFullPath(oChunk.sPPath,sPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRefURL(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
{
|
|
|
|
var sPath=oChunk.aTocs[nIdx-oChunk.nMI].sRefURL;
|
|
|
|
if(!(sPath==null||sPath==""))
|
|
|
|
{
|
|
|
|
return _getFullPath(oChunk.sPPath,sPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTopicTarget(nIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
{
|
|
|
|
if(typeof(oChunk.aTocs[nIdx-oChunk.nMI].sTarget)!="undefined")
|
|
|
|
return oChunk.aTocs[nIdx-oChunk.nMI].sTarget;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemIcon(nIdx,nIconIdx)
|
|
|
|
{
|
|
|
|
var oChunk=getChunk(nIdx);
|
|
|
|
if(oChunk)
|
|
|
|
{
|
|
|
|
if(typeof(oChunk.aTocs[nIdx-oChunk.nMI].sIconRef)!="undefined")
|
|
|
|
{
|
|
|
|
var sIconRef=oChunk.aTocs[nIdx-oChunk.nMI].sIconRef;
|
|
|
|
var nIndex=sIconRef.indexOf(";");
|
|
|
|
while(nIconIdx-->0&&nIndex!=-1)
|
|
|
|
{
|
|
|
|
sIconRef=sIconRef.substring(nIndex+1);
|
|
|
|
nIndex=sIconRef.indexOf(";");
|
|
|
|
}
|
|
|
|
if(nIconIdx<0)
|
|
|
|
{
|
|
|
|
if(nIndex!=-1)
|
|
|
|
sIconRef=sIconRef.substring(0,nIndex);
|
|
|
|
return _getFullPath(oChunk.sPPath,sIconRef)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function TocWriteClassStyle()
|
|
|
|
{
|
|
|
|
var sStyle="<STYLE TYPE='text/css'>\n";
|
2004-12-17 16:18:33 +05:00
|
|
|
if(gsBgImage)
|
2004-06-16 21:45:26 +06:00
|
|
|
sStyle+="body {border-top:"+gsBgColor+" 1px solid;}\n";
|
|
|
|
else
|
|
|
|
sStyle+="body {border-top:black 1px solid;}\n";
|
|
|
|
sStyle+="P {"+getFontStyle(goFont)+"margin-top:"+gsMargin+";margin-bottom:"+gsMargin+";}\n";
|
|
|
|
sStyle+="DIV {margin-top:"+gsMargin+";margin-bottom:"+gsMargin+";}\n";
|
|
|
|
sStyle+=".parent {margin-left:0pt;}\n";
|
2004-12-17 16:18:33 +05:00
|
|
|
sStyle+=".stub {margin-left:0pt;display:none}\n";
|
2004-06-16 21:45:26 +06:00
|
|
|
sStyle+=".child {display:none;margin-left:"+gsIndent+";}\n";
|
|
|
|
sStyle+="A:link {"+getFontStyle(goFont)+"}\n";
|
|
|
|
sStyle+="A:visited {"+getFontStyle(goFont)+"}\n";
|
|
|
|
sStyle+="A:active {background-color:"+gsABgColor+";}\n";
|
|
|
|
sStyle +="A:hover {"+getFontStyle(goHFont)+"}\n";
|
|
|
|
sStyle+="</STYLE>";
|
|
|
|
document.write(sStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
function TocWriteFixedWidth(bBegin,nWidth)
|
|
|
|
{
|
|
|
|
if((gbIE4)&&(gbMac)&&(!gbIE5)){
|
|
|
|
if(bBegin)
|
|
|
|
document.write("<table width="+nWidth+" border=0><tr><td>");
|
|
|
|
else
|
|
|
|
document.write("</td></tr></table>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function TocInitPage()
|
|
|
|
{
|
|
|
|
var tempColl=getItemsByBook(document.body);
|
|
|
|
if(tempColl.length>0)
|
|
|
|
tempColl[0].focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemsFromObj(obj)
|
|
|
|
{
|
|
|
|
var aAnchor=new Array();
|
|
|
|
var tempColl=getChildrenByTag(obj,"P");
|
|
|
|
if(tempColl&&tempColl.length>0)
|
|
|
|
{
|
|
|
|
var anobr=new Array();
|
|
|
|
for(var i=0;i<tempColl.length;i++)
|
|
|
|
{
|
|
|
|
var tempNobr=getChildrenByTag(tempColl[i],"NOBR");
|
|
|
|
if(tempNobr&&tempNobr.length>0)
|
|
|
|
for(var j=0;j<tempNobr.length;j++)
|
|
|
|
anobr[anobr.length]=tempNobr[j];
|
|
|
|
}
|
|
|
|
for(var s=0;s<anobr.length;s++)
|
|
|
|
{
|
|
|
|
var tempAnchor=getChildrenByTag(anobr[s],"A");
|
|
|
|
if(tempAnchor&&tempAnchor.length>0)
|
|
|
|
for(var u=0;u<tempAnchor.length;u++)
|
|
|
|
aAnchor[aAnchor.length]=tempAnchor[u];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aAnchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemsByBook(obj)
|
|
|
|
{
|
|
|
|
var aAnchor=new Array();
|
|
|
|
var aTAnchor=getItemsFromObj(obj);
|
|
|
|
for(var i=0;i<aTAnchor.length;i++)
|
|
|
|
aAnchor[aAnchor.length]=aTAnchor[i];
|
|
|
|
var tempBook=getChildrenByTag(obj,"DIV");
|
|
|
|
if(tempBook&&tempBook.length>0)
|
|
|
|
for(var j=0;j<tempBook.length;j++)
|
|
|
|
{
|
|
|
|
var aTAnchorDiv=getItemsFromObj(tempBook[j]);
|
|
|
|
for(var s=0;s<aTAnchorDiv.length;s++)
|
|
|
|
aAnchor[aAnchor.length]=aTAnchorDiv[s];
|
|
|
|
}
|
|
|
|
return aAnchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ExpandIt(nId)
|
|
|
|
{
|
|
|
|
if(!gsTP)
|
|
|
|
ExpandIt2(nId,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ExpandIt2(nId,bForceOpen)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var oC=TocExpand(nId,true,bForceOpen);
|
|
|
|
var nNewScroll=document.body.scrollTop;
|
|
|
|
if(oC.style.display=="block"){
|
|
|
|
var nTop=oC.offsetTop;
|
|
|
|
var nBottom=nTop+oC.offsetHeight;
|
|
|
|
if(document.body.scrollTop+document.body.clientHeight<nBottom){
|
|
|
|
nNewScroll=nBottom-document.body.clientHeight;
|
|
|
|
}
|
|
|
|
if(nBottom-nTop>document.body.clientHeight){
|
|
|
|
nNewScroll=nTop-20;
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
document.body.scrollTop=nNewScroll;
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function TocExpand(nId,bChangeImg,bForceOpen)
|
|
|
|
{
|
|
|
|
var oDiv=getElement(getCBId(nId));
|
|
|
|
if(oDiv==null) return null;
|
|
|
|
|
|
|
|
var whichIm=document.images[getBId(nId)];
|
|
|
|
if((oDiv.style.display!="block")||bForceOpen){
|
|
|
|
oDiv.style.display="block";
|
|
|
|
if(bChangeImg){
|
|
|
|
var sPath=getPath(whichIm.src);
|
|
|
|
sPath=_getFullPath(sPath,getBookImage(nId,false));
|
|
|
|
whichIm.src=sPath;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
oDiv.style.display="none";
|
|
|
|
if(bChangeImg){
|
|
|
|
var sPath=getPath(whichIm.src);
|
|
|
|
sPath=_getFullPath(sPath,getBookImage(nId,true));
|
|
|
|
whichIm.src=sPath;
|
|
|
|
}
|
|
|
|
if(gbMac&&gbIE5){
|
|
|
|
this.parent.document.getElementById("tocIFrame").style.width="101%";
|
|
|
|
this.parent.document.getElementById("tocIFrame").style.width="100%";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return oDiv;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChunkId(n)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var nCan=-1;
|
|
|
|
for(var i=0;i<gaTocs.length;i++)
|
|
|
|
if(gaTocs[i].nMI<=n&&gaTocs[i].nMI!=-1)
|
|
|
|
{
|
|
|
|
if(nCan==-1)
|
|
|
|
nCan=i;
|
|
|
|
else
|
|
|
|
if(gaTocs[i].nMI>=gaTocs[nCan].nMI)
|
|
|
|
nCan=i;
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
if(nCan!=-1)
|
|
|
|
return nCan;
|
2004-06-16 21:45:26 +06:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChunk(n)
|
|
|
|
{
|
|
|
|
if(gnCC!=-1&&gaTocs[gnCC].nMI<=n&&(gnCC==gaTocs.length-1||
|
|
|
|
gaTocs[gnCC+1].nMI>n))
|
|
|
|
{
|
|
|
|
return gaTocs[gnCC];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
gnCC=getChunkId(n);
|
|
|
|
if(gnCC!=-1)
|
|
|
|
return gaTocs[gnCC];
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBookImage(nIdx,bClosed)
|
|
|
|
{
|
|
|
|
var nIdx=bClosed?0:1;
|
|
|
|
var sIcon=getItemIcon(nIdx,nIdx);
|
|
|
|
if(sIcon=="")
|
|
|
|
if(bClosed)
|
|
|
|
sIcon=giBookClose;
|
|
|
|
else
|
|
|
|
sIcon=giBookOpen;
|
|
|
|
return _getFullPath(gaProj[0].sPPath,sIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemImage(nIdx,bRemote)
|
|
|
|
{
|
|
|
|
var sIcon=getItemIcon(nIdx,0);
|
|
|
|
if(sIcon=="")
|
|
|
|
if(bRemote)
|
|
|
|
sIcon=giURLItem;
|
|
|
|
else
|
|
|
|
sIcon=giBookItem;
|
|
|
|
return _getFullPath(gaProj[0].sPPath,sIcon);
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
function getInnerText2(obj)
|
|
|
|
{
|
|
|
|
var sText=getInnerText(obj);
|
|
|
|
if(sText.length>0&&!gbOpera7)
|
|
|
|
sText=sText.substring(1);
|
|
|
|
return sText;
|
|
|
|
}
|
|
|
|
|
2004-06-16 21:45:26 +06:00
|
|
|
function expandToc(oObj,sRest,aIdList)
|
|
|
|
{
|
|
|
|
var len=aIdList.length;
|
|
|
|
var nPos=sRest.indexOf(gsPathSplit);
|
|
|
|
if(nPos!=-1)
|
|
|
|
{
|
|
|
|
sPart=sRest.substring(0,nPos);
|
|
|
|
sRest=sRest.substring(nPos+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sPart=sRest;
|
|
|
|
var aTagAs=getItemsByBook(oObj);
|
|
|
|
for(var s=0;s<aTagAs.length;s++)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var sText=getInnerText2(aTagAs[s]);
|
2004-06-16 21:45:26 +06:00
|
|
|
if(sText==sPart)
|
|
|
|
{
|
|
|
|
aIdList[len]=aTagAs[s];
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
var aChildren=getChildrenByTag(oObj,"DIV");
|
|
|
|
for(var i=0;i<aChildren.length;i++)
|
|
|
|
{
|
|
|
|
var sPId=aChildren[i].id;
|
|
|
|
if(!isPBId(sPId))
|
|
|
|
continue;
|
2004-12-17 16:18:33 +05:00
|
|
|
var sText=getInnerText2(aChildren[i]);
|
|
|
|
if(sText!=sPart)
|
2004-06-16 21:45:26 +06:00
|
|
|
continue;
|
|
|
|
aIdList[len]=getIdByPBId(sPId);
|
|
|
|
var sCId=getCBId(aIdList[len]);
|
|
|
|
var oCObj=getElement(sCId);
|
|
|
|
if(oCObj)
|
|
|
|
{
|
|
|
|
if(oCObj.innerHTML=="")
|
|
|
|
{
|
|
|
|
var obj=getItemsByBook(aChildren[i]);
|
|
|
|
if(obj.length>0)
|
|
|
|
{
|
|
|
|
if(gbNav6)
|
|
|
|
{
|
|
|
|
var sCommand=obj[0].getAttribute("onClick");
|
|
|
|
var nCommand=sCommand.indexOf(";");
|
|
|
|
sCommand=sCommand.substring(0,nCommand);
|
|
|
|
setTimeout(sCommand,1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
obj[0].click();
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
var nRet=expandToc(oCObj,sRest,aIdList);
|
|
|
|
if(nRet)
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aIdList.length=len;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getIdByPBId(sPId)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return parseInt(sPId.substring(2,sPId.length-1));
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getIdByCBId(sCId)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return parseInt(sCId.substring(2,sCId.length-1));
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function isPBId(sId)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return (sId&&sId.indexOf("B_")==0&&sId.lastIndexOf("P")==sId.length-1);
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function isCBId(sId)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return (sId&&sId.indexOf("B_")==0&&sId.lastIndexOf("C")==sId.length-1);
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getBId(nIdx)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return "B_"+nIdx;
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPBId(nIdx)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return getBId(nIdx)+"P";
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCBId(nIdx)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
return getBId(nIdx)+"C";
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function getClosestTocPath(aPaths)
|
|
|
|
{
|
|
|
|
var nMaxSimilarity=0;
|
|
|
|
var nThatIndex=-1;
|
|
|
|
var sPath=null;
|
|
|
|
if(aPaths.length==0) return sPath;
|
|
|
|
for(var i=0;i<aPaths.length;i++)
|
|
|
|
{
|
|
|
|
var nSimilarity=comparePath(gsCTPath,aPaths[i]);
|
|
|
|
if(nSimilarity>nMaxSimilarity)
|
|
|
|
{
|
|
|
|
nMaxSimilarity=nSimilarity;
|
|
|
|
nThatIndex=i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(nThatIndex!=-1)
|
|
|
|
sPath=aPaths[nThatIndex];
|
|
|
|
else
|
|
|
|
sPath=aPaths[0];
|
|
|
|
return sPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
function comparePath(sPath1,sPath2)
|
|
|
|
{
|
|
|
|
var nMaxSimilarity=0;
|
|
|
|
var nStartPos1=0;
|
|
|
|
var nPos1=-1;
|
|
|
|
var nStartPos2=0;
|
|
|
|
var nPos2=-1;
|
|
|
|
do{
|
|
|
|
var sCheck1=null;
|
|
|
|
var sCheck2=null;
|
|
|
|
nPos1=sPath1.indexOf(gsPathSplit,nStartPos1);
|
|
|
|
if(nPos1!=-1)
|
|
|
|
{
|
|
|
|
sCheck1=sPath1.substring(nStartPos1,nPos1);
|
|
|
|
nStartPos1=nPos1+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sCheck1=sPath1.substring(nStartPos1);
|
|
|
|
nStartPos1=-1;
|
|
|
|
}
|
|
|
|
nPos2=sPath2.indexOf(gsPathSplit,nStartPos2);
|
|
|
|
if(nPos1!=-1)
|
|
|
|
{
|
|
|
|
sCheck2=sPath2.substring(nStartPos2,nPos2);
|
|
|
|
nStartPos2=nPos2+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sCheck2=sPath2.substring(nStartPos2);
|
|
|
|
nStartPos2=-1;
|
|
|
|
}
|
|
|
|
if(sCheck1==sCheck2)
|
|
|
|
nMaxSimilarity++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}while(nStartPos1!=-1&&nStartPos2!=-1);
|
|
|
|
return nMaxSimilarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTocPaths(oTopicParam)
|
|
|
|
{
|
|
|
|
var aRelTocPaths=oTopicParam.aPaths;
|
|
|
|
var aPaths=new Array();
|
|
|
|
for(var i=0;i<gaProj.length;i++)
|
|
|
|
if(isSamePath(gaProj[i].sPPath,oTopicParam.sPPath))
|
|
|
|
{
|
|
|
|
for(var j=0;j<aRelTocPaths.length;j++)
|
2004-12-17 16:18:33 +05:00
|
|
|
for (var k=0;k<gaRoot[i].aRPath.length;k++)
|
|
|
|
{
|
|
|
|
var sPath=gaRoot[i].aRPath[k]+aRelTocPaths[j];
|
|
|
|
aPaths[aPaths.length]=sPath.substring(1);
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return aPaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncInit()
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(gsTP&&!gbNeedFillStub)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
|
|
|
gInSync=true;
|
|
|
|
var obj=document.body;
|
|
|
|
var aIdList=new Array();
|
|
|
|
var nRet=expandToc(obj,gsTP,aIdList);
|
|
|
|
if(nRet!=-1)
|
|
|
|
{
|
|
|
|
if(nRet==1)
|
|
|
|
{
|
|
|
|
if(aIdList.length)
|
|
|
|
for(var i=0;i<aIdList.length-1;i++)
|
|
|
|
ExpandIt2(aIdList[i],true);
|
|
|
|
gsCTPath=gsTP;
|
|
|
|
if(!gbIE55)
|
|
|
|
aIdList[aIdList.length-1].focus();
|
|
|
|
else
|
|
|
|
HighLightElement(aIdList[aIdList.length-1],gsABgColor,"transparent");
|
|
|
|
}
|
|
|
|
var aPaths=gaBTPs;
|
|
|
|
gsTP=null;
|
|
|
|
gaBTPs=null;
|
|
|
|
if(aPaths!=null)
|
|
|
|
{
|
|
|
|
var sPath=getClosestTocPath(aPaths);
|
|
|
|
if(sPath!=null)
|
|
|
|
{
|
|
|
|
gsTP=sPath;
|
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gInSync=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadToc()
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(!gbLoadToc)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
|
|
|
var oResMsg=new whMessage(WH_MSG_GETPROJINFO,this,1,null);
|
|
|
|
if(SendMessage(oResMsg)&&oResMsg.oParam)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
gbLoadToc=true;
|
2004-06-16 21:45:26 +06:00
|
|
|
var oProj=oResMsg.oParam;
|
|
|
|
gaProj=oProj.aProj;
|
|
|
|
gbXML=oProj.bXML;
|
|
|
|
load1B1();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function load1B1()
|
|
|
|
{
|
|
|
|
if(gnLT+1<gaProj.length)
|
|
|
|
for(var i=gnLT+1;i<gaProj.length;i++)
|
2004-12-17 16:18:33 +05:00
|
|
|
if(gaProj[i].sToc)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
gbToc=true;
|
2004-06-16 21:45:26 +06:00
|
|
|
gnLT=i;
|
|
|
|
setTimeout("loadTocInfo()",1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadTocInfo()
|
|
|
|
{
|
|
|
|
loadData2(gaProj[gnLT].sPPath+gaProj[gnLT].sDPath+gaProj[gnLT].sToc);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadData2(sFile)
|
|
|
|
{
|
|
|
|
if(gbXML)
|
|
|
|
loadDataXML(sFile);
|
|
|
|
else
|
|
|
|
loadData(sFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
function projReady(sRoot,aProj)
|
|
|
|
{
|
|
|
|
if(gaRoot.length<=gnLT||!gaRoot[gnLT])
|
|
|
|
gaRoot[gnLT]=new Object();
|
|
|
|
gaRoot[gnLT].sToc=sRoot;
|
|
|
|
|
|
|
|
if(gnLT==0)
|
2004-12-17 16:18:33 +05:00
|
|
|
{
|
|
|
|
gaRoot[gnLT].aRPath=new Array();
|
|
|
|
gaRoot[gnLT].aRPath[0]=gsPathSplit;
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
|
|
|
|
updatePTPath(gnLT,aProj);
|
|
|
|
|
|
|
|
if(!((gnLT+1<gaProj.length)&&load1B1()))
|
|
|
|
{
|
|
|
|
gbReady=true;
|
|
|
|
if(gbIE4)
|
|
|
|
setTimeout("loadImages();",1);
|
|
|
|
else
|
|
|
|
setTimeout("loadTData();",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadTData()
|
|
|
|
{
|
|
|
|
if(gaProj[0].sToc!="")
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
gbLData=true;
|
2004-06-16 21:45:26 +06:00
|
|
|
goChunk=addTocChunk(gaProj[0].sPPath,gaProj[0].sDPath);
|
2004-12-17 16:18:33 +05:00
|
|
|
gbToc=false;
|
2004-06-16 21:45:26 +06:00
|
|
|
loadData2(gaProj[0].sPPath+gaProj[0].sDPath+gaRoot[0].sToc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updatePTPath(n,aProj)
|
|
|
|
{
|
|
|
|
if(aProj)
|
|
|
|
for(var i=0;i<aProj.length;i++)
|
|
|
|
{
|
|
|
|
var sFullPath=_getFullPath(gaProj[n].sPPath,aProj[i].sPPath);
|
|
|
|
for(var j=0;j<gaProj.length;j++)
|
|
|
|
if(isSamePath(sFullPath,gaProj[j].sPPath))
|
|
|
|
{
|
|
|
|
if(gaRoot.length<=j||!gaRoot[j])
|
|
|
|
gaRoot[j]=new Object();
|
2004-12-17 16:18:33 +05:00
|
|
|
if(!gaRoot[j].aRPath)
|
|
|
|
gaRoot[j].aRPath=new Array();
|
|
|
|
|
|
|
|
if(gaRoot[n].aRPath)
|
|
|
|
for(var k=0;k<gaRoot[n].aRPath.length;k++)
|
|
|
|
{
|
|
|
|
var bDup=false;
|
|
|
|
var sTFPath=gaRoot[n].aRPath[k]+aProj[i].sRPath;
|
|
|
|
for(var l=0;l<gaRoot[j].aRPath.length;l++)
|
|
|
|
if(gaRoot[j].aRPath[l]==sTFPath)
|
|
|
|
{
|
|
|
|
bDup=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!bDup)
|
|
|
|
gaRoot[j].aRPath[gaRoot[j].aRPath.length]=sTFPath;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gaRoot[j].aRPath[gaRoot[j].aRPath.length]=aProj[i].sRPath;
|
2004-06-16 21:45:26 +06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoadXMLError()
|
|
|
|
{
|
|
|
|
if(gbToc)
|
|
|
|
{
|
|
|
|
var sRoot="";
|
|
|
|
var aRProj=new Array();
|
|
|
|
projReady(sRoot,aRProj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var aToc=new Array();
|
|
|
|
putData(aToc)
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function putDataXML(xmlDoc,sDocPath)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(gbToc)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
|
|
|
var tocNode=xmlDoc.getElementsByTagName("toc")[0];
|
|
|
|
if(tocNode)
|
|
|
|
{
|
|
|
|
var sRoot=tocNode.getAttribute("root");
|
|
|
|
var rmtProject=tocNode.getElementsByTagName("project");
|
|
|
|
var aRProj=new Array();
|
|
|
|
if(rmtProject.length>0)
|
|
|
|
{
|
|
|
|
for(var i=0;i<rmtProject.length;i++)
|
|
|
|
{
|
|
|
|
aRProj[i]=new Object();
|
2004-12-17 16:18:33 +05:00
|
|
|
var sURL=rmtProject[i].getAttribute("url");
|
|
|
|
if(sURL)
|
|
|
|
{
|
|
|
|
if(sURL.lastIndexOf("/")!=sURL.length-1)
|
|
|
|
sURL+="/";
|
|
|
|
}
|
|
|
|
aRProj[i].sPPath=sURL;
|
|
|
|
aRProj[i].sRPath = "";
|
|
|
|
var oSubPath = rmtProject[i].getElementsByTagName("subpath")[0];
|
|
|
|
if (oSubPath)
|
|
|
|
{
|
|
|
|
while (oSubPath)
|
|
|
|
{
|
|
|
|
aRProj[i].sRPath += oSubPath.getAttribute("name") + "\n";
|
|
|
|
oSubPath = oSubPath.getElementsByTagName("subpath")[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRProj[i].sRPath=rmtProject[i].getAttribute("path");
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
projReady(sRoot,aRProj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var chunkNode=xmlDoc.getElementsByTagName("tocdata")[0];
|
|
|
|
if(chunkNode)
|
|
|
|
{
|
|
|
|
var aToc=new Array();
|
|
|
|
processBook(chunkNode,aToc);
|
|
|
|
putData(aToc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function processBook(node,aToc)
|
|
|
|
{
|
|
|
|
var i=0;
|
|
|
|
var entry=null;
|
|
|
|
var prevEntry=null;
|
|
|
|
var oChild=node.firstChild;
|
|
|
|
do{
|
|
|
|
if(oChild)
|
|
|
|
{
|
|
|
|
if(oChild.nodeName.indexOf("#")!=0)
|
|
|
|
{
|
|
|
|
var sName=oChild.getAttribute("name");
|
|
|
|
var sURL=oChild.getAttribute("url");
|
|
|
|
var sRef=oChild.getAttribute("ref");
|
|
|
|
var sTarget=oChild.getAttribute("target");
|
|
|
|
var sIcons=oChild.getAttribute("images");
|
|
|
|
var item=new Object();
|
|
|
|
item.sItemName=sName;
|
|
|
|
if(sTarget)
|
|
|
|
item.sTarget=sTarget;
|
|
|
|
if(sIcons)
|
|
|
|
item.sIconRef=sIcons;
|
|
|
|
if(sURL==null) sURL="";
|
2004-12-17 16:18:33 +05:00
|
|
|
|
2004-06-16 21:45:26 +06:00
|
|
|
item.sItemURL=sURL;
|
|
|
|
|
|
|
|
if(oChild.nodeName=="book")
|
|
|
|
{
|
|
|
|
item.nType=1;
|
|
|
|
aToc[aToc.length]=item;
|
|
|
|
var nCurrPos=aToc.length;
|
|
|
|
processBook(oChild,aToc);
|
|
|
|
item.nContents=aToc.length-nCurrPos;
|
|
|
|
}
|
|
|
|
else if(oChild.nodeName=="item")
|
|
|
|
{
|
|
|
|
item.nType=2;
|
|
|
|
item.nContents=0;
|
|
|
|
aToc[aToc.length]=item;
|
|
|
|
}
|
|
|
|
else if(oChild.nodeName=="remoteitem")
|
|
|
|
{
|
|
|
|
item.nType=16;
|
|
|
|
item.nContents=0;
|
|
|
|
aToc[aToc.length]=item;
|
|
|
|
}
|
|
|
|
else if(oChild.nodeName=="project")
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(sRef)
|
|
|
|
{
|
|
|
|
if(sRef.lastIndexOf("/")!=sRef.length-1)
|
|
|
|
sRef+="/";
|
|
|
|
}
|
2004-06-16 21:45:26 +06:00
|
|
|
item.nType=4;
|
|
|
|
item.sRefURL=sRef;
|
|
|
|
item.nContents=0;
|
|
|
|
aToc[aToc.length]=item;
|
|
|
|
}
|
|
|
|
else if(oChild.nodeName=="chunk")
|
|
|
|
{
|
|
|
|
item.nType=8;
|
|
|
|
item.sRefURL=sRef;
|
|
|
|
item.nContents=0;
|
|
|
|
aToc[aToc.length]=item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
oChild=oChild.nextSibling;
|
|
|
|
}while(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function putData(aTocs)
|
|
|
|
{
|
|
|
|
gaTocsNs61Fix=aTocs;
|
|
|
|
setTimeout("realPutData();",1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function realPutData()
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
removeLoadingDiv();
|
2004-06-16 21:45:26 +06:00
|
|
|
var aTocs=gaTocsNs61Fix;
|
|
|
|
if(!aTocs) return;
|
|
|
|
if(goChunk)
|
|
|
|
{
|
|
|
|
var n=gnMinIdx;
|
|
|
|
goChunk.nMI=gnMinIdx;
|
|
|
|
goChunk.aTocs=aTocs;
|
|
|
|
gnMinIdx+=aTocs.length;
|
|
|
|
if(gnInsIdx!=-1)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
var oObj=getElement(getPBId(gnInsIdx));
|
2004-06-16 21:45:26 +06:00
|
|
|
if(oObj)
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
oObj.insertAdjacentHTML("afterEnd",writeBookItems(n-1,aTocs.length));
|
2004-06-16 21:45:26 +06:00
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
document.body.insertAdjacentHTML("beforeEnd",writeBookItems(n-1,aTocs.length));
|
|
|
|
var oParam=new Object();
|
|
|
|
oParam.oTocInfo=null;
|
|
|
|
var oMsg=new whMessage(WH_MSG_GETTOCPATHS,this,1,oParam);
|
|
|
|
if(SendMessage(oMsg))
|
|
|
|
{
|
2004-12-17 16:18:33 +05:00
|
|
|
if(oMsg.oParam.oTocInfo)
|
2004-06-16 21:45:26 +06:00
|
|
|
syncWithPaths(oMsg.oParam.oTocInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
gbLData=false;
|
|
|
|
checkFillStub();
|
2004-06-16 21:45:26 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
function syncWithPaths(oTopicParam)
|
|
|
|
{
|
|
|
|
var aPaths=getTocPaths(oTopicParam);
|
|
|
|
if(gsTP)
|
|
|
|
gaBTPs=aPaths;
|
|
|
|
else{
|
|
|
|
var sPath=getClosestTocPath(aPaths);
|
|
|
|
if(sPath!=null)
|
|
|
|
{
|
|
|
|
gsTP=sPath;
|
|
|
|
setTimeout("syncInit()",1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function window_OnLoad()
|
|
|
|
{
|
|
|
|
if(gsBgImage&&gsBgImage.length>0)
|
|
|
|
{
|
|
|
|
document.body.background=gsBgImage;
|
|
|
|
}
|
|
|
|
if(gsBgColor&&gsBgColor.length>0)
|
|
|
|
{
|
|
|
|
document.body.bgColor=gsBgColor;
|
|
|
|
}
|
|
|
|
loadToc();
|
|
|
|
var oMsg=new whMessage(WH_MSG_SHOWTOC,this,1,null)
|
|
|
|
SendMessage(oMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadImages()
|
|
|
|
{
|
|
|
|
if(giBookClose)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giBookClose;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giBookOpen)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giBookOpen;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giBookItem)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giBookItem;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giURLItem)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giURLItem;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giNewBookClose)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giNewBookClose;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giNewBookOpen)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giNewBookOpen;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giNewBookItem)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giNewBookItem;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(giNewURLItem)
|
|
|
|
{
|
|
|
|
gaImgs[gnImages]=giNewURLItem;
|
|
|
|
gnImages++;
|
|
|
|
}
|
|
|
|
if(gnImages>0)
|
|
|
|
{
|
|
|
|
setTimeout("loadDataAfter();",1000);
|
|
|
|
loadImage(gaImgs[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
loadDataAfter();
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadImage(sURL)
|
|
|
|
{
|
|
|
|
var oImg=new Image();
|
|
|
|
oImg.onload=checkImageLoading;
|
|
|
|
oImg.onerror=errorImageLoading;
|
|
|
|
oImg.src=_getFullPath(gaProj[0].sPPath,sURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadDataAfter()
|
|
|
|
{
|
|
|
|
if(!gbLoadData)
|
|
|
|
{
|
|
|
|
gbLoadData=true;
|
|
|
|
loadTData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function errorImageLoading()
|
|
|
|
{
|
|
|
|
gnLoadedImages++;
|
|
|
|
if(gnImages==gnLoadedImages)
|
|
|
|
loadDataAfter();
|
|
|
|
else
|
|
|
|
loadImage(gaImgs[gnLoadedImages]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkImageLoading()
|
|
|
|
{
|
|
|
|
gnLoadedImages++;
|
|
|
|
if(gnImages==gnLoadedImages)
|
|
|
|
loadDataAfter();
|
|
|
|
else
|
|
|
|
loadImage(gaImgs[gnLoadedImages]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function window_unload()
|
|
|
|
{
|
|
|
|
UnRegisterListener2(this,WH_MSG_PROJECTREADY);
|
|
|
|
UnRegisterListener2(this,WH_MSG_SYNCTOC);
|
|
|
|
UnRegisterListener2(this,WH_MSG_SHOWTOC);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSendMessage(oMsg)
|
|
|
|
{
|
|
|
|
if(oMsg)
|
|
|
|
{
|
|
|
|
var nMsgId=oMsg.nMessageId;
|
|
|
|
if(nMsgId==WH_MSG_PROJECTREADY)
|
|
|
|
{
|
|
|
|
loadToc();
|
|
|
|
}
|
|
|
|
else if(nMsgId==WH_MSG_SYNCTOC)
|
|
|
|
{
|
|
|
|
if(gbReady)
|
|
|
|
{
|
|
|
|
syncWithPaths(oMsg.oParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(nMsgId==WH_MSG_SHOWTOC)
|
|
|
|
{
|
|
|
|
if(!gbNav6)
|
|
|
|
document.body.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-17 16:18:33 +05:00
|
|
|
if(window.gbWhUtil&&window.gbWhVer&&window.gbWhMsg&&window.gbWhProxy)
|
2004-06-16 21:45:26 +06:00
|
|
|
{
|
|
|
|
RegisterListener2(this,WH_MSG_PROJECTREADY);
|
|
|
|
RegisterListener2(this,WH_MSG_SYNCTOC);
|
|
|
|
RegisterListener2(this,WH_MSG_SHOWTOC);
|
|
|
|
goFont=new whFont("Verdana","8pt","#000000","normal","normal","none");
|
|
|
|
goHFont=new whFont("Verdana","8pt","#007f00","normal","normal","underline");
|
|
|
|
|
|
|
|
window.onload=window_OnLoad;
|
|
|
|
window.onbeforeunload=window_BUnload;
|
|
|
|
window.onunload=window_unload;
|
|
|
|
gbWhTHost=true;
|
|
|
|
}
|
|
|
|
else
|
2004-12-17 16:18:33 +05:00
|
|
|
document.location.reload();
|