📄 whtopic.js
字号:
// WebHelp 5.10.003
var gsPPath = "";
var gaPaths = new Array();
var gaAvenues = new Array();
var goFrame = null;
var gsStartPage = "";
var gsRelCurPagePath = "";
var gsSearchFormHref = "";
var gnTopicOnly = -1;
var gnOutmostTopic = -1;
var BTN_TEXT=1;
var BTN_IMG=2;
var goSync = null;
var goShow = null;
var goHide = null;
var goPrev = null;
var goNext = null;
var gnForm = 0;
var goShowNav = null;
var goHideNav = null;
var goWebSearch = null;
var gsBtnStyle = "";
var gaButtons = new Array();
var gaTypes = new Array();
var whtopic_foldUnload = null;
var gbWhTopic=false;
var gbCheckSync=false;
var gbSyncEnabled=false;
function setButtonFont(sType, sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration)
{
var vFont=new whFont(sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration);
gsBtnStyle += ".whtbtn" + sType + "{"+getFontStyle(vFont) + "}";
}
function writeBtnStyle()
{
if (gaButtons.length > 0)
{
if (gsBtnStyle.length > 0)
{
var sStyle = "<style type='text/css'>";
sStyle+= gsBtnStyle + "</style>";
document.write(sStyle);
}
}
}
function button(sText, nWidth, nHeight)
{
this.sText = sText;
this.nWidth = nWidth;
this.nHeight = nHeight;
this.aImgs = new Array();
var i = 0;
while (button.arguments.length > i + 3)
{
this.aImgs[i] = button.arguments[3 + i];
i ++;
}
}
// project info
function setRelStartPage(sPath)
{
if (gsPPath.length == 0)
{
gsPPath = _getFullPath(_getPath(document.location.href), _getPath(sPath));
gsStartPage = _getFullPath(_getPath(document.location.href), sPath);
gsRelCurPagePath = _getRelativeFileName(gsStartPage, document.location.href);
}
}
function getImage(oImage, sType)
{
var sImg="";
if (oImage && oImage.aImgs && (oImage.aImgs.length > 0))
{
sImg+="<img alt=\""+ sType + "\" src=\"" + oImage.aImgs[0] + "\"";
if (oImage.nWidth > 0)
sImg+=" width=" + oImage.nWidth;
if (oImage.nHeight > 0)
sImg+=" height=" + oImage.nHeight;
sImg+=" border=0>";
}
return sImg;
}
function addTocInfo(sTocPath)
{
gaPaths[gaPaths.length] = sTocPath;
}
function addAvenueInfo(sName, sPrev, sNext)
{
gaAvenues[gaAvenues.length] = new avenueInfo(sName, sPrev, sNext);
}
function addButton(sType, nStyle, sText, sHref, sOnClick, sOnMouseOver, sOnLoad, nWidth, nHeight, sImg1, sImg2, sImg3)
{
var sButton = "";
var nBtn=gaButtons.length;
if (sType == "prev")
{
if (canGo(false))
{
var sTitle = "上一主题";
goPrev = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnprev\" href=\"javascript:void(0);\" onclick=\"goAvenue(false);return false;\">";
if (nStyle == BTN_TEXT)
sButton += goPrev.sText;
else
sButton += getImage(goPrev, sTitle);
sButton += "</a>";
}
}
else if (sType == "next")
{
if (canGo(true))
{
var sTitle = "下一主题";
goNext = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnnext\" href=\"javascript:void(0);\" onclick=\"goAvenue(true);return false;\">";
if (nStyle == BTN_TEXT)
sButton += goNext.sText;
else
sButton += getImage(goNext, sTitle);
sButton += "</a>";
}
}
else if (sType == "show")
{
if (isTopicOnly())
{
var sTitle = "显示导航组件";
goShow = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnshow\" href=\"javascript:void(0);\" onclick=\"show();return false;\">";
if (nStyle == BTN_TEXT)
sButton += goShow.sText;
else
sButton += getImage(goShow, sTitle);
sButton += "</a>";
}
}
else if (sType == "hide")
{
if (!isTopicOnly())
{
var sTitle = "隐藏导航组件";
goHide = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnhide\" href=\"javascript:void(0);\" onclick=\"hide();return false;\">";
if (nStyle == BTN_TEXT)
sButton += goHide.sText;
else
sButton += getImage(goHide, sTitle);
sButton += "</a>";
}
}
else if (sType == "shownav")
{
if (isShowHideEnable())
{
var sTitle = "显示导航组件";
goShowNav = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnshownav\" href=\"javascript:void(0);\" onclick=\"showHidePane(true);return false;\">";
if (nStyle == BTN_TEXT)
sButton += goShowNav.sText;
else
sButton += getImage(goShowNav, sTitle);
sButton += "</a>";
}
}
else if (sType == "hidenav")
{
if (isShowHideEnable())
{
var sTitle = "隐藏导航组件";
goHideNav = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\"" + sTitle + "\" class=\"whtbtnhidenav\" href=\"javascript:void(0);\" onclick=\"showHidePane(false);return false;\">";
if (nStyle == BTN_TEXT)
sButton += goHideNav.sText;
else
sButton += getImage(goHideNav, sTitle);
sButton += "</a>";
}
}
else if (sType == "synctoc")
{
if (gaPaths.length > 0)
{
var sTitle = "同步主题";
goSync = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\""+ sTitle + "\" class=\"whtbtnsynctoc\" href=\"javascript:void(0);\" onclick=\"syncWithShow();return false;\">";
if (nStyle == BTN_TEXT)
sButton += goSync.sText;
else
sButton += getImage(goSync, sTitle);
sButton += "</a>";
}
}
else if (sType == "websearch")
{
if (gsSearchFormHref.length > 0)
{
var sTitle = "WebSearch";
goWebSearch = new button(sText, nWidth, nHeight, sImg1, sImg2, sImg3);
sButton = "<a title=\""+ sTitle + "\" class=\"whtbtnwebsearch\" href=\"" + gsSearchFormHref + "\">";
if (nStyle == BTN_TEXT)
sButton += goWebSearch.sText;
else
sButton += getImage(goWebSearch, sTitle);
sButton += "</a>";
}
}
else if (sType == "searchform")
{
gaButtons[nBtn] = "NeedSearchForm";
gaTypes[nBtn] = sType;
}
if (sButton.length != 0)
{
if (nStyle == BTN_TEXT)
sButton += " ";
gaButtons[nBtn] = "<td>" + sButton + "</td>";
gaTypes[nBtn] = sType;
}
}
function isSyncEnabled()
{
if (!gbCheckSync)
{
var oMsg=new whMessage(WH_MSG_ISSYNCSSUPPORT,this,1,null);
if(SendMessage(oMsg))
{
gbSyncEnabled=oMsg.oParam;
}
gbCheckSync=true;
}
return gbSyncEnabled;
}
function isInPopup()
{
return (window.name.indexOf("BSSCPopup") != -1);
}
function getIntopicBar(sAlign)
{
var sHTML = "";
if (gaButtons.length > 0)
{
sHTML += "<div align="+ sAlign + ">";
sHTML += "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\"><tr>";
for (var i = 0; i < gaButtons.length; i++)
{
if (gaTypes[i]!="synctoc" || isSyncEnabled())
{
if (gaButtons[i] == "NeedSearchForm")
sHTML += getSearchFormHTML();
else
sHTML += gaButtons[i];
}
}
sHTML += "</tr></table>";
sHTML += "</div>";
}
return sHTML;
}
function writeIntopicBar(nAligns)
{
if (isInPopup()) return;
if (gaButtons.length > 0)
{
var sHTML = "";
if (nAligns != 0)
{
sHTML += "<table width=100%><tr>"
if (nAligns & 1)
sHTML += "<td width=33%>" + getIntopicBar("left") + "</td>";
if (nAligns & 2)
sHTML += "<td width=34%>" + getIntopicBar("center") + "</td>";
if (nAligns & 4)
sHTML += "<td width=33%>" + getIntopicBar("right") + "</td>";
sHTML += "</tr></table>";
document.write(sHTML);
}
}
}
function sendAveInfoOut()
{
if (!isInPopup())
setTimeout("sendAveInfo();", 100);
}
function sendAveInfo()
{
var oMsg = new whMessage(WH_MSG_AVENUEINFO, this, 1, gaAvenues);
SendMessage(oMsg);
}
function onNext()
{
var oMsg = new whMessage(WH_MSG_NEXT, this, 1, null);
SendMessage(oMsg);
}
function onPrev()
{
var oMsg = new whMessage(WH_MSG_PREV, this, 1, null);
SendMessage(oMsg);
}
function createSyncInfo()
{
var oParam = new Object();
if (gsPPath.length == 0)
gsPPath = _getPath(document.location.href);
oParam.sPPath = gsPPath;
oParam.sTPath = document.location.href;
oParam.aPaths = gaPaths;
return oParam;
}
function syncWithShow()
{
if (isTopicOnly())
show();
else
{
sync();
showTocPane();
}
}
function showTocPane()
{
var oMsg = new whMessage(WH_MSG_SHOWTOC, this, 1, null);
SendMessage(oMsg);
}
function sendSyncInfo()
{
if (!isInPopup())
{
var oParam = null;
if (gaPaths.length > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -