/* start ready */ if(typeof console != 'undefined'){ window._log=function(){console.log.apply(console, arguments);}; window._profile=function(){(arguments.length?console.profile:console.profileend).apply(console, arguments);}; }else{ window._log=function(){}; window._profile=function(){}; } $(document).ready(function(){ var body = $(document.body); //插入k_ajax浮动层 body.append('
'); $.kc_ready(); //用esc关闭ajax窗口 $($.browser.msie?document:window).keydown(function(e){$.kc_keydown(e.keycode)}); $('.k_help').reset_href().click(function(){$.kc_help_click(this)}).blur(function(){$('#k_help_fly').fadeout(300)}); //右键 $('.k_table_list').bind("contextmenu",function(e){ //在这里书写代码,构建个性右键化菜单 // if(!(($.browser.msie && e.button==0) || (!$.browser.msie && e.button==2))) return; /* if($('#k_list_right_fly').length==0){ var s='
'; s+=$.kc_icon('k8'); s+='
' $('body').append(s); $.kc_ready('#k_list_right_fly '); } */ if($('#k_list_right_fly').length>0){ $('#k_list_right_fly') .css('top',e.pagey-1).css('left',e.pagex-1) .show(); return false; }else{ return true; } //取消默认的右键菜单 }).click(function(){ $('#k_list_right_fly').fadeout(300); }); });/* end ready */ /* kingcms 扩展函数 */ (function ($){ $.fn.reset_href=function(h){ return this.attr('href',h===undefined ? 'javascript:;' : h); }; /* 字符串格式化函数,类似 printf $.strf('%sx%s=%s', 5, 4, 3*4) => '5x4=20' $.strf('比率为 %s%%', 20) => '比率为 20%' */ $.strf = function (s){ var args = arguments, s = args[0], idx = 1; if(!s) return ''; return s.replace(/%([s%])/g,function(a){ return (''+args[idx++]) || ''; }); }; $.kc_ready=function(pre){ if(pre==undefined){ pre='' }else{ pre =$("head meta[name='generator']").attr('content')=='kingcms' ? pre+' ': ''; } $(pre+'.k_ajax').unbind("click"); // 先移除所有绑定的点击事件 目录展开出现重复现象的解决方法 $(pre+'.k_ajax').reset_href().click(function(){$.kc_ajax($(this).attr('rel'))}); $(pre+'.k_goto').reset_href().click(function(){$.kc_goto($(this).attr('rel'));return false;});/*不要删除return false,否则ie6下出现无法跳转的bug*/ //$(pre+'a.k_ajax,a.k_help,a.k_setvalue,a.k_updown').attr('href','javascript:;');//重置k_ajax链接为空->javascript:; $(pre+'.k_aselect').click(function(){$("#k_form_list input[name=list]").attr('checked',true)});//全选 $(pre+'.k_rselect').click(function(){$("#k_form_list input[name=list]").each(function(i){//反选 this.checked=!this.checked; })}); $(pre+'.k_setvalue').reset_href().click(function(){$.kc_setvalue_click(this)}).blur(function(){$('#k_setvalue_fly').fadeout(300)}); $(pre+'.k_updown').reset_href().click(function(){$.kc_updown_click(this)}).blur(function(){$('#k_updown_fly').fadeout(300)}); $(pre+'.k_cmd').click(function(){$.kc_cmd_click(this)}).blur(function(){$('#k_cmd_fly').fadeout(300)}); $(document).mouseup(function(){$('#k_cmd_fly').fadeout(300);}) $(pre+'.k_calendar').click(function(){$.kc_calendar(this)}).blur(function(){$('#k_calendar_fly').fadeout(300)}); $(pre+'.k_color').click(function(){$.kc_color(this)}).blur(function(){$('#k_color_fly').fadeout(300)}); $(pre+'.k_float').mousedown(function(e){$.kc_float(this,e)}).fadeto(50,1.0); $(pre+'.k_verify').click(function(){$.kc_verify(this)}).focus(function(){$.kc_verify(this)}); $(pre+"*[class^='k_user_']").reset_href().click(function(){$.kc_user_action(this,pre)}); $(pre+'.k_close').reset_href().click(function(){ $.kc_close(); }); $(".k_table_list tr").hover(function(){ $(this).children('td').addclass('hover'); },function(){ $(this).children('td').removeclass('hover'); }); } $.kc_verify=function(obj){ var id=obj.id; if($('#'+id+'_fly').length==0){ $(obj).after(''); $.kc_ajax({url:$.kc_root()+'system/verify.php',id:id+'_fly',cmd:'salt'}); } $('#'+id+'_fly').css('position','absolute').fadein(100); } $.kc_help_click=function(obj){ var rel=eval('('+obj.rel+')'); var width=rel.width; var o=$(obj).children('img').offset(); var left=17; var top=17; if($('#k_help_fly').length==0){ $('body').append('
'); } $.kc_ajax(obj.rel); $('#k_help_fly').css('top',o.top+top).css('left',o.left+left).css('zindex',1100).fadein(100).click(function(){$(this).fadeout(300)}); } $.kc_progress=function(id,title,text,prop){ $('#'+id).children('label').html(title).end() .children('var').html(text).end() .find('>span>em').width(prop); } $.kc_userstate=function(id){ var cookie=document.cookie; /* var auth=cookie.match(/auth_[a-za-z0-9]+\=\d+\%09[a-za-z0-9%]{3,200}\%09\w{32}/); */ var re=new regexp('auth_[a-za-z0-9]+\=(\\d+)\\%09([a-za-z0-9%]{3,200})\\%09(\\w{32})'); var auth=re.exec(cookie); if(auth!==null){ var userid=regexp.$1; var username=decodeuricomponent(regexp.$2); var userhead= $.ajax({ type: "get", datatype:"html", url: "/user/index.php?action=getavatar&id="+userid, async: false }).responsetext; var auth_obj=$('#'+id+'_hide'); var auth_htm=auth_obj.html(); auth_htm=auth_htm.replace('[userid]',userid); //replace global variable auth_htm=auth_htm.replace(/\[username\]/g,username); auth_htm=auth_htm.replace('[avatar]',userhead); auth_obj.html(auth_htm); auth_obj.show(); $('#'+id).hide(); } } $.kc_border=function(obj){ var aa=new array('paddingleft','paddingright','marginleft','marginright','borderleft','borderright'); var num=0; var tmp for (key in aa){ tmp=$(obj).css(aa[key]); if(tmp!=undefined) num=num + number(tmp.match(/\d+/));//怪事,不能用parseint获取数字部分? }//parseint(str, 10) || 0 第二个参数是进制,|| 0 是为了防止 nan return num; } $.kc_user_action=function(obj,pre){ var cls=$(obj).attr('class'); var s=cls.match(/k_user_[a-z]+/i)[0]; $.kc_ajax({url:$.kc_root()+'user/index.php',method:'get',cmd:s.substr(7,s.length-7),is:(pre==''?0:1)}); } $.kc_keydown=function(key){//键盘响应 switch(key){ case 27: $.kc_close(); break; case 13: // $.kc_ajax(); break; } } $.kc_goto=function(rel){//跳转到 var rel=eval('('+rel+')');//rel值 var url= (rel.url==undefined ? parent.location.href : rel.url);//跳转到 parent.location.href=url; } $.kc_href=function(){//获得当前页地址 var s=parent.location.href; var num; num=s.indexof('#'); if(num>0) s=s.substring(0,num); num=s.indexof('?'); if(num>0) s=s.substring(0,num); return s; } $.kc_root=function(){//返回根目录 if($.kc_root.path){ return $.kc_root.path; } var sc=$('head script:first[src$=\'system/js/jquery.kc.js\']'); var fp=sc.attr('src');//filepath return $.kc_root.path = fp.substring(0,fp.length-22); } $.kc_ajax=function(rel){//ajax调用 var rel=(typeof rel=='string') ? eval('('+rel+')') : rel;//rel值 var cmd=(rel.cmd==undefined?'':rel.cmd);//cmd var url=(rel.url==undefined?$.kc_href():rel.url);//post地址 var id=(rel.id==undefined?'k_ajax':rel.id);//返回输出值的id值 var is=(rel.is==undefined?0:rel.is);//loading的显示类型,默认右上角显示,1的时候不显示loading,2的时候显示图片loading var form=(rel.form==undefined?'#k_ajaxform':'#'+rel.form);//表单域 var v=rel.val;//一并提交的指定值,各个值之间用逗号分开 //操作验证:删除/清理/退出 var t_ = cmd.match(/^(delete|clear|close|logout)/); if(t_ && !confirm($.kc_lang(t_[0]))){ return false; } //rel中的预设值 var postdata=''; $.each(rel,function(i,n){ postdata+=(i+"="+n+'&'); }); //val中指定的值 if(v!=undefined){ var array_v=v.split(','); $.each(array_v,function(i,n){ postdata+=(n+'='+$('#'+n).val())+'&'; }); } //form表单中的值 var formdata=$(form).serialize(); var formdatas=formdata.split('&'); var tmp=new array; if(formdatas.length){ $.each(formdatas,function(i,n){ if(n.length>0){ var nn=n.split('='); if(tmp[nn[0]]==undefined){ tmp[nn[0]]=nn[1]; }else{ tmp[nn[0]]+=','+nn[1]; } } }); for (key in tmp){ postdata+='&'+key+'='+tmp[key]; } } if(id=='k_ajax'&&is!=1){ $('#k_ajax').html('
loading...
'); $('#k_ajaxfly').css({ 'position':'absolute', 'top':document.documentelement.scrolltop, 'left':$(document).width()-$('#k_ajaxfly').width()-$.kc_border($('#k_ajaxfly')) }); } if(is==2){ $('#'+id).html(''); } $.ajax({ url:url+'?action=ajax', type:'post', data:postdata, datatype:'html', timeout:30000, error:function(){if(id=='k_ajax'){$.kc_ajax_show("{title:'error!',main:'

'+$.kc_lang('timeout')+'

',but:''+$.kc_lang('enter')+'',width:320,height:100}");}//else{alert($.kc_lang('timeout'))}//k_msg出错? }, success: function(s){ if(id=='k_ajax'){ $.kc_ajax_show(s) }else{ var d=eval('('+s+')');//通过php处理后返回的值 var main=d.main; var js=d.js; if(main!=''){ $('#'+id).html(main); $('#'+id+' .k_ajax').attr('href','javascript:;').click(function(){ $.kc_ajax(this.rel); }); } if(js!=''){ eval(js); } } } }); } $.kc_ajax_show=function(s){//构造ajax交互窗口 if(s.length<10){//若s为空值,则提示错误 s="{title:'error!',main:'

'+$.kc_lang('empty')+'

',but:''+$.kc_lang('enter')+'',width:320,height:100}"; } try{ var d=eval('('+s+')');//通过php处理后返回的值 }catch(e) { alert(e+'\n\n'+(s.length>5002?s.substr(0,5000)+'...':s)); return; } var title=d.title; var main=d.main; var but=d.but; var width=d.width; var height=d.height; var js=d.js; // 赋值并显示 if(title!=''||main!=''){ $('html').css('overflow','hidden'); var w=$(window).width(); var h=$(window).height(); if($.browser.opera){//opera下$(window).height 并不是可是区域大小,不知道是不是jquery的bug? h=document.documentelement.clientheight; } var str='
'; str+='
'; str+='
'; str+='
'; str+='
'; str+='
'; str+='
'; str+='
'; str+='
'; $('#k_ajax').html(str).show(); $('#k_ajaxbg').css({ 'top':document.documentelement.scrolltop+document.body.scrolltop, 'width':w+30, 'height':h+30, 'left':document.documentelement.scrollleft }); $('#k_ajaxtitle').width(width); $('#k_ajaxttitle').width(width-$('#k_ajaxtitle a.k_close').width()).html(title); $('#k_ajaxmain').css({width:width,height:height}); $('#k_ajaxcontent').html(main); $('#k_ajaxsubmit').width(width-$.kc_border($('#k_ajaxsubmit'))).html('

'+but+'

'); var nheight=height+$('#k_ajaxtitle').height()+$('#k_ajaxsubmit').height();//完整的高度 $('#k_ajaxbox').css({ 'left':document.documentelement.scrollleft+(w-width)/2, 'width':width, 'height':nheight, 'zindex':'901', 'position':'absolute', 'top':document.body.scrolltop+document.documentelement.scrolltop+((h-nheight)/2) }); $(window).resize(function(){ w=$(window).width(); h=$(window).height(); height=$('#k_ajaxmain').height(); nheight=height+$('#k_ajaxtitle').height()+$('#k_ajaxsubmit').height();//完整的高度 if($.browser.opera){ h=document.documentelement.clientheight; } $('#k_ajaxbg').css('width',w+30).css('height',h+30); $('#k_ajaxbox').css('top',document.documentelement.scrolltop+((h-nheight)/2)).css('left',document.documentelement.scrollleft+(w-width)/2); }).scroll(function(){//opera下隐藏滚动条的情况下还能上下拖动.. w=$(window).width(); h=$(window).height(); height=$('#k_ajaxmain').height(); nheight=height+$('#k_ajaxtitle').height()+$('#k_ajaxsubmit').height();//完整的高度 $('#k_ajaxbg').css('width',w+30).css('height',h+30).css('top',document.documentelement.scrolltop).css('left',document.documentelement.scrollleft); $('#k_ajaxbox').css('top',document.documentelement.scrolltop+((h-nheight)/2)).css('left',document.documentelement.scrollleft+(w-width)/2); }); $('#k_ajaxcontent input:first').focus();//焦点定位到第一个input框,ie7/8下失效? $.kc_ready('#k_ajax'); var tipp=$('#k_ajax p.k_err,#k_ajax p.k_ok'); if(tipp.html()!=null){ $('#k_ajax #k_ajaxmain').html('
'+tipp.html()+'
'); } $('#k_ajaxbox input').keydown(function(event){ if(event.keycode==13){ $.kc_ajax($('#k_ajaxsubmit a.k_ajax:first').attr('rel'));//读取第一个k_ajax操作按钮的rel并调用$.kc_ajax } }); /* $('#k_ajaxbox form').each(function(_, form){ form.onsubmit = function(){ $('a.k_ajax:first', form).click(); return false; }; }); */ $('#k_ajaxform').submit(function(){ return false; }); } if(js!=''){ eval(js); } } $.kc_close=function(){//隐藏ajax $('html').css('overflow',''); $('#k_ajax').empty(); } $.kc_nbsp=function(s){//空值替换为  return s==''||s==0?' ':s; } $.kc_long2ip=function(nlong) { if (nlong < 0){ nlong=nlong+4294967296; } if(nlong > 4294967295){ return false; } ip = ""; for (i=3;i>=0;i--) { ip += parseint(nlong / math.pow(256,i)) nlong -= parseint((nlong / math.pow(256,i)))*math.pow(256,i); if (i>0) ip += "."; } return ip; } /* $.kc_formatdate=function(timec){ var d,s,y,yy,h,ap; if (timec==0){ s='-' }else{ d = new date(timec*1000); h=d.gethours(); if (h<=12){ ap='am'; }else{ ap='pm'; h-=12; } s=$.kc_double(d.getyear())+'-' s+=$.kc_double(d.getmonth() + 1) + "-" s+=$.kc_double(d.getdate()) + ", " s+=" "+$.kc_double(h); s+=":"+$.kc_double(d.getminutes()); s+=' '+ap; } return(s); } */ $.kc_double=function(s){ var i1,ss; ss=s.tostring(10); if (ss.length>2){ i1=ss.substr(ss.length-2,2); }else if(ss.length==2){ i1=ss; }else{ i1='0'+ss } return i1; } /** id 自动递增的id tit 对应的标题 link 链接 isid 是否显示id isgray 是否为灰调 ico 前置图片,直接写icon.gif中的图片表 space 有多少空格 first 最前面显示的内容,比如列表页的展开关闭之类 after 标题后面显示的内容,比如是否有图片等 */ $.kc_list=function(id,tit,link,isid,isgray,ico,space,first,after){ classname= isgray==0 ? ' gray' : ''; ico= ico==undefined ? '' : $.kc_icon(ico); space= space==undefined ? '' : 'style="margin-right:'+20*(space-1)+'px;"'; if(first==undefined) first=''; var i1=''; return i1; }; /** clas class类,即对应关系 alt alt属性 id 给图片设置id */ $.kc_icon=function(clas,alt,id){ if (!alt) alt=''; var hid = id ? ' id="'+id+'"' : ''; return $.strf('', hid, clas ? ' ' + clas : '', alt, alt); }; $.kc_updown=function(kid,cmd){ if(cmd==undefined) cmd='updown'; var s=''; s+=$.kc_icon('n5',$.kc_lang('updown'))+''; return s; }; $.kc_updown_click=function(obj){ var rel=eval('('+obj.rel+')'); var kid=rel.kid; var cmd=rel.cmd; var o=$(obj).children('img').offset(); var left=17; var top=17; if($('#k_updown_fly').length==0){ $('body').append('
'); } var i1=''+$.kc_icon('m6')+' to'; i1+=''+$.kc_icon()+''; for (var i=1;i<=9;i++){ i1+=''+$.kc_icon('n6')+'  '+i+''; i1+=''+$.kc_icon('n7')+'  '+i+''; } var arr=new array(10,15,20); for(i=0;i'+$.kc_icon('n6')+' '+arr[i]+''; i1+=''+$.kc_icon('n7')+' '+arr[i]+''; } i1+=''+$.kc_icon()+''; i1+=''+$.kc_icon('m7')+' to'; //当页面太靠下的时候,显示在上端 if(o.top+295>$(document).height() && o.top>400){ top=-295; } $('#k_updown_fly').html(i1).css('top',o.top+top).css('left',o.left+left).fadein(100);//位置定义 $('#k_updown_fly .k_ajax').click(function(){ $.kc_ajax(this.rel); }); }; $.kc_setvalue_click=function(obj){ var rel=eval('('+obj.rel+')'); var id=rel.id; var width=rel.width; var is=rel.is; var o=$(obj).children('img').offset(); var left=17; var top=17; if($('#k_setvalue_fly').length==0){ $('body').append('
'); } $('#k_setvalue_fly').html($('#'+id+'_setvalue').val()).css('top',o.top+top).css('left',o.left+left).css('width',width).fadein(100); $('#k_setvalue_fly a').attr('href','javascript:;').click(function(){ var rel_a=eval('('+this.rel+')'); $('#'+id).val(rel_a.value); }); } $.kc_cmd_click=function(obj){ var o=$(obj).offset(); var left=0; var top=24; //#k_cmd_fly $('#k_cmd_fly').css({'top':o.top+top, 'left':o.left+left}).fadein(100); } $.kc_color=function(obj){ var rel=eval('('+obj.rel+')'); var id=rel.id; var o=$(obj).children('img').offset(); if($('#k_color_fly').length==0){ var colors=new array('0','3','6','9','c','f'); var col='kingcms'; var color; $('body').append('
'); for (i=0;i<=5;i++){ for (j=0;j<=5;j++){ for (k=0;k<=5;k++){ color=colors[j]+colors[j]+colors[i]+colors[i]+colors[k]+colors[k]; col+=' '; } } } $('#k_color_fly').html(col); $('#k_color_fly a').attr('href','javascript:;'); } //颜色 $('#k_color_fly').css('top',o.top+17).css('left',o.left+17).fadein(100); $('#k_color_fly a').click(function(){ $('#'+id).val($(this).attr('color')).css('background',$(this).attr('color')); $('#k_color_fly').fadeout(300); }).mousemove(function(){ $('#k_fontcolor').css('color',$(this).attr('color')); }); } $.kc_calendar=function(obj){ //""; var rel=eval('('+obj.rel+')'); var id=rel.id; var o=$(obj).children('img').offset(); if($('#k_calendar_fly').length==0){ $('body').append('
'); } if($('#k_calendar_fly').css('display')=='block'){ $('#k_calendar_fly').fadeout(300); return; } var reg=/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29))$/; var d=$('#'+id).val(); if(!reg.test(d)){ var dd=new date(); d=dd.getfullyear()+'-'+(dd.getmonth()+1)+'-'+dd.getdate(); } /* alert(d); */ //var s= $.kc_calendar_show(d,id); $('#k_calendar_fly').css('top',o.top+17).css('left',o.left+17);//定位 } $.kc_calendar_show=function(d,id){ var dd=d.split('-'); var fday=new date(dd[0],dd[1]-1,1).getday();//每月第一天的前一天星期数 var daynum=new date(dd[0],dd[1],0).getdate();//每月的天数 var n=0; var nday; var s=''; s+=''; s+=''; s+=''; s+='';//这边还可以继续扩展展开显示,先不写了 s+=''; s+=''; s+=''; s+='' for(var i=0;i<7;i++){//填充日历头 s+=''; } s+=''; for(var i=0; i < 6; i++){//填充日期 s+=''; for(var j=0;j<7;j++){ nday=n-fday+1; if(ndaynum){ s+=''; }else if(nday==dd[2]){ s+=''; }else{ s+=''; } n++; } s+=''; } s+='
<<<'+dd[0]+'-'+dd[1]+'>>>
'+$.kc_lang('week'+i)+'
'+nday+''+nday+'
'; $('#k_calendar_fly').html(s).fadein(100); $('#k_calendar_fly td:parent').hover(function(){$(this).addclass('hover')},function(){$(this).removeclass('hover')}); $('#k_calendar_fly a').attr('href','javascript:;').click(function(){ if(this.rel==''){//判断是否有rel值,若没有rel值,则直接插入对应的值 $('#'+id).val(dd[0]+'-'+$.kc_double(dd[1])+'-'+$.kc_double($(this).text())); $('#k_calendar_fly').fadeout(300); }else{//若有rel值,则读取并进行判断 var r=eval('('+this.rel+')'); if(r.month!=undefined){//<<>>来调整上下月份及年份 var ndd=new date(dd[0],dd[1]-1+r.month,1); var nd=ndd.getfullyear()+'-'+$.kc_double(ndd.getmonth()+1)+'-'+$.kc_double(dd[2]); $.kc_calendar_show(nd,id); }else{//这边还可以继续扩展展开显示,先不写了 } } }); } $.kc_float=function(obj,e){//鼠标点击动作 var o=$(obj).offset(); var x=e.clientx-o.left; var y=e.clienty-o.top; var is=true; var bs=10;//块大小blocksize var left,top; var id=$(obj).attr('id'); var kid=id.substr(8,id.length-8); if($('#k_float_shadow').length==0){ $('body').append('
'); } $('#k_float_shadow').fadein(100); $(obj).mousemove(function(e){ if(is==false) return; $(obj).css('zindex',1000).css('top',e.clienty-y).css('left',e.clientx-x).fadeto(100,0.5); top =math.round((e.clienty-y)/bs)*bs; left=math.round((e.clientx-x)/bs)*bs; $('#k_float_shadow').css('top',top).css('left',left)//影子坐标 }).mouseout(function(){ if(is==false) return; is=false; $(obj).css('zindex',200).css('top',top).css('left',left).fadeto(0,1); if(o.left!=left||o.top!=top){ $.kc_ajax({url:'../system/manage.php',cmd:'lnkmove',id:kid,left:left,top:top,is:1}); } }).mouseup(function(){ if(is==false) return; is=false; if((o.left!=left||o.top!=top)&&(top!=undefined||left!=undefined)){ $(obj).css('zindex',200).css('top',top).css('left',left).fadeto(0,1); $.kc_ajax({url:'../system/manage.php',cmd:'lnkmove',id:kid,left:left,top:top,is:1}); } }).blur(function(){ is=false; $(obj).css('zindex',200).fadeto(0,1); }); } /*number_format*/ $.number_format=function(number, decimals, dec_point, thousands_sep){ // http://kevin.vanzonneveld.net // + original by: jonas raoni soares silva (http://www.jsfromhell.com) // + improved by: kevin van zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: michael white (http://getsprink.com) // + bugfix by: benjamin lupton // + bugfix by: allan jensen (http://www.winternet.no) // + revised by: jonas raoni soares silva (http://www.jsfromhell.com) // + bugfix by: howard yeend // + revised by: luke smith (http://lucassmith.name) // + bugfix by: diogo resende // + bugfix by: rival // % note 1: for 1000.55 result with precision 1 in ff/opera is 1,000.5, but in ie is 1,000.6 // * example 1: number_format(1234.56); // * returns 1: '1,235' // * example 2: number_format(1234.56, 2, ',', ' '); // * returns 2: '1 234,56' // * example 3: number_format(1234.5678, 2, '.', ''); // * returns 3: '1234.57' // * example 4: number_format(67, 2, ',', '.'); // * returns 4: '67,00' // * example 5: number_format(1000); // * returns 5: '1,000' // * example 6: number_format(67.311, 2); // * returns 6: '67.31' var n = number, prec = decimals; n = !isfinite(+n) ? 0 : +n; prec = !isfinite(+prec) ? 0 : math.abs(prec); var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep; var dec = (typeof dec_point == "undefined") ? '.' : dec_point; var s = (prec > 0) ? n.tofixed(prec) : math.round(n).tofixed(prec); //fix for ie parsefloat(0.55).tofixed(0) = 0; var abs = math.abs(n).tofixed(prec); var _, i; if (abs >= 1000) { _ = abs.split(/\d/); i = _[0].length % 3 || 3; _[0] = s.slice(0,i + (n < 0)) + _[0].slice(i).replace(/(\d{3})/g, sep+'$1'); s = _.join(dec); } else { s = s.replace('.', dec); } return s; } /* 读取cookie */ $.cookie=function(name){//读取cookie,仿php的读取cookie var sta=document.cookie.indexof(name+"="); var len=sta+name.length+1; if((!sta)&&(name!=document.cookie.substring(0,name.length))){ return null; } if(sta==-1) return null; var end=document.cookie.indexof(';',len); if(end==-1) end=document.cookie.length; return unescape(document.cookie.substring(len,end)); } /* 设置cookie */ $.setcookie=function(name,value,expires,path,domain,secure){ var today=new date(); today.settime( today.gettime() ); if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new date( today.gettime() + (expires) ); document.cookie = name+'='+escape( value ) + ( ( expires ) ? ';expires='+expires_date.togmtstring() : '' ) + ( ( path ) ? ';path=' + path : '' ) + ( ( domain ) ? ';domain=' + domain : '' ) + ( ( secure ) ? ';secure' : '' ); } })(jquery); var root=$.kc_root(); var cook=$.cookie('language');if(cook==null) cook='zh-cn'; //加入语言包 document.write(''); function kc_style(){//设置页面常用的样式 var i1="abcdefghijklmnopqr";//stuvwxyz var s=''; return s; } document.write(kc_style()); //设置焦掉 $.fn.setcursorposition = function(position){ if(this.lengh == 0) return this; return $(this).setselection(position, position); } $.fn.setselection = function(selectionstart, selectionend) { if(this.lengh == 0) return this; input = this[0]; if (input.createtextrange) { var range = input.createtextrange(); range.collapse(true); range.moveend('character', selectionend); range.movestart('character', selectionstart); range.select(); } else if (input.setselectionrange) { input.focus(); input.setselectionrange(selectionstart, selectionend); } return this; } $.fn.focusend = function(){ this.setcursorposition(this.val().length); }