/**----前台模板里必须调用的通用js文件--**/ var appurl='/'; //主程序安装url,请正确填写,否则可能导到js不能用,如是网站有启用二级域名,请填写主站域名 document.write(''); //===========================ajax标签结束开始=============================================== jquery(document).ready(function(){ jquery("span[type=ajax]").each(function(){ loadajaxlist($(this)); }); jquery("*[linkref]").click(function(){ var linkid=$(this).attr("linkref"); var url=appurl+"plus/ajaxs.ashx?a=linkhits&linkid="+linkid+"&anticache=" + math.floor(math.random()*1000); jquery.ajax({type:"get",async:false,url:url,cache:false,success:function(d){ }}); }); jquery("font[type=showhits]").each(function(){ var url=appurl+"model/gethits.aspx?action="+jquery(this).attr("action")+"&f="+jquery(this).attr("f")+"&t="+jquery(this).attr("t")+"&modelid="+jquery(this).attr("modelid")+"&id="+jquery(this).attr("id")+"&anticache=" + math.floor(math.random()*1000); var o=jquery(this); jquery.ajax({type:"get",async:false,url:url,cache:false,success:function(d){ o.html(d); } }); }); //判断app if (isopenapp()){ $(".quick-btn").hide(); $("body").addclass("appbody"); } }); //========================ajax方式加载标签 参数:obj 标签id ,labelparam 标签参数======================== function loadajaxlist(o){ var id=o.attr("id"); var idarr=id.split('_'); var labelid=idarr[0].replace(/ks/g,"").replace(/sql/g,"").replace(/special/g,""); var typeid=idarr[1]; //是否分页 var channelid=idarr[2]; var classid=idarr[3]; var infoid=idarr[4]; var specialid=idarr[5]; if (id.substring(0,7)=="special"){ loadpage('special',id,labelid,1,channelid,classid,infoid,refreshtype,specialid,userparam) }else if (id.substring(0,2)=="ks"){ if (typeid==1){ //分页 loadpage('label',id,labelid,1,channelid,classid,infoid,refreshtype,specialid,userparam) }else{ getlabelcontent("model/ajaxlabel.aspx",id,labelid,"label",typeid,channelid,classid,infoid); } }else if (id.substring(0,3)=="sql") { var refreshtype=o.attr("refreshtype"); var userparam=o.attr("userparam"); if (idarr[1]==1){ loadpage('sql',id,labelid,1,channelid,classid,infoid,refreshtype,specialid,userparam) }else{ getlabelcontent("model/ajaxlabel.aspx?1=1"+geturlparam(),id,labelid,"sql",userparam,channelid,classid,infoid); } } } function getlabelcontent(posturl,id,labelid,action,userparam,channelid,classid,infoid){ $.get(appurl+posturl,{action:action,labelid:labelid,userparam:userparam,channelid:channelid,m_classid:classid,m_infoid:infoid},function(d){ $("#"+id).html(d); }); } function loadpage(action,id,labelid,page,modelid,classid,infoid,refreshtype,specialid,userparam){ if (userparam==''){ $("#"+id).html("
正在读取数据...
"); }else{ $("span[userparam^='"+userparam+"']").html("
正在读取数据...
"); } var s=appurl+"model/ajaxlabel.aspx?action="+action+"&ispage=1&objid="+escape(id)+"&m_infoid="+infoid+"&m_id="+modelid+"&labelid="+escape(labelid)+"&m_classid="+classid+"&refreshtype="+refreshtype+"&specialid=" +specialid+"&page="+page+"&userparam="+escape(userparam)+geturlparam(); $.ajax({ type:"post",url:s,cache:false, success:function(d){ if (userparam==''){ $("#"+id).html(d); }else{ $("span[userparam='"+userparam+"']").html(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 -1)//判断当前的ua中是否包含"ck 2.0",如果包含"ck 2.0"标识当前在云打包的应用中 { return true; }else{ return false; } } //检查是否中文字符 is_zw=function(str){ exp=/[0-9a-za-z_.,#@!$%^&*()-+=|\?/<>]/g; if(str.search(exp) != -1){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; } checkerrorstr=function(charasciicode) { var temparray=new array(43,46,34,47,92,42,58,60,62,63,124); for (var i=0;i
'); else inserthtmltoeditorbyid(editorid,'
'); }else if (fileext=="mp3" || fileext=="flv"||fileext=="mp4" || fileext=="f4v" || fileext=="wmv" || fileext=="swf" || fileext=="rm" || fileext=="rmvb"){ var mheight=450; if (fileext=="mp3") mheight=100; if (editorid=='') inserthtmltoeditor('[media='+fileext+',500,'+mheight+',1]'+filelist+'[/media]'); else inserthtmltoeditorbyid(editorid,'[media='+fileext+',500,'+mheight+',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+"');") } //判断是否有选择复选框的值,参数op:edit修改 getids=function(op) { var aa=document.getelementsbyname("ids"); var n=0; for (var i=0; i1) { kesionjs.alert('对不起,一次只能编辑一条记录!',null); return false; } else return true; } chk=function(obj) { var el=event.srcelement; var selectedcolor='#e7f1fa'; if (el.type=='checkbox') { if (el.checked==true) obj.style.background=selectedcolor; else obj.style.background=''; } else { var chkbox=$(obj).find("input[type='checkbox']"); if (chkbox.attr("checked")==undefined){ chkbox.attr("checked",true).parent().attr("class","wcheck wcheck-mode-checkbox wcheck-theme-square-classic-red wcheck-on"); obj.style.background=selectedcolor; }else{ obj.style.background='#ffffff'; chkbox.attr("checked",false).parent().attr("class","wcheck wcheck-off wcheck-mode-checkbox  wcheck-theme-square-classic-red"); } } } function select(flag) { //alert(document.forms[0].elements.length); for(var i=0;i50 || num>0){ $("#"+objname).height( $("#"+objname).height()+num*10); } } function showtips(str) { document.write('
'); jquery("#tips").fadein("slow"); } //显示提示层代码 function showhintinfo(obj, objleftoffset,objtopoffset, title, info , objheight, showtype ,objtopfirefoxoffset) { var p = getposition(obj); if((showtype==null)||(showtype =="")) { showtype =="up"; } document.getelementbyid('hintiframe'+showtype).style.height= objheight + "px"; //document.getelementbyid('hinttitle').innerhtml = title; document.getelementbyid('hintinfo'+showtype).innerhtml = info; document.getelementbyid('hintdiv'+showtype).style.display='block'; if((objtopfirefoxoffset != null)&& !isie) { document.getelementbyid('hintdiv'+showtype).style.top=p['y']+objtopfirefoxoffset+"px"; } else { if(objtopoffset == 0) { if(showtype=="up") { document.getelementbyid('hintdiv'+showtype).style.top=p['y']-document.getelementbyid('hintinfo'+showtype).offsetheight-40+"px"; } else { document.getelementbyid('hintdiv'+showtype).style.top=p['y']+obj.offsetheight+5+"px"; } } else { document.getelementbyid('hintdiv'+showtype).style.top=p['y']+objtopoffset+"px"; } } document.getelementbyid('hintdiv'+showtype).style.left=p['x']+objleftoffset+"px"; } function getposition(obj) { var r = new array(); r['x'] = obj.offsetleft; r['y'] = obj.offsettop; while(obj = obj.offsetparent) { r['x'] += obj.offsetleft; r['y'] += obj.offsettop; } return r; } //隐藏提示层代码 function hidehintinfo() { document.getelementbyid('hintdivup').style.display='none'; document.getelementbyid('hintdivdown').style.display='none'; } //==================================================digg模块开始================================================== digg=function(diggtype,channelid,infoid,installdir){ jquery.ajax({url:installdir+'plus/digg.aspx',cache:false,data:'action=hits&channelid='+channelid+'&infoid=' +infoid+'&diggtype='+diggtype,success:function(returnvalue){ switch (returnvalue){ case "err": kesionjs.message('error.gif','digg error!',null); break; case "over": kesionjs.message('error.gif','您已评分过了,不能重复评分!',null); break; case "nologin": kesionjs.message('error.gif','您还没有登录,不能推荐!',null); break; default: try{ var sarr=returnvalue.split('|'); $('#s'+diggtype+sarr[0]).html(sarr[1+diggtype]); $('#d'+diggtype+sarr[0]).html("查看"); }catch(e){ } try{ showdigg(returnvalue); }catch(e){ } } }}); } show_digg=function(diggtype,channelid,infoid,installdir){ jquery('#s'+diggtype+infoid).html(""); jquery.ajax({url:installdir+"/plus/digg.aspx",cache:false,data:"channelid="+channelid+"&infoid="+infoid+"&action=show&diggtype="+diggtype,success:function(obj){ showdiggnum(obj,diggtype); }}); } showdiggnum=function(returnvalue,diggtype){ var rarr=returnvalue.split('|'); jquery('#s'+diggtype+rarr[0]).html(rarr[1+diggtype]); } show_digg1=function(channelid,infoid,installdir){ jquery.ajax({url:installdir+"plus/digg.aspx",cache:false,data:"channelid="+channelid+"&infoid="+infoid+"&action=show",success:function(obj){ showdigg(obj); }}); } showdigg=function(r){ try{ var rarr=r.split('|'); jquery("#s"+rarr[0]).html(rarr[1]); jquery("#c"+rarr[0]).html(rarr[2]); var znum=jquery("#s"+rarr[0]).html(); var cnum=jquery("#c"+rarr[0]).html(); var totalnum=parseint(znum)+parseint(cnum); if (parseint(znum)==0){ jquery("#perz"+rarr[0]).html('0%'); }else{ jquery("#perz"+rarr[0]).animate({opacity:0}, 1).html(((znum*100)/totalnum).tofixed(2)+'%').animate({opacity:0.2},300).animate({opacity:0.5},200).animate({opacity:0.7},300).animate({opacity:1},800); } if (parseint(cnum)==0){ jquery("#perc"+rarr[0]).html('0%'); }else{ jquery("#perc"+rarr[0]).animate({opacity:0}, 1).html(((cnum*100)/totalnum).tofixed(2)+'%').animate({opacity:0.2},300).animate({opacity:0.5},200).animate({opacity:0.7},300).animate({opacity:1},800); } jquery("#digzcimg").width(parseint((znum/totalnum)*55)); jquery("#digcimg").width(parseint((cnum/totalnum)*55)); }catch(e){ } } //==================================================digg模块结束================================================== //点分享加积分 function addscore(classid,infoid){ jquery.ajax({ type: "post", url: appurl+"plus/ajaxs.ashx", data: "classid="+classid+"&infoid="+infoid+"&a=shareaddscore", success: function(data){ } }); return true; } //点广告 function clickads(adid,bid){ jquery.ajax({ type: "post", url: appurl+"plus/ajaxs.ashx", data: "adid="+adid+"&bid="+bid+"&a=clickads", success: function(data){ } }); return true; } //===========================以下是一些常用js=============================================== 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);}); $.dialog.tips(msg,2); settimeout(function(){ eval(fun);},2000); }, tips:function(title,msg,w,h){ jquery.dialog({ title:title, content: msg, width:w, height:h, max:false, min:false }); }, getfilenamearea:function(val){ if (val==0){ jquery('#filearea').css("display","none");} else{ jquery('#filearea').css("display","");} }, gettemplatearea:function(val){ if (val==2){ jquery('#templatearea').css("display","none");} else{ jquery('#templatearea').css("display","");} }, //word存图 savewordpic:function(callfrom,id){ var html=''; if (id!='' && id!=undefined) html=eval('editor'+id+'.getcontent()'); else html=editor.getcontent(); var wordpic; try { wordpic = new activexobject("kesion.word"); } catch (exception) { kesionjs.alert('您没有安装kesioncms word图片上传插件或您的浏览器不支持!',null); return ; } if (html==''){ kesionjs.alert('编辑器中没有内容!',null); return; } jquery('#ajaxmsg',window.parent.document).toggle(); var temp = ""; var strbase64 = ""; var reg=//ig; var result = html.match(reg); if (result) { for (i = 0; i < result.length; i++) { var str=result[i] var src=str.split('file:///')[1]; src=src.split('"')[0]; var source='file:///'+src; html=html.replace(str,""); var temppic = wordpic.imagetobase64(src); //alert(str + "|" + temppic + "$"); if (temppic != "") { temp +=source + "|" + temppic + "$"; } } if (temp != "") { strbase64 = temp.substring(0, temp.length - 1); } } //alert(html); // return strbase64; //document.write(html); //return; strbase64 = strbase64.replace(/\+/ig, "*"); try { var oxmlhttp = new activexobject("microsoft.xmlhttp"); var postdata = "callfrom="+callfrom+"&html=" + escape(html) + "&strbase64=" + escape(strbase64) ; //alert(postdata); oxmlhttp.open("post", appurl+"plus/worduploadpic.aspx", false); oxmlhttp.setrequestheader("content-length", postdata.length); oxmlhttp.setrequestheader("content-type", "application/x-www-form-urlencoded"); oxmlhttp.send(postdata); if (oxmlhttp.readystate == 4) { if (oxmlhttp.status == 200) { html = oxmlhttp.responsetext; if (id!='' && id!=undefined) { eval('editor'+id+'.setcontent(html)'); }else{ editor.setcontent(html); } jquery('#ajaxmsg',window.parent.document).toggle(); return; } } } catch (exception) { return; } return ; } }; //===========================js结束============================================================= function showuserlogin(){ $.dialog.open(appurl+"user/userlogin.aspx",{id:"loginbox",lock:true,fixed:true,title:"
用户登录
",width:380,height:500,max:false,min:false}); } //检查是不是数字 isnumber = function (e) { if ($.browser.msie) { if ( ((event.keycode > 47) && (event.keycode < 58)) || (event.keycode == 8) ) { return true; } else { return false; } } else { if ( ((e.which > 47) && (e.which < 58)) || (e.which == 8) ) { return true; } else { return false; } } } //打印指定区域 function printpage(mydiv){ var newstr = document.getelementbyid(mydiv).innerhtml; var oldstr = document.body.innerhtml; newstr+=""; document.body.innerhtml = newstr; var oldcss=$("link").attr("href"); $("link").attr("href",""); window.print(); document.body.innerhtml = oldstr; $("link").attr("href",oldcss); return false; } var sagent=navigator.useragent.tolowercase(); var isie=sagent.indexof("msie")!=-1; /*******显示等待提示消********/ function showwaitinfo(info,obj){ try{ if(obj==null)return; clearwaitinfo(); var newd=document.createelement("span"); newd.classname='waitinfo'; newd.id='waitinfo'; newd.innerhtml=info; obj.parentnode.appendchild(newd); }catch(e){} } function clearwaitinfo(){ try{ if(jquery('#waitinfo')){jquery('#waitinfo')[0].parentnode.removechild(jquery('#waitinfo')[0]);} }catch(e){} } 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( "您的浏览器不支持该操作,请使用浏览器菜单手动设置." ); } } } } //和当前时间比较,大于当前时间返回true 否则返回false function comparecurrtime(date){ var begintime =stringtodate(date) var nowtime = new date(); var tt=nowtime.gettime()-begintime.gettime(); if (tt<=0){ return true; }else{ return false; } } //显示剩余时间 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){ if (begin=='' || end=='')return; 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 if (f==2){ //一元购开奖 str = "开奖中..."; } else { str = "已结束."; } } $("#"+bjq).html(str); var tfun="show_date_time('"+begin+"','"+end+"','"+bjq+"','"+f+"')"; //window.settimeout(tfun, 100); eval("t"+bjq+"=window.settimeout(tfun, 100);"); } 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"; $("#"+divs[j]).hide(); } _this.$$(menus[this.value]).classname = openclass; $("#"+divs[this.value]).show(); //_this.$$(divs[this.value]).style.display = "block"; } } }, $$ : function(oid){ if(typeof(oid) == "string") return document.getelementbyid(oid); return oid; } } // utility function called by getcookie( ) function getcookieval(offset) { var endstr = document.cookie.indexof (";", offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } // primary function to retrieve cookie by name function getcookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { return getcookieval(j); } i = document.cookie.indexof(" ", i) + 1; if (i == 0) break; } return ""; } // store cookie value with optional details as needed function setcookie(name, value) {document.cookie = name + "=" + escape (value)} // remove the cookie by setting ancient expiration date function deletecookie(name,path,domain) { if (getcookie(name)) {document.cookie = name + "="} }