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

SNMP编程

开发平台:

C/C++

  1. var gbXML=false;
  2. var gaDef=new Array();
  3. var gsBgColor="#ffffff";
  4. var gsBgImage="";
  5. var goFont=null;
  6. var goHoverFont=null;
  7. var gsMargin="2pt";
  8. var gsIndent="2pt";
  9. var gsActiveBgColor="#cccccc";
  10. var gbWhGHost=false;
  11. function setBackground(sBgImage)
  12. {
  13. gsBgImage=sBgImage;
  14. }
  15. function setBackgroundcolor(sBgColor)
  16. {
  17. gsBgColor=sBgColor;
  18. }
  19. function setFont(sType,sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration)
  20. {
  21. var vFont=new whFont(sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration);
  22. if(sType=="Normal")
  23. goFont=vFont;
  24. else if(sType=="Hover")
  25. goHoverFont=vFont;
  26. }
  27. function setActiveBgColor(sBgColor)
  28. {
  29. gsActiveBgColor=sBgColor;
  30. }
  31. function setMargin(sMargin)
  32. {
  33. gsMargin=sMargin;
  34. }
  35. function setIndent(sIndent)
  36. {
  37. gsIndent=sIndent;
  38. }
  39. function writeOneItem(oHTML,bDown,aDataCon,aCurIdxSet,n,aPos,nLevel)
  40. {
  41. var sHTML="";
  42. var nIdxSet=aCurIdxSet[n];
  43. var nIIdx=aPos[nIdxSet];
  44. var sRawKName = getItemName(aDataCon,nIdxSet,nIIdx);
  45. var sKName=_textToHtml(sRawKName);
  46. var nIndex=insertDef(sKName,_textToHtml_nonbsp(getDef(aDataCon,nIdxSet,nIIdx)));
  47. if(nLevel==1){
  48. sHTML+="<p><nobr><a alt="" + sKName+"" href="javascript:void(0);" onclick="showDef("+nIndex;
  49. sHTML+=");return false;">"+sKName+"</a></nobr></p>";
  50. }
  51. oHTML.addHTML(sHTML,1,bDown,true,sRawKName);
  52. }
  53. function insertDef(sKName,sDef)
  54. {
  55. var nLength=gaDef.length
  56. var oGlo=new nameDefPair(sKName,sDef);
  57. gaDef[nLength]=oGlo;
  58. return nLength;
  59. }
  60. function showDef(nDef)
  61. {
  62. if(nDef<gaDef.length)
  63. {
  64. var oParam=gaDef[nDef];
  65. var oMsg=new whMessage(WH_MSG_SHOWGLODEF,this,1,oParam);
  66. SendMessage(oMsg);
  67. }
  68. }
  69. function nameDefPair(sName,sDef)
  70. {
  71. this.sName=sName;
  72. this.sDef=sDef;
  73. }
  74. function mergeItems(oHTML,bDown,aDataCon,aCurIdxSet,nLength,aPos,nLevel)
  75. {
  76. for(var i=0;i<nLength;i++)
  77. writeOneItem(oHTML,bDown,aDataCon,aCurIdxSet,i,aPos,nLevel);
  78. }
  79. function adjustPosition(bDown,aDataCon,aCurIdxSet,nLength,aPos)
  80. {
  81. if(bDown)
  82. {
  83. for(var i=0;i<nLength;i++)
  84. aPos[aCurIdxSet[i]]++;
  85. }
  86. else{
  87. for(var i=0;i<nLength;i++)
  88. aPos[aCurIdxSet[i]]--;
  89. }
  90. }
  91. function getDef(aDataCon,nIdxSet,nIIdx)
  92. {
  93. if(nIdxSet<aDataCon.length&&aDataCon[nIdxSet].aKs.length>nIIdx)
  94. return aDataCon[nIdxSet].aKs[nIIdx].sDef;
  95. else
  96. return null;
  97. }
  98. function getItemName(aDataCon,nIdxSet,nIIdx)
  99. {
  100. if(nIdxSet<aDataCon.length&&aDataCon[nIdxSet].aKs.length>nIIdx)
  101. return aDataCon[nIdxSet].aKs[nIIdx].sName;
  102. else
  103. return null;
  104. }
  105. function window_OnLoad()
  106. {
  107. if(gsBgImage&&gsBgImage.length>0)
  108. document.body.background=gsBgImage;
  109. if(gsBgColor&&gsBgColor.length>0)
  110. document.body.bgColor=gsBgColor;
  111. document.body.insertAdjacentHTML("beforeEnd",writeLoadingDiv());
  112. loadGlo();
  113. var oMsg=new whMessage(WH_MSG_SHOWGLO,this,1,null)
  114. SendMessage(oMsg);
  115. }
  116. function loadGlo()
  117. {
  118. if(!gbReady)
  119. {
  120. var oResMsg=new whMessage(WH_MSG_GETPROJINFO,this,1,null);
  121. if(SendMessage(oResMsg)&&oResMsg.oParam)
  122. {
  123. gbReady=true;
  124. var oProj=oResMsg.oParam;
  125. var aProj=oProj.aProj;
  126. gbXML=oProj.bXML;
  127. if(aProj.length>0)
  128. {
  129. var sLangId=aProj[0].sLangId;
  130. for(var i=0;i<aProj.length;i++)
  131. {
  132. if(aProj[i].sGlo!=null&&aProj[i].sGlo!=""&&aProj[i].sLangId==sLangId)
  133. addProjInfo(aProj[i].sPPath,aProj[i].sDPath,aProj[i].sGlo);
  134. }
  135. }
  136. writeDataIFrame();
  137. enEvt();
  138. }
  139. }
  140. }
  141. function findCKInDom()
  142. {
  143. return true;
  144. }
  145. function GloWriteClassStyle()
  146. {
  147. var sStyle="<STYLE TYPE='text/css'>n";
  148. if (gsBgImage)
  149. sStyle+="body {border-top:"+gsBgColor+" 1px solid;}n";
  150. else
  151. sStyle+="body {border-top:black 1px solid;}n";
  152. sStyle+="P {"+getFontStyle(goFont)+"margin-top:"+gsMargin+";margin-bottom:"+gsMargin+";margin-left:"+gsIndent+";}n";
  153. sStyle+="A:link {"+getFontStyle(goFont)+"}n";
  154. sStyle+="A:visited {"+getFontStyle(goFont)+"}n";
  155. sStyle+="A:active {background-color:"+gsActiveBgColor+";}n";
  156. sStyle+="A:hover {"+getFontStyle(goHoverFont)+"}n";
  157. sStyle+="</STYLE>";
  158. document.write(sStyle);
  159. }
  160. function window_Unload()
  161. {
  162. UnRegisterListener2(this,WH_MSG_PROJECTREADY);
  163. UnRegisterListener2(this,WH_MSG_SHOWGLO);
  164. }
  165. function onSendMessage(oMsg)
  166. {
  167. if(oMsg)
  168. {
  169. var nMsgId=oMsg.nMessageId;
  170. if(nMsgId==WH_MSG_SHOWGLO)
  171. {
  172. if(!gbNav6)
  173. document.body.focus();
  174. }
  175. else if(nMsgId==WH_MSG_PROJECTREADY)
  176. {
  177. loadGlo();
  178. }
  179. }
  180. return true;
  181. }
  182. if (window.gbWhUtil&&window.gbWhProxy&&window.gbWhVer&&window.gbWhLang&&window.gbWhMsg&&window.gbWhHost)
  183. {
  184. RegisterListener2(this,WH_MSG_PROJECTREADY);
  185. RegisterListener2(this,WH_MSG_SHOWGLO);
  186. goFont=new whFont("Verdana","8pt","#000000","normal","normal","none");
  187. goHoverFont=new whFont("Verdana","8pt","#007f00","normal","normal","underline");
  188. window.onload=window_OnLoad;
  189. window.onbeforeunload=window_BUnload;
  190. window.onunload=window_Unload;
  191. gbWhGHost=true;
  192. }
  193. else
  194. document.location.reload();