📄 anysale.js
字号:
var make="<button onclick='winClose();');' class='button' onmouseover=this.className='buttonH' onmouseout=this.className='button'>确 定</button>"
var cancel="<button onclick='javascript:breaked=true;winClose();');' class='button' onmouseover=this.className='buttonH' onmouseout=this.className='button'>取 消</button>"
/*标签显示*/
function showTab(num,listID,contentID,more){
var tabList,tab;
tabList = $(listID).getElementsByTagName("ul");
tab = $(contentID).getElementsByTagName("ul");
for(var i=0;i<tabList.length;i++) {
tabList[i].className="tabN";
tabList[i].getElementsByTagName("li")[2].className="tabRL";
tab[i].style.display="none";
}
tabList[num].className="tabH";
tab[num].style.display="block";
if(num==0){num=tabList.length}
tabList[num-1].getElementsByTagName("li")[2].className="tabR";
tabList[tabList.length-1].getElementsByTagName("li")[2].className="tabR";
if(more !=null){$(listID).parentNode.getElementsByTagName("div")[0].getElementsByTagName("ul")[0].getElementsByTagName("li")[1].getElementsByTagName("a")[0].setAttribute("href",more);}
}
/*news*/
function showNews(id){
var showNum
showNum = $("indexNews").getElementsByTagName("h5");
for(i=1;i<showNum.length+1;i++){
document.getElementById("indexNews"+i).className = "newsN";
}
document.getElementById("indexNews"+id).className = "newsH";
}
/*flash*/
function showflash(src, width, height, ID, wmode) {
var contents = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + ID + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' +height +'">';
contents += '<param name="menu" value="false">';
if (typeof(wmode) == "undefined") {
contents += '<param name="wmode" value="transparent">';
} else {
contents += '<param name="wmode" value="' + wmode + '">';
}
contents += '<param name="movie" value="' + src + '">';
contents += '<param name="quality" value="high">';
contents += '<embed src="' + src + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
if (typeof(wmode) == "undefined") {
contents += ' wmode="transparent" ';
} else {
contents += ' wmode="' + wmode + '" ';
}
contents += ' type="application/x-shockwave-flash" width="' + width + '" height="' + height +'"></embed></object>';
document.write(contents);
}
/*minwin*/
function winNew(title,content,ismask,width,height){
$("windows").style.display = "block";
$("windows").innerHTML="";
var mask=document.createElement("div");
mask.setAttribute('id','mask');
mask.style.position="absolute";
mask.style.top="0";
mask.style.left="0";
mask.style.width=document.body.offsetWidth + "px";
mask.style.height=document.body.offsetHeight-14 + "px";
mask.style.zIndex = "10000";
var minWins = document.createElement("div");
minWins.setAttribute("id","minWin");
minWins.style.position = "absolute";
minWins.style.left = "50%";
minWins.style.top = "50%";
minWins.style.marginLeft = -width/2+"px";
minWins.style.marginTop = -width/4+document.documentElement.scrollTop+"px";
minWins.style.width = width + "px";
minWins.style.zIndex = "10001";
var winTitle = document.createElement("ul");
winTitle.className="winTitle";
var winLeft = document.createElement("li");
winLeft.className="winLeft";
var winMid = document.createElement("li");
winMid.innerHTML="<span style='font-weight:bold;color:#ffffff;'>"+title+"</span>";
winMid.className="winMid";
winMid.style.width = width-24 + "px";
var winClose = document.createElement("li");
winClose.className="winClose";
var winCloseA = document.createElement("a");
winCloseA.title = "关闭";
winCloseA.setAttribute("href","javascript:anysale();");
winCloseA.setAttribute("hideFocus","hideFocus")
winCloseA.onclick=function(){$("windows").style.display = "none";$("windows").innerHTML="";}
var winRight = document.createElement("li");
winRight.className="winRight";
var winContent = document.createElement("ul");
winContent.className = "winContent";
winContent.style.width = width-2 + "px";
if(height!=null){winContent.style.height = height+ "px";}
winContent.innerHTML="<li><p>"+content+"</p></li>";
winClose.appendChild(winCloseA);
winTitle.appendChild(winLeft);
winTitle.appendChild(winMid);
winTitle.appendChild(winClose);
winTitle.appendChild(winRight);
minWins.appendChild(winTitle);
minWins.appendChild(winContent);
document.getElementById("windows").appendChild(mask);
document.getElementById("windows").appendChild(minWins);
if(ismask==0){
mask.style.background="#ffffff";
mask.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=0,finishOpacity=10)";
mask.style.opacity="0";
}else{
mask.style.background="#666666";
mask.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=30,finishOpacity=10)";
mask.style.opacity="0.3";
}
}
function winClose(){
$("windows").style.display = "none";
$("windows").innerHTML="";
}
/*check*/
function checkAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.Name != 'chkAll'&&e.disabled==false)
e.checked = form.chkAll.checked;
}
}
function unCheckAll(form){
if( $(form).chkAll.checked ){
$(form).chkAll.checked = $(form).chkAll.checked&0;
}
}
function $(id){return document.getElementById(id);}
function anysale(links){return;}
//验证表单validator
String.prototype.trim = function(){
return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
function isNumber(num){ //数字检查
if( /^[0-9.]+$/.test( num ))
return true;
else return false;
}
function isEmail(email){ //邮件地址检查
return ( /^[^@]+@[^@]+\.[^@]+$/.test(email) && email.length<128 );
}
function isMobile( mobile ){ //手机号码检查
return /^13\d{9}$/.test( mobile ) | /^15\d{9}$/.test( mobile );
}
function showNote(obj,iMsg,status){ //显示提示
if (typeof obj == "string") {
obj = $(obj);
}
var thisul = obj.parentNode.parentNode
if(status==1){
obj.style.color = "#ff0000";
obj.innerHTML = "<span class='iErr'></span>"+iMsg;
thisul.className="hover";
}else{
obj.style.color = "#0e9e26";
obj.innerHTML = "<span class='iSuc'></span>"+iMsg;
thisul.className="";
}
}
//(值,提示ID,名称,为空(0非空,1空),类型(0不限,1数字,2字母,3字母和数字,4字母开头非中文,5邮件,6手机号码),最小长度,最大长度,最小值,最大值)
function check(name,value,note,isnull,type,minL,maxL,minN,maxN){
var oProm = $(note);
if( value == null || value == "" || value.trim() == "" ) { //值为空时
if( isnull==0 ){
showNote(oProm, "请填写"+name,1);
return false;
}else{
return true;
}
}else{ //值不为空
if( type==1 && !isNumber(value) ){ //数字
showNote(oProm,name+"必须为数字",1);
return false;
}else if( type==2 && ! /^[a-zA-Z]+$/.test(value) ){ //字母
showNote(oProm,name+"必须为字母",1);
return false;
}else if( type==3 && ! /^[\w]+$/.test(value) ){ //字母和数字
showNote(oProm,name+"只能由英文字母、数字和下划线(_)组成",1);
return false;
}else if( type==4 && ( ! /^[a-zA-Z].*$/.test(value) || ! /^[\w]+$/.test(value) ) ){ //字母开头非中文
showNote(oProm,name+"只能以字母开头的英文字母、数字和下划线(_)组成",1);
return false;
}else if( type==5){ //多个邮件
var arr=value.split(",");
for (var i=0; i<arr.length; i++) {
if (!isEmail(arr[i])){
showNote(oProm,name+"有误,请重新输入",1);
return false;
}
}
}else if( type==6 && !isMobile(value) ){ //手机号码
showNote(oProm,name+"有误,请重新输入",1);
return false;
}else if( type==7){ //多个用户名
var arr=value.split(",");
for (var i=0; i<arr.length; i++) {
if (! /^[a-zA-Z].*$/.test(arr[i]) || ! /^[\w]+$/.test(arr[i])){
showNote(oProm,name+"有误,请重新输入",1);
return false;
}
}
}
if( minL!=null && maxL!=null && minL==maxL && value.length!=minL ){
showNote(oProm, name+"长度有误,应该为"+minL+"个字符",1);
return false;
}
if( minL!=null && value.length < minL ){ //最小长度
showNote(oProm, name+"长度有误,应该不少于"+minL+"个字符",1);
return false;
}
if( maxL!=null && value.length > maxL ){ //最大长度
showNote(oProm, name+"长度有误,应该不多于"+maxL+"个字符",1);
return false;
}
if( type==1 && minN!=null && value < minN ){ //最小值
showNote(oProm, name+"大小有误,应该不小于"+minN,1);
return false;
}
if( type==1 && maxN!=null && value > maxN ){ //最大值
showNote(oProm, name+"大小有误,应该不大于"+maxN,1);
return false;
}
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -