whhost.js
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:24k
源码类别:

SNMP编程

开发平台:

C/C++

  1. var gaChunks=new Array();
  2. var gaFakes=new Array();
  3. var gaDataCon=null;
  4. var gaData=new Array();
  5. var gbFindCK=false;;
  6. var gbNeedCalc=false;
  7. var gbScrl=false;
  8. var gbProcess=false;
  9. var gbReady=false;
  10. var gnCheck=0;
  11. var gnNum=0;
  12. var gnIns=-1;
  13. var gnLoad=0;
  14. var gnRef=-1;
  15. var gnMaxItems=0;
  16. var gnMaxMargin=32000;
  17. var gnNeeded=0;
  18. var gnNKI=-1;
  19. var gnRE=0;
  20. var gnScrlMgn=30;
  21. var gnSE=0;
  22. var gnVisible=0;
  23. var gnItems=0;
  24. var gnUHeight=1;
  25. var gsBCK=null;
  26. var gsChK=null;
  27. var gsCK=null;
  28. var gsLoadingDivID="LoadingDiv";
  29. var gsLoadingMsg="Loading data, please wait...";
  30. var gsSKA=null;
  31. var gsSKB=null;
  32. var gbLoadInfo=false;
  33. function putDataXML(xmlDoc,sDocPath)
  34. {
  35. if(gbLoadInfo)
  36. {
  37. var node=xmlDoc.lastChild;
  38. if(node)
  39. {
  40. var nTotal=0
  41. var aChunk=new Array();
  42. var oC=node.firstChild;
  43. while(oC)
  44. {
  45. if(oC.nodeName=="chunkinfo")
  46. {
  47. var item=new Object();
  48. item.sBK=oC.getAttribute("first");
  49. item.sEK=oC.getAttribute("last");
  50. item.sFileName=oC.getAttribute("url");
  51. item.nNum=parseInt(oC.getAttribute("num"));
  52. nTotal+=item.nNum;
  53. item.nTotal=nTotal;
  54. aChunk[aChunk.length]=item;
  55. }
  56. oC=oC.nextSibling;
  57. }
  58. projReady(aChunk);
  59. }
  60. }
  61. else
  62. {
  63. var node=xmlDoc.lastChild;
  64. if(node)
  65. {
  66. var aData=new Array();
  67. var nPrev=0;
  68. var nNext=0;
  69. var oC=node.firstChild;
  70. while(oC)
  71. {
  72. nPrev=nNext;
  73. if(oC.nodeName=="key")
  74. {
  75. var sName=oC.getAttribute("name");
  76. if(sName&&sName.length>0)
  77. {
  78. var sTarget=oC.getAttribute("target");
  79. var item=new Object();
  80. item.nType=2;
  81. item.sName=sName;
  82. if(sTarget)
  83. item.sTarget=sTarget;
  84. item.nPKOff=nPrev;
  85. aData[aData.length]=item;
  86. var nCurIndex=aData.length;
  87. processKey(oC,aData,item);
  88. nNext=aData.length-nCurIndex;
  89. item.nNKOff=nNext;
  90. }
  91. }
  92. else if(oC.nodeName=="letter")
  93. {
  94. var name=oC.getAttribute("name");
  95. if(name&&name.length>0)
  96. {
  97. var item=new Object();
  98. item.nType=1;
  99. item.sName=name;
  100. item.nPKOff=nPrev;
  101. nNext=0;
  102. item.nNKOff=nNext;
  103. aData[aData.length]=item;
  104. }
  105. }
  106. else if(oC.nodeName=="entry")
  107. {
  108. var name=oC.getAttribute("name");
  109. var def=oC.getAttribute("value");
  110. if(name&&name.length>0)
  111. {
  112. var item=new Object();
  113. item.sName=name;
  114. item.sDef=def;
  115. item.nPKOff=nPrev;
  116. nNext=0;
  117. item.nNKOff=nNext;
  118. aData[aData.length]=item;
  119. }
  120. }
  121. oC=oC.nextSibling;
  122. }
  123. putData(aData);
  124. }
  125. }
  126. }
  127. function processKey(element,aData,item)
  128. {
  129. var i=0;
  130. var nPrev=0;
  131. var nNext=0;
  132. var oC=element.firstChild;
  133. while(oC)
  134. {
  135. if(oC.nodeName=="topic")
  136. {
  137. var name=oC.getAttribute("name");
  138. var url=oC.getAttribute("url");
  139. if(url&&url.length!=0)
  140. {
  141. if(!name||name.length==0)
  142. name=url;
  143. var topic=new Object();
  144. topic.sName=name;
  145. topic.sURL=url;
  146. if(!item.aTopics)
  147. item.aTopics=new Array();
  148. item.aTopics[item.aTopics.length]=topic;
  149. }
  150. }
  151. else if(oC.nodeName=="key")
  152. {
  153. nPrev=nNext;
  154. var name=oC.getAttribute("name");
  155. if(name&&name.length!=0)
  156. {
  157. var subItem=new Object();
  158. subItem.sName=name;
  159. subItem.nType=3;
  160. subItem.nPKOff=nPrev;
  161. aData[aData.length]=subItem;
  162. var nCurIndex=aData.length;
  163. processKey(oC,aData,subItem);
  164. nNext=aData.length-nCurIndex;
  165. subItem.nNKOff=nNext;
  166. }
  167. }
  168. oC=oC.nextSibling;
  169. }
  170. }
  171. function putData(aData)
  172. {
  173. endLoading();
  174. var oCData=goCData;
  175. if(oCData)
  176. {
  177. oCData.aKs=aData;
  178. if(gnNKI==-1)
  179. setTimeout("checkReady();",1);
  180. else
  181. {
  182. gsSKA=getKByIdx(oCData,gnNKI);
  183. gbNeedCalc=true;
  184. gbScrl=true;
  185. gnNKI=-1;
  186. if(gsSKA)
  187. setTimeout("checkReady();",1);
  188. else
  189. {
  190. markEnd();
  191. setTimeout("checkAgain();",50);
  192. }
  193. }
  194. }
  195. }
  196. function markEnd()
  197. {
  198. if(gbProcess)
  199. gbProcess=false;
  200. }
  201. function endLoading()
  202. {
  203. var oDiv=getElement(gsLoadingDivID);
  204. if(oDiv)
  205. oDiv.style.visibility="hidden";
  206. }
  207. function markBegin()
  208. {
  209. gbProcess=true;
  210. }
  211. function beginLoading()
  212. {
  213. var oDiv=getElement(gsLoadingDivID);
  214. if(oDiv)
  215. {
  216. oDiv.style.top=document.body.scrollTop;
  217. oDiv.style.visibility="visible";
  218. }
  219. }
  220. function indexHTMLPart()
  221. {
  222. this.sHTML="";
  223. this.nNeeded=0;
  224. this.nCurrent=0;
  225. this.nConsumed=0;
  226. this.sFK=null;
  227. this.sLK=null;
  228. this.addHTML=function(sHTML,nConsumed,bDown,bK,sK){
  229. if(bDown)
  230. this.sHTML+=sHTML;
  231. else
  232. this.sHTML=sHTML+this.sHTML;
  233. this.nCurrent++;
  234. this.nConsumed+=nConsumed;
  235. if(bK)
  236. {
  237. if(!this.sFK)
  238. this.sFK=sK;
  239. if(!this.sLK)
  240. this.sLK=sK;
  241. if(bDown)
  242. this.sLK=sK;
  243. else
  244. this.sFK=sK;
  245. }
  246. }
  247. this.appendHTML=function(oHTML,bDown){
  248. this.addSubHTML(oHTML,bDown);
  249. if(!this.sFK)
  250. this.sFK=oHTML.sFK;
  251. if(!this.sLK)
  252. this.sLK=oHTML.sLK;
  253. if(bDown)
  254. this.sLK=oHTML.sLK;
  255. else
  256. this.sFK=oHTML.sFK;
  257. }
  258. this.addSubHTML=function(oHTML,bDown){
  259. if(bDown)
  260. this.sHTML+=oHTML.sHTML;
  261. else
  262. this.sHTML=oHTML.sHTML+this.sHTML;
  263. this.nCurrent+=oHTML.nCurrent;
  264. this.nConsumed+=oHTML.nConsumed;
  265. }
  266. }
  267. function getMaxUnits()
  268. {
  269. return Math.floor(gnMaxMargin/gnUHeight)+1;
  270. }
  271. function getFakeItemsHTMLbyCount(nB,nCount)
  272. {
  273. var nMU=getMaxUnits();
  274. var nNum=Math.floor(nCount/nMU);
  275. var sHTML="";
  276. for(var i=0;i<nNum;i++)
  277. sHTML+=getFakeItemHTML(nB,nMU-1);
  278. var nRest=nCount%nMU;
  279. sHTML+=getFakeItemHTML(nB,nRest-1);
  280. return sHTML;
  281. }
  282. function getFakeItemHTML(nB,nNum)
  283. {
  284. return "<h6 name=fk"+nB+" id=fk"+nB+" style="margin-top:"+gnUHeight*nNum+";margin-bottom:0">&nbsp;</h6>";
  285. }
  286. function fakeItemsArea(nB,n,sKA,sKB,obj)
  287. {
  288. this.nB=nB;
  289. this.nNum=n;
  290. this.sKA=sKA;
  291. this.sKB=sKB;
  292. this.obj=obj;
  293. this.nMargin=(n-1)*gnUHeight;
  294. this.setNum=function(n)
  295. {
  296. var nLastobj=-1;
  297. var nDelta=this.nMargin;
  298. this.nMargin=(n-1)*gnUHeight;
  299. nDelta=nDelta-this.nMargin;
  300. if(n>0)
  301. {
  302. this.nNum=n;
  303. var nMU=getMaxUnits();
  304. nLastobj=Math.floor((n-1)/nMU);
  305. if(this.obj.length)
  306. this.obj[nLastobj].style.marginTop=((n-1)%nMU)*gnUHeight;
  307. else
  308. this.obj.style.marginTop=((n-1)%nMU)*gnUHeight;
  309. }
  310. if(this.obj.length)
  311. {
  312. for(var i=this.obj.length-1;i>nLastobj;i--)
  313. removeThis(this.obj[i]);
  314. }
  315. else
  316. {
  317. if(nLastobj==-1)
  318. removeThis(this.obj);
  319. }
  320. return nDelta;
  321. }
  322. this.insertAdjacentHTML=function(sWhere,sHTML)
  323. {
  324. if(sWhere=="beforeBegin")
  325. {
  326. if(this.obj.length)
  327. this.obj[0].insertAdjacentHTML(sWhere,sHTML);
  328. else
  329. this.obj.insertAdjacentHTML(sWhere,sHTML);
  330. }
  331. else if(sWhere=="afterEnd")
  332. {
  333. if(this.obj.length)
  334. {
  335. if(gbMac&&gbIE5&&this.obj[this.obj.length-1].nextSibling)
  336. this.obj[this.obj.length-1].nextSibling.insertAdjacentHTML("beforeBegin",sHTML);
  337. else
  338. this.obj[this.obj.length-1].insertAdjacentHTML(sWhere,sHTML);
  339. }
  340. else
  341. {
  342. if(gbMac&&gbIE5&&this.obj.nextSibling)
  343. this.obj.nextSibling.insertAdjacentHTML("beforeBegin",sHTML);
  344. else
  345. this.obj.insertAdjacentHTML(sWhere,sHTML);
  346. }
  347. }
  348. }
  349. this.getBtm=function()
  350. {
  351. if(this.obj.length)
  352. return this.obj[this.obj.length-1].offsetTop;
  353. else
  354. return this.obj.offsetTop;
  355. }
  356. this.getTop=function()
  357. {
  358. return this.getBtm()-this.nMargin;
  359. }
  360. }
  361. function usedItems(nB,nE)
  362. {
  363. this.nB=nB;
  364. this.nE=nE;
  365. this.oN=null;
  366. }
  367. function checkReady()
  368. {
  369. var len=gaChunks.length;
  370. var bNeedLoad=false;
  371. var aDataCon;
  372. var s=0;
  373. var bDown=(gsSKB==null);
  374. var sK=bDown?gsSKA:gsSKB;
  375. if(sK==null)
  376. {
  377. markEnd();
  378. setTimeout("checkAgain();",50);
  379. return;
  380. }
  381. if(!gsChK||sK!=gsChK||gnNum==0)
  382. {
  383. gnCheck=0;
  384. gsChK=sK;
  385. aDataCon=new Array();
  386. }
  387. else{
  388. s=gnNum;
  389. aDataCon=gaDataCon;
  390. }
  391. for(var i=gnCheck;i<len;i++)
  392. {
  393. var oCData=getChunkedData(i,bDown,sK);
  394. if(oCData)
  395. {
  396. if(!oCData.aKs&&oCData.sFileName!=null)
  397. {
  398. bNeedLoad=true;
  399. goCData=oCData;
  400. gnNum=s;
  401. gnCheck=i;
  402. gaDataCon=aDataCon;
  403. oCData.nProjId=i;
  404. gbLoadInfo=false;
  405. beginLoading();
  406. loadData2(gaData[i].sPPath+gaData[i].sDPath+oCData.sFileName);
  407. return;
  408. }
  409. else{
  410. aDataCon[s++]=oCData;
  411. }
  412. }
  413. }
  414. if(!bNeedLoad)
  415. {
  416. gnNum=0;
  417. gsSKA=gsSKB=gsShowK=null;
  418. var oHTML=new indexHTMLPart();
  419. var aPos=new Array();
  420. var aOriPos=new Array();
  421. var aMaxPos=new Array();
  422. var aMinPos=new Array();
  423. if(gbNeedCalc||gbFindCK) gnIns=0;
  424. for(i=0;i<aDataCon.length;i++)
  425. {
  426. aPos[i]=getIdxPos(aDataCon[i],bDown,sK);
  427. if(gbNeedCalc||gbFindCK)
  428. {
  429. gnIns+=aPos[i]+aDataCon[i].nTotal-aDataCon[i].nNum;
  430. if(!bDown)
  431. {
  432. if(aPos[i]!=-1)
  433. {
  434. if(aDataCon[i].aKs)
  435. gnIns+=aDataCon[i].aKs[aPos[i]].nNKOff;
  436. else
  437. {
  438. var n=aPos[i]+1;
  439. while(n<aDataCon[i].aKsOnly.length&&!aDataCon[i].aKsOnly[n])
  440. n++;
  441. n=n-aPos[i]-1;
  442. gnIns+=n;
  443. }
  444. }
  445. }
  446. }
  447. aOriPos[i]=aPos[i];
  448. getLimit(aDataCon,aPos,aMaxPos,aMinPos,i);
  449. }
  450. if((gbNeedCalc||gbFindCK)&&!bDown&&gnIns!=-1)
  451. {
  452. gnIns+=(aDataCon.length-1)
  453. }
  454. if(gnIns!=-1||gbFindCK)
  455. {
  456. oHTML.nNeeded=gnNeeded;
  457. var bDone=writeItems(oHTML,aDataCon,aPos,aMinPos,aMaxPos,bDown,1);
  458. if(oHTML.nConsumed!=0)
  459. {
  460. var nB;
  461. if(!bDown)
  462. nB=gnIns-oHTML.nConsumed+1;
  463. else
  464. nB=gnIns;
  465. var oldScrollPos=document.body.scrollTop;
  466. if(insertIdxKs(nB,oHTML,gbScrl))
  467. {
  468. updateUsedK(aDataCon,aOriPos,aPos,bDown);
  469. if(!gbScrl&&gbMac)
  470. {
  471. while(document.body.scrollTop!=oldScrollPos)
  472. document.body.scrollTop=oldScrollPos;
  473. }
  474. gbScrl=false;
  475. }
  476. if(gbFindCK)
  477. {
  478. gbFindCK=false;
  479. gbNeedCalc=true;
  480. gsSKB=oHTML.sFK;
  481. gnIns=-1;
  482. setTimeout("checkReady();",50);
  483. return;
  484. }
  485. }
  486. else if(gbFindCK)
  487. {
  488. gbFindCK=false;
  489. gbNeedCalc=true;
  490. gsSKB=getFirstKeyFromPos(aDataCon,aPos);
  491. gnIns=-1;
  492. setTimeout("checkReady();",50);
  493. return;
  494. }
  495. if(!findCKInDom()) return;
  496. gnNeeded=gnNeeded-oHTML.nCurrent;
  497. gnIns=-1;
  498. markEnd();
  499. setTimeout("checkAgain();",50);
  500. gbNeedCalc=false;
  501. }
  502. else
  503. {
  504. if(!findCKInDom()) return;
  505. markEnd();
  506. setTimeout("checkAgain();",50);
  507. }
  508. }
  509. }
  510. function getFirstKeyFromPos(aDataCon,aPos)
  511. {
  512. var sCurrentK=getBiggestChar();
  513. for(var i=0;i<aPos.length;i++)
  514. {
  515. if(aDataCon[i].aKs&&aDataCon[i].aKs.length>0&&aPos[i]>=0&&aPos[i]<aDataCon[i].aKs.length)
  516. {
  517. if(sCurrentK==""||
  518. compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)>0)
  519. {
  520. sCurrentK=aDataCon[i].aKs[aPos[i]].sName;
  521. }
  522. }
  523. }
  524. return sCurrentK;
  525. }
  526. function checkAgain()
  527. {
  528. if(!gbProcess)
  529. {
  530. if(gsBCK!=null)
  531. {
  532. gsCK=gsBCK;
  533. gsBCK=null;
  534. findCK();
  535. }
  536. else
  537. {
  538. markBegin();
  539. getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  540. }
  541. }
  542. else
  543. setTimeout("checkAgain()",50);
  544. }
  545. function getLimit(aDataCon,aPos,aMaxPos,aMinPos,i)
  546. {
  547. aMaxPos[i]=aDataCon[i].nNum;
  548. aMinPos[i]=-1;
  549. var oPNode=null;
  550. if(aDataCon[i].oUsedItems)
  551. {
  552. var oUsedItems=aDataCon[i].oUsedItems;
  553. do{
  554. if(oUsedItems.nB>aPos[i])
  555. {
  556. aMaxPos[i]=oUsedItems.nB;
  557. break;
  558. }
  559. oPNode=oUsedItems;
  560. oUsedItems=oUsedItems.oN;
  561. }while(oUsedItems!=null);
  562. if(oPNode)
  563. aMinPos[i]=oPNode.nE;
  564. }
  565. else if(aDataCon[i].aKs==null)
  566. {
  567. aMaxPos[i]=aMinPos[i]=aPos[i];
  568. }
  569. if(aMinPos[i]>=aPos[i]||aMaxPos[i]<=aPos[i])
  570. {
  571. aMaxPos[i]=aMinPos[i]=aPos[i];
  572. }
  573. }
  574. function getIdxPos(oIdx,bDown,sK)
  575. {
  576. var aKs=oIdx.aKs;
  577. var nIdx;
  578. if(bDown)
  579. nIdx=oIdx.nNum;
  580. else
  581. nIdx=-1;
  582. if(aKs!=null)
  583. {
  584. for(var i=0;i<aKs.length;i++)
  585. {
  586. if(bDown)
  587. {
  588. if(compare(aKs[i].sName,sK)>0)
  589. {
  590. nIdx=i;
  591. break;
  592. }
  593. }
  594. else
  595. {
  596. if(compare(aKs[i].sName,sK)<0)
  597. nIdx=i;
  598. else
  599. break;
  600. }
  601. i+=aKs[i].nNKOff;
  602. }
  603. }
  604. else if(oIdx.aKsOnly)
  605. {
  606. var aKsOnly=oIdx.aKsOnly;
  607. for(var i=0;i<aKsOnly.length;i++)
  608. {
  609. if(aKsOnly[i])
  610. {
  611. if(bDown)
  612. {
  613. if(compare(aKsOnly[i],sK)>0)
  614. {
  615. nIdx=i;
  616. break;
  617. }
  618. }
  619. else
  620. {
  621. if(compare(aKsOnly[i],sK)<0)
  622. nIdx=i;
  623. else
  624. break;
  625. }
  626. }
  627. }
  628. }
  629. return nIdx;
  630. }
  631. function writeItems(oHTML,aDataCon,aPos,aMinPos,aMaxPos,bDown,nLevel)
  632. {
  633. var aOldPos=new Array();
  634. for(var i=0;i<aPos.length;i++)
  635. {
  636. aOldPos[i]=aPos[i];
  637. }
  638. var p;
  639. do{
  640. var sCurrentK="";
  641. var aCurIdxSet=new Array();
  642. p=0;
  643. for(i=0;i<aDataCon.length;i++)
  644. {
  645. if(aDataCon[i].aKs&&aDataCon[i].aKs.length&&aPos[i]!=-1&&
  646. (bDown&&aPos[i]<aMaxPos[i])||(!bDown&&aPos[i]>aMinPos[i]))
  647. {
  648. if(sCurrentK==""||
  649. (bDown&&compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)>0)||
  650. (!bDown&&compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)<0))
  651. {
  652. sCurrentK=aDataCon[i].aKs[aPos[i]].sName;
  653. p=0;
  654. aCurIdxSet[p++]=i;
  655. }
  656. else if(sCurrentK==aDataCon[i].aKs[aPos[i]].sName){
  657. aCurIdxSet[p++]=i;
  658. }
  659. }
  660. else if(nLevel==1&&aMaxPos[i]!=aMinPos[i]){
  661. if(bDown&&aPos[i]==aMaxPos[i])
  662. {
  663. if(aDataCon[i].aKs)
  664. {
  665. gsSKA=aDataCon[i].aKs[aOldPos[i]].sName;
  666. return false;
  667. }
  668. }
  669. else if(!bDown&&aPos[i]==aMinPos[i])
  670. {
  671. if(aDataCon[i].aKs)
  672. {
  673. gsSKB=aDataCon[i].aKs[aOldPos[i]].sName;
  674. return false;
  675. }
  676. }
  677. }
  678. }
  679. if(p>=1){
  680. for(var s=0;s<p;s++)
  681. {
  682. aOldPos[aCurIdxSet[s]]=aPos[aCurIdxSet[s]];
  683. }
  684. mergeItems(oHTML,bDown,aDataCon,aCurIdxSet,p,aPos,nLevel);
  685. adjustPosition(bDown,aDataCon,aCurIdxSet,p,aPos);
  686. if(nLevel==1&&oHTML.nNeeded<=oHTML.nCurrent){
  687. return true;
  688. }
  689. }
  690. }while(p>0);
  691. return true;
  692. }
  693. function updateUsedK(aDataCon,aOriPos,aOldPos,bDown)
  694. {
  695. for(var i=0;i<aDataCon.length;i++)
  696. {
  697. if (aOldPos[i]!=aOriPos[i])
  698. {
  699. var nBP=0;
  700. var nEP=0;
  701. if(bDown)
  702. {
  703. nBP=aOriPos[i];
  704. nEP=aOldPos[i]-1;
  705. }
  706. else
  707. {
  708. if (aOldPos[i]!=-1)
  709. nBP=aOldPos[i]+aDataCon[i].aKs[aOldPos[i]].nNKOff+1;
  710. else
  711. nBP=0;
  712. nEP=aOriPos[i]+aDataCon[i].aKs[aOriPos[i]].nNKOff;
  713. }
  714. if(nBP<=nEP)
  715. {
  716. setContentsUsed(aDataCon[i],nBP,nEP);
  717. var oFirstPair=aDataCon[i].oUsedItems;
  718. if(oFirstPair.oN==null&&oFirstPair.nB==0&&oFirstPair.nE==aDataCon[i].nNum-1)
  719. {
  720. storeKeysOnly(aDataCon[i]);
  721. aDataCon[i].oUsedItems=aDataCon[i].aKs=aDataCon[i].sFileName=null;
  722. }
  723. }
  724. }
  725. }
  726. }
  727. function storeKeysOnly(oCData)
  728. {
  729. oCData.aKsOnly=new Array();
  730. for(var i=0;i<oCData.aKs.length;i++)
  731. {
  732. oCData.aKsOnly[i]=oCData.aKs[i].sName;
  733. i+=oCData.aKs[i].nNKOff;
  734. }
  735. }
  736. function setContentsUsed(oIdx,nB,nE)
  737. {
  738. if(!oIdx.oUsedItems)
  739. oIdx.oUsedItems=new usedItems(nB,nE);
  740. else
  741. {
  742. var oUsedItems=oIdx.oUsedItems;
  743. var oPNode=null;
  744. do{
  745. if(oUsedItems.nB>nB)
  746. {
  747. if(oUsedItems.nB==nE+1)
  748. {
  749. oUsedItems.nB=nB;
  750. }
  751. else{
  752. var oNewNode=new usedItems(oUsedItems.nB,oUsedItems.nE);
  753. oNewNode.oN=oUsedItems.oN;
  754. oUsedItems.nB=nB;
  755. oUsedItems.nE=nE;
  756. oUsedItems.oN=oNewNode;
  757. }
  758. break;
  759. }
  760. oPNode=oUsedItems;
  761. oUsedItems=oUsedItems.oN;
  762. }while(oUsedItems);
  763. if(!oUsedItems)
  764. {
  765. if(oPNode!=null)
  766. oPNode.oN=new usedItems(nB,nE);
  767. }
  768. if(oPNode!=null){
  769. if(oPNode.nE==oPNode.oN.nB-1)
  770. {
  771. oPNode.nE=oPNode.oN.nE;
  772. oPNode.oN=oPNode.oN.oN;
  773. }
  774. }
  775. }
  776. }
  777. function projInfo(sPPath,sDPath,sFile)
  778. {
  779. this.sPPath=sPPath;
  780. this.sDPath=sDPath;
  781. this.sFile=sFile;
  782. }
  783. function addProjInfo(sPPath,sDPath,sFile)
  784. {
  785. var oIdxInfo=new projInfo(sPPath,sDPath,sFile);
  786. gaData[gaData.length]=oIdxInfo;
  787. return oIdxInfo;
  788. }
  789. function writeDataIFrame()
  790. {
  791. if(gnLoad<gaData.length)
  792. {
  793. gbLoadInfo=true;
  794. loadData2(gaData[gnLoad].sPPath+gaData[gnLoad].sDPath+gaData[gnLoad].sFile);
  795. }
  796. else{
  797. if(gnItems!=0)
  798. {
  799. markBegin();
  800. writeFakeItems();
  801. gsSKA="";
  802. gnNeeded=gnVisible;
  803. gnIns=0;
  804. checkReady();
  805. }
  806. }
  807. }
  808. function getH6ById(nPos)
  809. {
  810. if(document.all)
  811. return document.all("fk"+nPos);
  812. else if(document.getElementsByName)
  813. return document.getElementsByName("fk"+nPos);
  814. return null;
  815. }
  816. function showItemsInEvaluation(nBP)
  817. {
  818. var bRtn=true;
  819. var fPer=nBP/gnItems;
  820. var nB=Math.floor(fPer*gnMaxItems);
  821. var oCData=getChunkByIdx(gnRef,nB);
  822. if(oCData)
  823. {
  824. if(!oCData.aKs&&oCData.sFileName!=null)
  825. {
  826. gnNKI=nB;
  827. goCData=oCData;
  828. oCData.nProjId=gnRef;
  829. gbLoadInfo=false;
  830. beginLoading();
  831. loadData2(gaData[gnRef].sPPath+gaData[gnRef].sDPath+oCData.sFileName);
  832. }
  833. else{
  834. gsSKA=getKByIdx(oCData,nB);
  835. if(gsSKA)
  836. {
  837. gsSKB=null;
  838. gbNeedCalc=true;
  839. gbScrl=true;
  840. checkReady()
  841. }
  842. else
  843. {
  844. markEnd();
  845. bRtn=false;
  846. }
  847. }
  848. }
  849. else
  850. {
  851. markEnd();
  852. bRtn=false;
  853. }
  854. return bRtn;
  855. }
  856. function isUsed(oCData,nPos)
  857. {
  858. var oUsed=oCData.oUsedItems;
  859. while(oUsed&&oUsed.nB<=nPos)
  860. {
  861. if(oUsed.nE>=nPos) return true;
  862. oUsed=oUsed.oN;
  863. }
  864. return false;
  865. }
  866. function getKByIdx(oCData,nB)
  867. {
  868. var nRelPos=nB-(oCData.nTotal-oCData.nNum);
  869. var aIKs=oCData.aKs;
  870. if(nRelPos>=0&&aIKs&&nRelPos<aIKs.length)
  871. {
  872. var oK=null;
  873. do{
  874. oK=aIKs[nRelPos++];
  875. }
  876. while((oK.nType==3||isUsed(oCData,nRelPos-1))&&nRelPos<aIKs.length);
  877. if(oK.nType!=3)
  878. {
  879. return oK.sName;
  880. }
  881. else{
  882. nRelPos=nB-(oCData.nTotal-oCData.nNum)-1;
  883. if(nRelPos>=0)
  884. {
  885. do{
  886. oK=aIKs[nRelPos--];
  887. }
  888. while((oK.nType==3||isUsed(oCData,nRelPos+1))&&nRelPos>=0);
  889. }
  890. if(oK.nType!=3)
  891. {
  892. return oK.sName;
  893. }
  894. }
  895. }
  896. return null;
  897. }
  898. function loadData2(sFileName)
  899. {
  900. disEvt();
  901. if(gbXML)
  902. loadDataXML(sFileName);
  903. else
  904. loadData(sFileName);
  905. enEvt();
  906. }
  907. function projReady(aChunk)
  908. {
  909. gaChunks[gnLoad++]=aChunk;
  910. var len=aChunk.length;
  911. var nTotal=0;
  912. if(len>0)
  913. nTotal=aChunk[len-1].nTotal;
  914. gnItems+=nTotal;
  915. if(nTotal>gnMaxItems)
  916. {
  917. gnMaxItems=nTotal;
  918. gnRef=gnLoad-1;
  919. }
  920. setTimeout("writeDataIFrame();",1);
  921. }
  922. function writeFakeItems()
  923. {
  924. disEvt();
  925. gnUHeight=15;
  926. var sHTML=getFakeItemsHTMLbyCount(0,gnItems);
  927. document.body.insertAdjacentHTML("beforeEnd",sHTML);
  928. var obj=getH6ById(0);
  929. if (document.body != null)
  930. {
  931. gnVisible=Math.ceil(document.body.clientHeight/gnUHeight);
  932. }
  933. gaFakes[0]=new fakeItemsArea(0,gnItems,"",getEndString(),obj);
  934. enEvt();
  935. }
  936. function getEndString()
  937. {
  938. var sBC=getBiggestChar();
  939. return sBC+sBC+sBC+sBC+sBC+sBC+sBC+sBC;
  940. }
  941. function getUnitIdx(nScrl,nHeight)
  942. {
  943. if(gaFakes.length==0)
  944. {
  945. markEnd();
  946. return;
  947. }
  948. var nB=0;
  949. var nE=gaFakes.length-1;
  950. var nM=-1;
  951. var nTop=0;
  952. var nBtm=0;
  953. var bF=false;
  954. do{
  955. nM=(nB+nE)>>1;
  956. nBtm=gaFakes[nM].getBtm();
  957. nTop=gaFakes[nM].getTop();
  958. if(nTop>=nScrl+nHeight)
  959. nE=nM-1;
  960. else if(nBtm<nScrl)
  961. nB=nM+1;
  962. else{
  963. bF=true;
  964. break;
  965. }
  966. }while(nE>=nB);
  967. if(bF)
  968. {
  969. if(nTop>=nScrl){
  970. gsSKA=gaFakes[nM].sKA;
  971. gsSKB=null;
  972. gnNeeded=Math.ceil((nHeight-nTop+nScrl)/gnUHeight);
  973. gnIns=gaFakes[nM].nB;
  974. checkReady();
  975. }
  976. else if(nBtm<=nScrl+nHeight){
  977. gsSKB=gaFakes[nM].sKB;
  978. gsSKA=null;
  979. gnNeeded=Math.ceil((nBtm-nScrl+gnScrlMgn)/gnUHeight);
  980. gbNeedCalc=true;
  981. checkReady();
  982. }
  983. else{
  984. gnNeeded=gnVisible;
  985. var nUnitIdx=gaFakes[nM].nB+Math.floor((nScrl-nTop)/gnUHeight);
  986. if (!showItemsInEvaluation(nUnitIdx))
  987. {
  988. gsSKA=gaFakes[nM].sKA;
  989. gsSKB=null;
  990. gnNeeded=Math.ceil(nHeight/gnUHeight);
  991. gnIns=gaFakes[nM].nB;
  992. checkReady();
  993. }
  994. }
  995. }
  996. else
  997. markEnd();
  998. }
  999. function disEvt()
  1000. {
  1001. window.onscroll=null;
  1002. window.onresize=null;
  1003. }
  1004. function enEvt()
  1005. {
  1006. window.onscroll=window_OnScroll;
  1007. window.onresize=window_OnResize;
  1008. }
  1009. function insertIdxKs(nIns,oHTML,bScrl)
  1010. {
  1011. var bRtn=true;
  1012. disEvt();
  1013. var nCount=oHTML.nConsumed;
  1014. var nB=0;
  1015. var nE=gaFakes.length-1;
  1016. var nM=-1;
  1017. var bF=false;
  1018. do{
  1019. nM=(nB+nE)>>1;
  1020. if(gaFakes[nM].nB>nIns)
  1021. nE=nM-1;
  1022. else if(gaFakes[nM].nB+gaFakes[nM].nNum<=nIns)
  1023. nB=nM+1;
  1024. else{
  1025. bF=true;
  1026. break;
  1027. }
  1028. }while(nE>=nB);
  1029. if(bF)
  1030. {
  1031. var oFIA=gaFakes[nM];
  1032. var nOffsetTop=oFIA.getTop();
  1033. var nOffsetBottom=oFIA.getBtm();
  1034. var nDelta=0;
  1035. var nHDiff=nIns-oFIA.nB;
  1036. var nTDiff=oFIA.nNum+oFIA.nB-(nIns+nCount);
  1037. if(nHDiff>0)
  1038. {
  1039. nDelta=oFIA.setNum(nHDiff);
  1040. var sOldKBefore=oFIA.sKB;
  1041. oFIA.sKB=oHTML.sFK;
  1042. if(nTDiff>0)
  1043. {
  1044. var sHTML=getFakeItemsHTMLbyCount(nIns,nTDiff);
  1045. oFIA.insertAdjacentHTML("afterEnd",sHTML);
  1046. var obj=getH6ById(nIns);
  1047. insertItemIntoArray(gaFakes,nM+1,new fakeItemsArea(nIns+nCount,nTDiff,oHTML.sLK,sOldKBefore,obj));
  1048. }
  1049. oFIA.insertAdjacentHTML("afterEnd",oHTML.sHTML);
  1050. if(bScrl)
  1051. {
  1052. if(gbMac&&gbIE4)
  1053. {
  1054. var nScrollPos=nOffsetBottom-nDelta;
  1055. while(document.body.scrollTop!=nScrollPos)
  1056. document.body.scrollTop=nScrollPos;
  1057. }
  1058. else
  1059. window.scrollTo(0,nOffsetBottom-nDelta);
  1060. }
  1061. }
  1062. else{
  1063. oFIA.insertAdjacentHTML("beforeBegin",oHTML.sHTML);
  1064. if(bScrl){
  1065. if(gbMac&&gbIE4)
  1066. {
  1067. var nScrollPos=nOffsetTop;
  1068. while(document.body.scrollTop!=nScrollPos)
  1069. document.body.scrollTop=nScrollPos;
  1070. }
  1071. else
  1072. window.scrollTo(0,nOffsetTop);
  1073. }
  1074. if(nTDiff>0)
  1075. {
  1076. oFIA.nB=nIns+nCount;
  1077. nDelta=oFIA.setNum(nTDiff);
  1078. oFIA.sKA=oHTML.sLK;
  1079. }
  1080. else{
  1081. gaFakes[nM].setNum(0);
  1082. removeItemFromArray(gaFakes,nM);
  1083. }
  1084. }
  1085. }
  1086. else
  1087. bRtn=false;
  1088. enEvt();
  1089. return bRtn;
  1090. }
  1091. function window_OnScroll()
  1092. {
  1093. gnSE++;
  1094. setTimeout("procScroll();",50);
  1095. }
  1096. function procScroll()
  1097. {
  1098. if(gnSE==1&&!gbProcess)
  1099. {
  1100. markBegin();
  1101. getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  1102. }
  1103. gnSE--;
  1104. }
  1105. function window_OnResize()
  1106. {
  1107. gnRE++;
  1108. setTimeout("procResize();",50);
  1109. }
  1110. function procResize()
  1111. {
  1112. if(gnRE==1&&!gbProcess)
  1113. {
  1114. markBegin();
  1115. gnVisible=Math.ceil(document.body.clientHeight/gnUHeight);
  1116. if(gnIns==-1)
  1117. getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  1118. }
  1119. gnRE--;
  1120. }
  1121. function getChunkByIdx(nIdx,nPosition)
  1122. {
  1123. var oCData=null;
  1124. if(nIdx<gaChunks.length)
  1125. {
  1126. var len=gaChunks[nIdx].length;
  1127. if(len>0)
  1128. {
  1129. var nB=0;
  1130. var nE=len-1;
  1131. var bF=false;
  1132. do{
  1133. var nM=(nB+nE)>>1;
  1134. if(nPosition<gaChunks[nIdx][nM].nTotal)
  1135. {
  1136. bF=true;
  1137. nE=nM;
  1138. }
  1139. else
  1140. nB=nM+1;
  1141. }while(nE>nB);
  1142. if(bF)
  1143. oCData=gaChunks[nIdx][nE];
  1144. else if(nPosition<gaChunks[nIdx][nB].nTotal)
  1145. oCData=gaChunks[nIdx][nB];
  1146. }
  1147. }
  1148. return oCData;
  1149. }
  1150. function getChunkedData(nIdx,bDown,sK)
  1151. {
  1152. var oCData=null;
  1153. var nCandId=-1;
  1154. if(nIdx<gaChunks.length)
  1155. {
  1156. var len=gaChunks[nIdx].length;
  1157. if(len>0)
  1158. {
  1159. var nB=0;
  1160. var nE=len-1;
  1161. var bF=false;
  1162. do{
  1163. var nM=(nB+nE+(bDown?0:1))>>1;
  1164. if(bDown)
  1165. {
  1166. if(compare(sK,gaChunks[nIdx][nM].sEK)<0)
  1167. {
  1168. bF=true;
  1169. nE=nM;
  1170. }
  1171. else
  1172. nB=nM+1;
  1173. }
  1174. else
  1175. {
  1176. if(compare(sK,gaChunks[nIdx][nM].sBK)>0)
  1177. {
  1178. bF=true;
  1179. nB=nM;
  1180. }
  1181. else
  1182. nE=nM-1;
  1183. }
  1184. }while(nE>nB);
  1185. if(bF)
  1186. {
  1187. if(bDown)
  1188. nCandId=nE;
  1189. else
  1190. nCandId=nB;
  1191. }
  1192. else
  1193. {
  1194. if(bDown)
  1195. {
  1196. if(gaChunks[nIdx].length>nB&&compare(sK,gaChunks[nIdx][nB].sEK)<0)
  1197. nCandId=nB;
  1198. else
  1199. nCandId=gaChunks[nIdx].length-1;
  1200. }
  1201. else
  1202. {
  1203. if(0<=nE&&compare(sK,gaChunks[nIdx][nE].sBK)>0)
  1204. nCandId=nE;
  1205. else
  1206. nCandId=0;
  1207. }
  1208. }
  1209. return gaChunks[nIdx][nCandId];
  1210. }
  1211. }
  1212. return null;
  1213. }
  1214. function findCK()
  1215. {
  1216. if(gsCK!=null)
  1217. {
  1218. gsSKA=gsCK;
  1219. gbFindCK=true;
  1220. gnNeeded=1;
  1221. markBegin();
  1222. checkReady();
  1223. }
  1224. }
  1225. function writeLoadingDiv(nIIdx)
  1226. {
  1227. return "<div id=""+gsLoadingDivID+"" style="position:absolute;top:0;left:0;z-index:600;visibility:hidden;padding-left:4px;background-color:ivory;border-width:1;border-style:solid;border-color:black;width:150px;">"+gsLoadingMsg+"</div>";
  1228. }
  1229. var gbWhHost=true;