⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commoncheck.js

📁 仿53KF免费客服系统,一般用于网站的访客问答
💻 JS
📖 第 1 页 / 共 2 页
字号:
// ZDSOFT.NET JavaScript Base Ver 040910

var ActRd;
var ActRs=new Array();
function Act(obj,str){eval(obj.type+'.'+str+'(obj)')}
function LoadClass(name){eval(name+'=new '+name+'()')}

function GetIndex(obj)
{
	for(var i=0; i < obj.form.elements.length; i++)
	  if ( obj.form.elements[i].uniqueID == obj.uniqueID) return(i);
	return(-1);
}

function GetOffset(obj)
{
	var x=0,y=0;
	if(!obj) return [x,y];
	while(obj){
		x+=parseInt(obj.offsetLeft);
		y+=parseInt(obj.offsetTop);
		obj=obj.offsetParent;
	}
	return [x,y];
}

function Cookie()
{
    this._Cookie=[];
    
    this.Load=function(){
        if(document.cookie.indexOf(";")!=-1){
            var _sp,_name,_tp,_tars,_tarslength;
            var _item=document.cookie.split("; ");
            var _itemlength=_item.length;
            while(_itemlength>0){
                _sp=_item[--_itemlength].split("=");
                _name=_sp[0];
				if (_sp.length <2 )
				{
					continue;
				}
                _tp=_sp[1].split(",");
                _tars=_tp.slice(1,_tp.length);
                this._Cookie[_name]=[];
                this._Cookie[_name]=_tars;
                this._Cookie[_name]["timeout"]=_tp[0];
                }
            return true;
            }
        return false;
        }
        
    this.Save=function(){
        var _str,_ars,_mars,_marslength,timeout,i,key;
        for(key in this._Cookie){
            if(!this._Cookie[key])return;
            _str=[];
            _mars=this._Cookie[key];
            _marslength=_mars.length;
            for(i=0;i<_marslength;i++)_str[_str.length]=escape(_mars[i]);
            document.cookie=key+"="+_mars["timeout"]+(_str.length>0?",":"")+_str+(_mars["timeout"]==0?"":";expires="+new Date(parseInt(_mars["timeout"])).toGMTString());
            }        
        }
        
    this.Create=function(name,days){
        days=days?days:0;
        if(!this._Cookie[name])this._Cookie[name]=[];
        this._Cookie[name]["timeout"]=days!=0?new Date().getTime()+parseInt(days)*86400000:0;
        }    
        
    this.Modify=function(name,days){
        this.Create(name,days);
        }
        
    this.Delete=function(name){
        this.Create(name,0);
        }     
        
    this.AddItem=function(name,value){
        this._Cookie[name][this._Cookie[name].length]=value;
        }
        
    this.DelItem=function(name,index){
        var _ttime=this._Cookie[name]["timeout"];
        this._Cookie[name]=this._Cookie[name].slice(0,index).concat(this._Cookie[name].slice(parseInt(index)+1,this._Cookie[name].length));
        this._Cookie[name]["timeout"]=_ttime;
        }

    this.GetItem=function(name,index){
        return this._Cookie[name][index];
        }

    this.GetTime=function(name){
        return new Date(parseInt(this._Cookie[name]["timeout"]));
        }

    this.GetCount=function(name){
        return this._Cookie[name].length;
        }

    this.GetCookieCount=function(){
        var _length=0,key;
        for(key in this._Cookie)_length++;
        return _length;
        }
        
	this.SetCookie=function(name,value){
		var today = new Date()
		var expires = new Date()
		expires.setTime(today.getTime() + 1000*60*60*24*365)
		document.cookie = name + "=" + escape(value)	+ "; expires=" + expires.toGMTString()
	}
	
	this.GetCookie=function(Name){
		var search = Name + "="
		if(document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if(offset != -1) {
				offset += search.length
				end = document.cookie.indexOf(";", offset)
				if(end == -1) end = document.cookie.length
				return unescape(document.cookie.substring(offset, end))
			}	
		}
		return ""
	}
}	

Number.prototype.Fix = function()
{
	return numFix(this)
}

Number.prototype.Int = function()
{
	return numInt(this)
}

Array.prototype.Clear = function()
{
	this.length=0;
}

Array.prototype.Max = function()
{
	var i, max = this[0];
	for (i = 1; i < this.length; i++)
		if (max < this[i]) max = this[i];
	return max;
}

Array.prototype.Min = function()
{
	var i, min = this[0];
	for (i = 1; i < this.length; i++)
		if (min > this[i]) min = this[i];
	return min;
}

Array.prototype.Sum = function()
{
	var i, sum = 0;
	for (i = 0; i < this.length; i++)
		sum+=this[i]
	return sum;
}

Array.prototype.Left=function(length){
    return this.slice(0,length);
    }

Array.prototype.Mid=function(start,length){
    return this.slice(start,start+length);
    }

Array.prototype.Right=function(length){
    if(length>=this.length) return this;
    return this.slice(this.length-length,this.length);
    }


String.prototype.IsDate = function()
{
	var myReg = /^(\d{4})(-|\/|.)(\d{1,2})\2(\d{1,2})$/; 
	var result=this.match(myReg);
    if(result==null) return false;
	var test= new Date(result[1],result[3]-1,result[4]);
	if ((test.getFullYear()==result[1]) && (test.getMonth()+1==result[3]) && (test.getDate()==result[4])){
		ActRs.Clear();
		ActRs[0]=result[1];ActRs[1]=result[3];ActRs[2]=result[4];
		return true;
	}
	else return false;
}

String.prototype.IsTime = function()
{
	var myReg = /^(\d{1,2})(:)(\d{1,2})\2(\d{1,2})$/; 
	var result=this.match(myReg);
    if(result==null) return false;
	var test= new Date(2000,1,1,result[1],result[3],result[4]);
	if ((test.getHours()==result[1]) && (test.getMinutes()==result[3]) && (test.getSeconds()==result[4])){
		ActRs[3]=result[1];ActRs[4]=result[3];ActRs[5]=result[4];
		return true;
	}
	else return false;
}

String.prototype.IsDateTime = function()
{
	var myReg = this.split(" ");
	if(myReg.length!=2) return false;
	if(myReg[0].IsDate() && myReg[1].IsTime()) return true;
	return false;
}

String.prototype.IsEmail = function()
{
	var myReg = /[\u4e00-\u9fa5]/;
	if(!myReg.test(this)){
		myReg = /^[_a-zA-Z0-9][-._a-zA-Z0-9]*@[-_a-zA-Z0-9]+\.[-._a-zA-Z0-9]+(\.[-._a-zA-Z])*$/;
		if (myReg.test(this)) return true;
	}else{
		myReg = /^[_a-zA-Z0-9\u4e00-\u9fa5][-_.a-zA-Z0-9\u4e00-\u9fa5]*@[-._a-zA-Z0-9\u4e00-\u9fa5]+(\.[-._0-9a-zA-Z\u4e00-\u9fa5]+)*$/;
		if (myReg.test(this)) return true;
	}
	return false;
}

String.prototype.IsIdcard = function()
{
    var myReg = /^[1-9][0-9]{14}$|^[1-9][0-9]{16}[0-9a-zA-Z]$/;
	if(myReg.test(this)) return true;
    return false;
}

String.prototype.IsTelephone = function()
{
	myReg = /[(]/;
	if (!myReg.test(this))
	{
		myReg = /^[1-9][0-9]{6,7}$|^[0-9]{3,4}-[1-9][0-9]{6,7}$|^[0-9]{3,4}-[1-9][0-9]{6,7}-[0-9]{2,8}$/;
		if (myReg.test(this)) return true;
	}
	//else {
		//myReg = /^[1-9][0-9]{6,7}$|^([0-9]{3,4})[1-9][0-9]{6,7}$|^([0-9]{3,4})[1-9][0-9]{6,7}-[0-9]{2,8}$/;
		//if (myReg.test(this)) return true;
	//}
	return false;
}

String.prototype.IsNumber = function()
{
	var myReg = /^[0-9]+$/;
	if(!myReg.test(this)) return false;
	ActRd=parseInt(this)	
	return true;
}

String.prototype.IsFloat = function()
{
	var myReg = /^[0-9.]+$/;
	if(!myReg.test(this)) return false;
	var pos=this.indexOf('.')
	if(pos==-1) return false;
	if(pos!=this.lastIndexOf('.')) return false;
	if(pos==0 || (pos+1)==this.length) return false;
	ActRd=parseFloat(this)
	return true;
}

String.prototype.IsPhone = function()
{
	if(!this.IsNumber()) return false;
	if(this.length != 11 || this<13000000000 || this>13999999999) return false;
	return true;
}

String.prototype.IsDomain = function()
{
    var myReg = /^[0-9a-zA-Z\-]+$/;
    if(myReg.test(this)) return true;
    return false;
}

String.prototype.IsAvail = function()
{
	var myReg = /^[0-9a-zA-Z]+$/;
	if(myReg.test(this)) return true;
	return false;
}

String.prototype.IsEn = function()
{
    var myReg = /^[a-zA-Z]+$/;
    if(myReg.test(this)) return true;
    return false;
}

String.prototype.ConvertHtml = function()
{
	var tmp = this.replace(/\&/g, "&amp;");
    tmp = tmp.replace(/\"/g, "&quot;");
	tmp = tmp.replace(/ /g, "&nbsp;");
    tmp = tmp.replace(/</g, "&lt;");
    //tmp = tmp.replace(/\'/g, "&apos;");
    tmp = tmp.replace(/>/g, "&gt;");
    return tmp;
}

String.prototype.ConvertHtmlWithN = function()
{
	var tmp = this.replace(/\&/g, "&amp;");
    tmp = tmp.replace(/\"/g, "&quot;");
	tmp = tmp.replace(/ /g, "&nbsp;");
    tmp = tmp.replace(/</g, "&lt;");
    tmp = tmp.replace(/>/g, "&gt;");
    //tmp = tmp.replace(/\'/g, "&apos;");
    tmp = tmp.replace(/\r\n/g, "<br>");
    return tmp;
}

String.prototype.ConvertHtmlWithP = function()
{
	var tmp = this.replace(/\&/g, "&amp;");
    tmp = tmp.replace(/\"/g, "&quot;");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -