📄 whutils.js
字号:
return false;
}
return true;
}
function insertWhenBodyReady()
{
if(gsInsertBeforeEndHTML=="") return;
if(document.body)
{
document.body.insertAdjacentHTML("beforeEnd",gsInsertBeforeEndHTML);
gsInsertBeforeEndHTML="";
loadData_2(gsFileName,gsDivName);
}
else
{
setTimeout("insertWhenBodyReady();",100);
}
}
function window_BUnload()
{
for(var i=0;i<gnLoadDivNum;i++)
{
var oDivCon=getElement(gsDivName+i);
if(oDivCon)
oDivCon.innerHTML="";
}
}
function removeThis(obj)
{
if(obj.parentNode)
obj.parentNode.removeChild(obj);
else
obj.outerHTML="";
}
function getParentNode(obj)
{
if(obj.parentNode)
return obj.parentNode;
else if(obj.parentElement)
return obj.parentElement;
return null;
}
function getElement(sID)
{
if(document.getElementById)
return document.getElementById(sID);
else if(document.all)
return document.all(sID);
return null;
}
function getChildrenByTag(obj,sTagName)
{
if(obj.getElementsByTagName)
{
var aChildren=new Array();
var aElements=getElementsByTag(obj,sTagName);
if(aElements!=null)
{
for(var i=0;i<aElements.length;i++)
{
if(aElements[i].parentNode==obj)
aChildren[aChildren.length]=aElements[i];
}
return aChildren;
}
else
return new Array();
}
else if(obj.children)
return obj.children.tags(sTagName);
}
function getElementsByTag(obj,sTagName)
{
if(obj.getElementsByTagName)
return obj.getElementsByTagName(sTagName);
else if(obj.all)
return obj.all.tags(sTagName);
return null;
}
function _htmlToText(sHTML)
{
if(sHTML==null) return null;
var sText=sHTML;
for(var i=0;i<sReplaceStringsSrc.length;i++)
{
var re=new RegExp(sReplaceStringsSrc[i],"g");
sText=sText.replace(re,sReplaceStringsDst[i]);
}
return sText;
}
function _textToHtml_nonbsp(sText)
{
if(sText==null) return null;
var sHTML=sText;
for(var i=0;i<sReplaceStringsSrc.length-1;i++)
{
var re=new RegExp(sReplaceStringsDst[i],"g");
sHTML=sHTML.replace(re,sReplaceStringsSrc[i]);
}
return sHTML;
}
function _textToHtml(sText)
{
if(sText==null) return null;
var sHTML=sText;
for(var i=0;i<sReplaceStringsSrc.length;i++)
{
var re=new RegExp(sReplaceStringsDst[i],"g");
sHTML=sHTML.replace(re,sReplaceStringsSrc[i]);
}
return sHTML;
}
function getInnerText(obj)
{
var renbsp2sp=new RegExp("\xa0","g");
if(obj.innerText)
{
var sText=obj.innerText;
sText=sText.replace(renbsp2sp," ");
return sText;
}
else
{
if(obj.nodeValue)
{
var sValue=obj.nodeValue;
sValue=sValue.replace(renbsp2sp," ");
return sValue;
}
else
{
var sText="";
var oChild=obj.firstChild;
while(oChild!=null)
{
sText+=getInnerText(oChild);
oChild=oChild.nextSibling;
}
return sText;
}
}
}
function HighLightElement(obj,sHighLightColor,sNormalColor)
{
if(obj!=null)
{
resetHighLight(sNormalColor);
if (obj.style)
obj.style.backgroundColor=sHighLightColor;
goHighLighted=obj;
}
}
function resetHighLight(sNormalColor)
{
if(goHighLighted!=null)
{
if (goHighLighted.style)
goHighLighted.style.backgroundColor=sNormalColor;
goHighLighted=null;
}
}
function whFont(sName,sSize,sColor,sStyle,sWeight,sDecoration)
{
this.sName=sName;
this.sSize=sSize;
this.sColor=sColor;
this.sStyle=sStyle;
this.sWeight=sWeight;
this.sDecoration=sDecoration;
}
function getFontStyle(oFont)
{
var sStyle="";
if(oFont)
{
sStyle+="font-family:"+oFont.sName+";";
sStyle+="font-size:"+oFont.sSize+";";
sStyle+="font-style:"+oFont.sStyle+";";
sStyle+="font-weight:"+oFont.sWeight+";";
sStyle+="text-decoration:"+oFont.sDecoration+";";
sStyle+="color:"+oFont.sColor+";";
}
return sStyle;
}
function _browserStringToText(sBStr)
{
var sText="";
// change %xxx back to the real char.
var nPos=sBStr.indexOf('%');
while(nPos!=-1)
{
sText+=sBStr.substring(0,nPos);
sBStr=sBStr.substring(nPos+1);
var sNum="";
var i=0;
while(sBStr.charAt(i)>='0'&&sBStr.charAt(i)<='9')
{
sNum+=sBStr.charAt(i++);
}
if(sNum!=""){
var nNum=parseInt(sNum,16);
sText+=String.fromCharCode(nNum);
sBStr=sBStr.substring(i);
}
nPos=sBStr.indexOf('%');
}
sText+=sBStr;
return sText;
}
function IsInternal(urlName)
{
if(urlName.indexOf(":") == -1 && urlName.indexOf(":")== -1 && urlName.indexOf("//") != 0 &&
urlName.indexOf("//") != 0 && urlName.indexOf("//") != 0 && urlName.indexOf("//") != 0)
return true;
else
return false;
}
function IsNonAscii(szWord)
{
var temp;
for(var iCount=0; iCount<szWord.length;iCount++)
{
temp = szWord.charCodeAt(iCount);
if(temp>128)
return true;
}
return false;
}
function excapeSingleQuotandSlash(str)
{
if(str==null) return null;
var nPos=0;
var sRes="";
var nPosNew=str.indexOf("\\",nPos);
while(nPosNew!=-1){
sRes+=str.substring(nPos,nPosNew+1)+"\\";
nPos=nPosNew+1;
nPosNew=str.indexOf("\\",nPos);
}
if(nPos<str.length)
sRes+=str.substring(nPos);
var re=new RegExp("'","g");
sRes=sRes.replace(re,"\\'");
return sRes;
}
// used by roboengine
function mrGetRootWindow()
{
var cWnd=window;
while(cWnd!=null)
{
if( cWnd.cMRServer!=null && String(cWnd.cMRServer)!='undefined' )
{
return cWnd;
};
cWnd=cWnd.parent;
};
return null;
};
function mrGetProjName()
{
var cRoot=mrGetRootWindow();
if( cRoot==null ) return '';
var sTags=unescape(cRoot.location.search);
if( sTags=='' )
sTags=unescape(cRoot.location.hash);
var nStart, nEnd1, nEnd2;
var sName='';
if( (nStart=sTags.indexOf('prj='))>=0 )
{
if( (nEnd=sTags.indexOf('&', nStart))<0 ) nEnd=sTags.length;
if( (nEnd1=sTags.indexOf('>', nStart))<0 ) nEnd1=sTags.length;
if( nEnd>nEnd1 ) nEnd=nEnd1;
sName=sTags.substring(nStart+4, nEnd);
};
return sName;
};
function mrInitialize()
{
var sProjName=mrGetProjName();
var cRoot=mrGetRootWindow();
if( sProjName!='' && cRoot!=null )
{
cRoot.cMRServer.m_bEngine=true;
cRoot.cMRServer.m_sProjName=sProjName;
};
};
function mrIsOnEngine()
{
var cRoot=mrGetRootWindow();
return cRoot && cRoot.cMRServer && cRoot.cMRServer.m_bEngine==true;
};
function mrGetEngineUrl()
{
return c_sEnginePath;
};
function getClientHeight()
{
if(gbSafari3)
{
return innerHeight; //this is for safari
}
return document.body.clientHeight;
}
function PatchParametersForEscapeChar(sParam)
{
var sresult = sParam;
if(gbSafari)
{
sresult = sresult.replace(/%3c/gi,"<");
sresult = sresult.replace(/%3e/gi,">");
}
return sresult;
}
function SeeForSearch(strProjectDir)
{
if(gbAIRSSL && gbSearchPage)
{
loadFts_context(strProjectDir);
goOdinHunter.strQuery = GetSearchTextFromURL();
Query();
}
}
var RH_BreadCrumbDataStringVariable="";
function RH_Document_Write(szText)
{
RH_BreadCrumbDataStringVariable+=szText;
}
function RH_AddMasterBreadcrumbs(styleInfo, separator, strHome, strHomePath)
{
var strTrail = "<a style=\""+ styleInfo + "\"" + " href=\"" + strHomePath + "\">" + strHome + "</a> " + separator + " ";
RH_Document_Write(strTrail);
return;
}
var gbWhUtil=true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -