📄 global.js
字号:
Array.prototype.remove = function(dx) {
if(isNaN(dx) || dx>this.length){return false;}
this.splice(dx,1);
}
String.prototype.replaceAll = stringReplaceAll;
function stringReplaceAll(AFindText,ARepText){
var raRegExp = new RegExp(AFindText.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g,"\\$1"),"ig");
return this.replace(raRegExp,ARepText);
}
var dwsSearch = {
hoverBtn : function(o,s){
dwsElement.addClassName(o,s);
o.onmouseout = function(){
dwsElement.delClassName(this,s);
}
},
doInput : function(o){
if (o.value==o.defaultValue) {
o.value="";
}
o.onblur = function(){
o.value==""?o.value=o.defaultValue:"";
}
}
}
var dwsElement={
addClassName: function(element, className) {
if (!(element = $(element))) return;
dwsElement.delClassName(element, className);
element.className=element.className+" "+className;
},
delClassName: function(element, className) {
if (!(element = $(element))) return;
var arrClssOld=element.className.replaceAll(" "," ");
arrClssOld=arrClssOld.split(" ");
for (var i=arrClssOld.length-1;i>=0;i--){
if (className==arrClssOld[i]){
arrClssOld.remove(i);
}
}
element.className=arrClssOld.join(" ");
},
isChild : function(cNode,pNode){
while(cNode!=null){
cNode=cNode.parentNode;
if(cNode==pNode) return true;
}
return false;
},
getChild : function(oChild,oParent){
oParent.appendChild(oChild);
},
rePos : function(obj,nLt,nTop){
var o=$(obj);
o.style.left = nLt + "px";
o.style.top = nTop + "px";
},
getXYWH : function(o){
var nLt=0;
var nTp=0;
var offsetParent = o;
while (offsetParent!=null && offsetParent!=document.body) {
nLt+=offsetParent.offsetLeft;
nTp+=offsetParent.offsetTop;
if(dwsBrowser.isIE){
parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
}
offsetParent=offsetParent.offsetParent;
}
return {"X":nLt, "Y":nTp, "W":o.offsetWidth, "H":o.offsetHeight}
}
}
function $(element) {
return document.getElementById(element)?document.getElementById(element):element;
}
$Cls = document.getElementsByClassName ;
var dwsTAB = {
idSuffix : "_Tabs",
tabTagName : "li",
activeClassName : "active",
waitInterval : null,
delayTime : 30,
tempTAB : null
}
dwsTAB.init = function(){
for(var i=0;i<arguments.length;i++) {
var oTabBox=document.getElementById(arguments[i]+dwsTAB.idSuffix);
if(!oTabBox)continue;
var arrTabs=oTabBox.getElementsByTagName(dwsTAB.tabTagName);
var oCurrTAB=null;
for(var j=0;j<arrTabs.length;j++) {
oCurrTAB=arrTabs[j];
if(oCurrTAB.parentNode!=oTabBox) continue;
var oTabLink=oCurrTAB.getElementsByTagName("a")[0];
if(!oTabLink.innerHTML){
dwsElement.addClassName($(oCurrTAB),"hidden");
if(oTabLink.getAttribute("rel")=="#default"){
$(oTabLink).setAttribute("rel", "#normal");
$(arrTabs[j+1].getElementsByTagName("a")[0]).setAttribute("rel", "#default");
}
}
var sDataStaut=oTabLink.getAttribute("rel");
oCurrTAB.setActive=function(bactive){
var oDataId = this.getElementsByTagName("a")[0].getAttribute("urn");
if(bactive){
this.status="active";
dwsElement.addClassName(this,dwsTAB.activeClassName);
dwsElement.delClassName($(oDataId),"hidden");
}else{
this.status="normal";
dwsElement.delClassName(this,dwsTAB.activeClassName);
dwsElement.addClassName($(oDataId),"hidden");
}
}
oCurrTAB.getTabData=function(){
this.setActive(true);
this.parentNode.activetab.setActive(false);
this.parentNode.activetab=this;
var oTabLink=this.getElementsByTagName("a")[0];
}
oCurrTAB.onmouseover=function(aEvent){
var myEvent = window.event ? window.event : aEvent;
var fm=myEvent.fromElement;
if(dwsElement.isChild(fm,this) || fm==this) return;
if(this.status=="active") return;
dwsTAB.tempTAB=this;
clearTimeout(dwsTAB.waitInterval);
dwsTAB.waitInterval=window.setTimeout("dwsTAB.tempTAB.getTabData();",dwsTAB.delayTime);
}
oCurrTAB.onmouseout=function(aEvent){
var myEvent = window.event ? window.event : aEvent;
var em=myEvent.toElement;
if(dwsElement.isChild(em,this) || em==this) return;
if(this.status=="active") return;
clearTimeout(dwsTAB.waitInterval);
}
if(sDataStaut.indexOf("#default")!=-1){
oCurrTAB.setActive(true);
oTabBox.activetab=oCurrTAB;
} else {
oCurrTAB.setActive(false);
}
}
if(oTabBox.activetab==null) oTabBox.activetab=arrTabs[0];
}
}
// --- 设置cookie
function SkinsetCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
//--- 获取cookie
function SkingetCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function shiftSkin(cssfile) {
css = document.createElement("link");
css.id= 'skin_styles';
css.type = 'text/css';
css.rel = 'stylesheet';
css.href = cssfile+ '.css';
var headNode = document.getElementsByTagName("head")[0];
headNode.appendChild(css);
SkinsetCookie("skin_styles_id",cssfile,30);
}
function skincss(cssfile){
if(SkingetCookie("skin_styles_id")!=null){
shiftSkin(SkingetCookie("skin_styles_id"));
}else{
shiftSkin(cssfile);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -