/* kesioncms通用脚本函数,最后更新于2014-7-7 */ var installdir='/'; //系统安装目录,请正确填写。如安装在kesion目录下,请设为 installdir='/kesion/' document.write(''); function showlogin(){ $.dialog.open(installdir+"user/userlogin.asp?action=poplogin",{title:"会员登录",width:420,height:200,max:false,min:false}); } //容错脚本 resumeerror=function (){return true;} window.onerror = resumeerror; function ismobile(s) { var p = /^(013|015|13|15|018|18)\d{9}$/; if(s.match(p) != null){ return true; } return false; } //===========================================发送手机验证码_begin============================================== var touttimes; var tempouttimes function leavepage(btnid) { if (touttimes==0){ touttimes=tempouttimes; $("#"+btnid).attr("disabled",false); $("#"+btnid).val("免费获取手机验证码") } else{ touttimes -= 1; $("#"+btnid).val("已发,如果"+touttimes+"秒后没有收到,可以重发!") settimeout("leavepage('"+btnid+"')", 1000);} } //获取手机短信验证码 参数:重发时间(秒),模型id,手机号输入框id,获取按钮id,用户名 function getmobilecode(outtimes,modelid,mobileid,btnid,username){ if (username==undefined) username=''; touttimes=outtimes; tempouttimes=outtimes; var mobile=$("#"+mobileid).val(); if (mobile==''){ alert('请选输入手机号码!'); $("#"+mobileid).focus(); return false; } if (ismobile(mobile)==false){ alert('手机号码格式不正确,请重新输入!'); $("#"+mobileid).focus(); return false; } $("#"+btnid).attr("disabled",true); $.ajax({type:"get",async:false,url:installdir+"plus/ajaxs.asp?istest=0&action=getmobilecode&username="+username+"&modelid="+modelid+"&mobile="+mobile+"&anticache=" + math.floor(math.random()*1000),cache:false,datatype:"html",success:function(d){ if (d=='true'){ leavepage(btnid); }else{ alert(d); $("#"+btnid).attr("disabled",false); } }}); return false; } //===========================================发送手机验证码_end============================================== //检查是否中文字符 is_zw=function(str){ exp=/[0-9a-za-z_.,#@!$%^&*()-+=|\?/<>]/g; if(str.search(exp) != -1){return false;} return true; } //验证是否包含逗号 checkbadchar=function (obj,alertstr) { exp=/[,,]/g; if(obj.value.search(exp) != -1) { alert(alertstr+"不能包含逗号"); obj.value=""; obj.focus(); return false; } return true; } // 检查是否有效的扩展名 isext=function(filename, allowext){ var stemp; var s=allowext.touppercase().split("|"); for (var i=0;i=255||charascii<=31) { errorstr=errorstr+tempstr.charat(i); } else { if (!checkerrorstr(charascii)) { errorstr=errorstr+tempstr.charat(i); } } } if (errorstr!='') { alert("出错信息:\n\n"+descriptionstr+'发现非法字符:'+errorstr); obj.focus(); return false; } if (!(((tempstr.charcodeat(0)>=48)&&(tempstr.charcodeat(0)<=57))||((tempstr.charcodeat(0)>=65)&&(tempstr.charcodeat(0)<=90))||((tempstr.charcodeat(0)>=97)&&(tempstr.charcodeat(0)<=122)))) { alert(descriptionstr+'首字符只能够为数字或者字母'); obj.focus(); return false; } } return true; } function checkerrorstr(charasciicode) { var temparray=new array(34,47,92,42,58,60,62,63,124); for (var i=0;i
'); }else{ inserthtmltoeditorbyid(editorid,'
'); } }else if (fileext=="flv"||fileext=="mp4" || fileext=="f4v" || fileext=="wmv" || fileext=="swf" || fileext=="rm" || fileext=="rmvb"){ inserthtmltoeditor('[media='+fileext+',500,450,1]'+filelist+'[/media]'); }else{ var str="
[uploadfiles]"+maxid+","+filesize+","+fileext+","+title+"[/uploadfiles]
"; if (editorid==''||editorid==undefined){ inserthtmltoeditor(str); }else{ inserthtmltoeditorbyid(editorid,str); } } } function inserthtmltoeditorbyid(editorid,codestr) {eval(editorid+".execcommand('inserthtml', '"+codestr+"');") } //选择附件 var box=''; function popinsertannex(upfrom){ box=top.$.dialog.open('../plus/selectannex.asp?upfrom='+upfrom,{title:'选择附件插入',width:690,height:400}); } function getcolor(obj,url){ box=top.$.dialog.open(url,{id:'colorbox',follow:$('#'+obj)[0],title:false,width:225,height:148,min:false,max:false,padding:0}); } function openimgcutwindow(deloriginphoto,installdir,photourl){ openimgcutwindows(deloriginphoto,installdir,photourl,$('#photourl')[0]); } function openimgcutwindows(deloriginphoto,installdir,photourl,obj){ openthensetvalue(installdir+'plus/imgcut.asp?del='+deloriginphoto+'&photourl='+photourl,680,380,window,obj); } //网站验证码,调用 writeverifycode(安装目录,显示tips,cssname); if (typeof codenum == 'undefined'){ var codenum = 1;}else{codenum++;} function writeverifycode(dir,tips,cssname){ codenum++; if (dir==undefined) dir='/';if (tips==undefined) tips=0;if (cssname==undefined) cssname='textbox'; document.write(''); if (tips==1) document.write(' 请输入上图中字符 '); } var seccodefocus = 0; function showverifycode(id) { var obj=document.getelementbyid("codebox"+id); obj.style.top = (-parseint(obj.style.height) - 4) + 'px'; obj.style.left = '0px'; obj.style.display = ''; var pos=getelementpos("codebox"+id); if (pos.y<0) obj.style.top=parseint(obj.style.height)-20+"px"; document.getelementbyid('vcodeimg'+id).src =document.getelementbyid('vcodeimg'+id).src.split('?')[0]+'?time=' + math.random(); try{$("#codebox"+id).fadeout('fast').fadein('fast');}catch(e){} } function getelementpos(elementid) { var ua = navigator.useragent.tolowercase(); var isopera = (ua.indexof('opera') != -1); var isie = (ua.indexof('msie') != -1 && !isopera); // not opera spoof var el = document.getelementbyid(elementid); if(el.parentnode === null || el.style.display == 'none') { return false; } var parent = null;var pos = []; var box; if(el.getboundingclientrect) //ie { box = el.getboundingclientrect();var scrolltop = math.max(document.documentelement.scrolltop, document.body.scrolltop); var scrollleft = math.max(document.documentelement.scrollleft, document.body.scrollleft);return {x:box.left + scrollleft, y:box.top + scrolltop};}else if(document.getboxobjectfor) // gecko {box = document.getboxobjectfor(el); var borderleft = (el.style.borderleftwidth)?parseint(el.style.borderleftwidth):0; var bordertop = (el.style.bordertopwidth)?parseint(el.style.bordertopwidth):0; pos = [box.x - borderleft, box.y - bordertop];} else // safari & opera {pos = [el.offsetleft, el.offsettop]; parent = el.offsetparent; if (parent != el) {while (parent) {pos[0] += parent.offsetleft; pos[1] += parent.offsettop; parent = parent.offsetparent;}} if (ua.indexof('opera') != -1 || ( ua.indexof('safari') != -1 && el.style.position == 'absolute' )) { pos[0] -= document.body.offsetleft;pos[1] -= document.body.offsettop;}} if (el.parentnode) {parent = el.parentnode;} else {parent = null;} while (parent && parent.tagname != 'body' && parent.tagname != 'html') { // account for any scrolled ancestors pos[0] -= parent.scrollleft;pos[1] -= parent.scrolltop;if (parent.parentnode) {parent = parent.parentnode;} else { parent = null;}} return {x:pos[0], y:pos[1]}; } function addfavorite(surl, stitle) { try { //ie window.external.addfavorite(surl, stitle); } catch (e) { try { //firefox window.sidebar.addpanel(stitle, surl, ""); } catch (e) { try{//chrome无法自动收藏,用创建快应用程序的捷方式来替代。js特效大全 www.www.111cn.net createshortcut(); } catch(e){ alert("请按ctrl+d之后按“确定”完成收藏!"); } } } } function sethomepage(pageurl) { if (document.all) { document.body.style.behavior='url(#default#homepage)'; document.body.sethomepage(pageurl); } else { try { //ie netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { try{ //firefox var prefs = components.classes['@mozilla.org/preferences-service;1'] .getservice(components. interfaces.nsiprefbranch); prefs.setcharpref('browser.startup.homepage',pageurl); } catch(e) { alert( "您的浏览器不支持该操作,请使用浏览器菜单手动设置." ); } } } } var kesionjs={ //通用对话框 alert:function(msg,act){ if (frameelement==null || frameelement.api==undefined){ this.alert1(msg,act); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.alert(msg,function(){ settimeout(function(){ eval(act);},1);}); } }, alert1:function(msg,act){ jquery.dialog.alert(msg,function(){eval(act);}); }, alertbytime:function(src,msg,t){ if (src==1){ src="success.gif"; }else{ src="error.gif"; } if (t=='') t=2; jquery.dialog.tips(msg,t,src,function(){}); }, confirm:function(msg,fun1,fun2){ if (frameelement==null ||frameelement.api==undefined){ this.confirm1(msg,fun1,fun2); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.confirm(msg,function(){settimeout(function(){ eval(fun1);},1);},function(){ settimeout(function(){ eval(fun2);},1);}); } }, confirm1:function(msg,fun1,fun2){ jquery.dialog.confirm(msg,function(){eval(fun1);},function(){eval(fun2);}); }, message:function(ico,msg,fun){ if (frameelement==null ||frameelement.api==undefined){ this.message1(ico,msg,fun); }else{ var api = frameelement.api, w = api.opener; w.jquery.dialog.tips(msg,2,ico,function(){ settimeout(function(){ eval(fun);},1); }); } }, message1:function(ico,msg,fun){ jquery.dialog.tips(msg,2,ico,function(){eval(fun);}); }, tips:function(title,msg,w,h){ jquery.dialog({ title:title, content: msg, width:w, height:h, max:false, min:false }); } }; /*鼠标切换脚本*/ function scrolldoor(){ } scrolldoor.prototype = { sd : function(menus,divs,openclass,closeclass){ var _this = this; if(menus.length != divs.length) { alert("菜单层数量和内容层数量不一样!"); return false; } for(var i = 0 ; i < menus.length ; i++) { _this.$(menus[i]).value = i; _this.$(menus[i]).onmouseover = function(){ for(var j = 0 ; j < menus.length ; j++) { _this.$(menus[j]).classname = closeclass; _this.$(divs[j]).style.display = "none"; } _this.$(menus[this.value]).classname = openclass; _this.$(divs[this.value]).style.display = "block"; } } }, $ : function(oid){ if(typeof(oid) == "string") return document.getelementbyid(oid); return oid; } } //==============================限时抢购倒计时================================/ function gethtmlstr(id,num){ $.ajax({ type: "get", url: installdir+"shop/limitbuy.asp", data: "id="+id+"&num="+num+"&fresh=" + math.random(), cache:false, success: function(result){ result=unescape(result); $("#loading"+id).hide(); $("#hasqianggou"+id).show(); eval(result.split('|')[0]); $("#qianggou"+id).html(result.split('|')[1]); } }); } //调用限时/限量抢购 function getlimitbuy(taskid,num) { document.writeln('
'); document.writeln(''); gethtmlstr(taskid,num); //异步调用主方法 } //显示剩余时间 var servertime = new date() ; var datetime = new date(); var difference = datetime.gettime() - servertime.gettime(); function stringtodate(datestr) { var converted = date.parse(datestr); var mydate = new date(converted); if (isnan(mydate)) { var arys= datestr.split(' '); var arys1=arys[0].split('-'); var arys2=arys[1].split(':'); mydate = new date(arys1[0],--arys1[1],arys1[2],arys2[0],-arys2[1],arys2[2]); } return mydate; } function show_date_time(begin,end,bjq,f){ var begintime =stringtodate(begin) var endtime =stringtodate(end) var nowtime = new date(); var nms=endtime.gettime() - nowtime.gettime() + difference; var myd=math.floor(nms/(1000 * 60 * 60 * 24)); var myh=math.floor(nms/(1000*60*60)) % 24; var mym=math.floor(nms/(1000*60)) % 60; var mys=math.floor(nms/1000) % 60; var myms=math.floor(nms/100) % 10; if(myd>= 0){ var str =''; if (myd>0) str=myd+"天"; str+=myh+"小时"+mym+"分"+mys+"."+myms+"秒"; }else{ var str = ""; if (f==0) { var tt=begintime.gettime()-nowtime.gettime(); if (tt>0){ str="火爆进行中..."; }else{ str="已结束."; } }else{str = "已结束.";} } document.getelementbyid(""+bjq+"").innerhtml=str; window.settimeout("show_date_time('"+begin+"','"+end+"','"+bjq+"','"+f+"')", 100); } //==============================限时抢购倒计时结束================================/ //===================================标签ajax输出开始========================================================== var labelid=""; var classid=""; var infoid=""; var refreshtype=""; var specialid=""; var objid=""; function getlabeltag(){ var labelitem = document.getelementsbytagname("span"); for(var i=0; i正在加载数据..."; $.ajax({ type:"post", url:installdir+posturl+senddata, cache:false, success:function(d){ obj.innerhtml=d; }}); } //取url传的参数 function geturlparam() { var urlparams = new object() ; var aparams = document.location.search.substr(1).split('&') ;//substr(n,m)截取字符从n到m,split('o')以o为标记,分割字符串为数组 if(aparams!=''&&aparams!=null){ var sum=new array(aparams.length);//定义数组 for (i=0 ; i < aparams.length ; i++) { sum[i]=new array(); var aparam = aparams[i].split('=') ;//以等号分割 urlparams[aparam[0]] = aparam[1] ; sum[i][0]=aparam[0]; sum[i][1]=aparam[1]; } var p=''; for(i=0;i正在读取数据..."); $.ajax({ type:"post", url:installdir+"plus/ajaxs.asp?action=ajaxsqllabel&labelid="+escape(labelid)+"&infoid="+infoid+"&classid="+classid+"&refreshtype="+refreshtype+"&specialid=" +specialid+"&curpage="+page+geturlparam(), cache:false, success:function(d){ $("#"+id).html("
    "+d+"
"); }}); } function turn(page,labelname) { if (page==-1){ alert("已经是首页了!"); }else if (page==-2){ alert("已经是最后一页了!") }else{ labelid=labelname; objid=$("[labelname='"+labelname+"']").attr("id"); classid=$("[labelname='"+labelname+"']").attr("classid"); infoid=$("[labelname='"+labelname+"']").attr("infoid"); loadpage(objid,page,labelid,classid,infoid,refreshtype,specialid) } } $(document).ready(function(){ getlabeltag(); }); //===================================标签ajax输出结束==========================================================