mbui.js 39 KB

1234567891011121314151617181920212223242526272829
  1. ;!function(win){"use strict";var doc=win.document;var config={modules:{},status:{},timeout:10,event:{}};var Mbui=function(){this.v='1.0.1'};var GLOBAL=win.GLOBAL||{};var getPath=function(){var jsPath=doc.currentScript?doc.currentScript.src:function(){var js=doc.scripts;var last=js.length-1;var src;for(var i=last;i>0;i--){if(js[i].readyState==='interactive'){src=js[i].src;break}}return src||js[last].src}();return config.dir=GLOBAL.dir||jsPath.substring(0,jsPath.lastIndexOf('/')+1)}();var error=function(msg,type){type=type||'log';win.console&&console[type]&&console[type]('mbui error hint: '+msg)};var isOpera=typeof opera!=='undefined'&&opera.toString()==='[object Opera]';var modules={};Mbui.prototype.cache=config;Mbui.prototype.define=function(deps,factory){var that=this;var type=typeof deps==='function';var callback=function(){var setApp=function(app,exports){mbui[app]=exports;config.status[app]=true};typeof factory==='function'&&factory(function(app,exports){setApp(app,exports);config.callback[app]=function(){factory(setApp)}});return this};type&&(factory=deps,deps=[]);that.use(deps,callback,null,'define');return that};Mbui.prototype.use=function(apps,callback,exports,from){var that=this;var dir=config.dir=config.dir?config.dir:getPath;var head=doc.getElementsByTagName('head')[0];apps=function(){if(typeof apps==='string'){return[apps]}else if(typeof apps==='function'){callback=apps;return['all']}return apps}();var item=apps[0];var timeout=0;exports=exports||[];config.host=config.host||(dir.match(/\/\/([\s\S]+?)\//)||['//'+location.host+'/'])[0];function onScriptLoad(e,url){var readyRegExp=navigator.platform==='PLaySTATION 3'?/^complete$/:/^(complete|loaded)$/;if(e.type==='load'||(readyRegExp.test((e.currentTarget||e.srcElement).readyState))){config.modules[item]=url;head.removeChild(node);(function poll(){if(++timeout>config.timeout*1000/4){return error(item+' is not a valid module','error')}config.status[item]?onCallback():setTimeout(poll,4)}())}}function onCallback(){exports.push(mbui[item]);apps.length>1?that.use(apps.slice(1),callback,exports,from):(typeof callback==='function'&&function(){callback.apply(mbui,exports)}())}if(apps.length===0||(modules[item])){return onCallback(),that}var url=(modules[item]?(dir+'modules/'):(/^\{\/\}/.test(that.modules[item])?'':(config.base||'')))+(that.modules[item]||item)+'.js';url=url.replace(/^\{\/\}/,'');if(!config.modules[item]&&mbui[item]){config.modules[item]=url}if(!config.modules[item]){var node=doc.createElement('script');node.async=true;node.charset='utf-8';node.src=url+function(){var version=config.version===true?(config.v||(new Date()).getTime()):(config.version||'');return version?('?v='+version):''}();head.appendChild(node);if(node.attachEvent&&!(node.attachEvent.toString&&node.attachEvent.toString().indexOf('[native code')<0)&&!isOpera){node.attachEvent('onreadystatechange',function(e){onScriptLoad(e,url)})}else{node.addEventListener('load',function(e){onScriptLoad(e,url)},false)}config.modules[item]=url}else{(function poll(){if(++timeout>config.timeout*1000/4){return error(item+' is not a valid module','error')}(typeof config.modules[item]==='string'&&config.status[item])?onCallback():setTimeout(poll,4)}())}return that};Mbui.prototype.disuse=function(apps){var that=this;apps=that.isArray(apps)?apps:[apps];that.each(apps,function(index,item){if(!config.status[item]){}delete that[item];delete modules[item];delete that.modules[item];delete config.status[item];delete config.modules[item]});return that};Mbui.prototype.getStyle=function(node,name){var style=node.currentStyle?node.currentStyle:win.getComputedStyle(node,null);return style[style.getPropertyValue?'getPropertyValue':'getAttribute'](name)};Mbui.prototype.link=function(href,fn,cssname){var that=this;var head=doc.getElementsByTagName('head')[0];var link=doc.createElement('link');if(typeof fn==='string')cssname=fn;var app=(cssname||href).replace(/\.|\//g,'');var id='mbuicss-'+app;var STAUTS_NAME='creating';var timeout=0;link.href=href+(config.debug?'?v='+new Date().getTime():'');link.rel='stylesheet';link.id=id;link.media='all';if(!doc.getElementById(id)){head.appendChild(link)}if(typeof fn!=='function')return that;(function poll(status){var delay=100;var getLinkElem=doc.getElementById(id);if(++timeout>config.timeout*1000/delay){return error(href+' timeout')}if(parseInt(that.getStyle(getLinkElem,'width'))===1989){if(status===STAUTS_NAME)getLinkElem.removeAttribute('load-status');getLinkElem.getAttribute('load-status')===STAUTS_NAME?setTimeout(poll,delay):fn()}else{getLinkElem.setAttribute('load-status',STAUTS_NAME);setTimeout(function(){poll(STAUTS_NAME)},delay)}}());return that};Mbui.prototype.addcss=function(firename,fn,cssname){return mbui.link(config.dir+'css/'+firename,fn,cssname)};config.callback={};Mbui.prototype.factory=function(modName){if(mbui[modName]){return typeof config.callback[modName]==='function'?config.callback[modName]:null}};Mbui.prototype.config=function(options){options=options||{};for(var key in options){config[key]=options[key]}return this};Mbui.prototype.modules=function(){var clone={};for(var o in modules){clone[o]=modules[o]}return clone}();Mbui.prototype.extend=function(options){var that=this;options=options||{};for(var o in options){if(that[o]||that.modules[o]){error(o+' Module already exists','error')}else{that.modules[o]=options[o]}}return that};Mbui.prototype.router=Mbui.prototype.hash=function(hash){var that=this;var hash=hash||location.hash;var data={path:[],search:{},hash:(hash.match(/[^#](#.*$)/)||[])[1]||''};if(!/^#\//.test(hash))return data;hash=hash.replace(/^#\//,'');data.href='/'+hash;hash=hash.replace(/([^#])(#.*$)/,'$1').split('/')||[];that.each(hash,function(index,item){/^\w+=/.test(item)?function(){item=item.split('=');data.search[item[0]]=item[1]}():data.path.push(item)});return data};Mbui.prototype.url=function(href){var that=this;var data={pathname:function(){var pathname=href?function(){var str=(href.match(/\.[^.]+?\/.+/)||[])[0]||'';return str.replace(/^[^\/]+/,'').replace(/\?.+/,'')}():location.pathname;return pathname.replace(/^\//,'').split('/')}(),search:function(){var obj={};var search=(href?function(){var str=(href.match(/\?.+/)||[])[0]||'';return str.replace(/\#.+/,'')}():location.search).replace(/^\?+/,'').split('&');that.each(search,function(index,item){var _index=item.indexOf('='),key=function(){if(_index<0){return item.substr(0,item.length)}else if(_index===0){return false}else{return item.substr(0,_index)}}();if(key){obj[key]=_index>0?item.substr(_index+1):null}});return obj}(),hash:that.router(function(){return href?((href.match(/#.+/)||[])[0]||'/'):location.hash}())};return data};Mbui.prototype.each=function(obj,fn){var key;var that=this;var callFn=function(key,obj){return fn.call(obj[key],key,obj[key])};if(typeof fn!=='function')return that;obj=obj||[];if(that.isArray(obj)){for(key=0;key<obj.length;key++){if(callFn(key,obj))break}}else{for(key in obj){if(callFn(key,obj))break}}return that};var EV_REMOVE='MOBAI-EVENT-REMOVE';Mbui.prototype.event=Mbui.event=function(modName,events,params,fn){var that=this;var result=null;var filter=(events||'').match(/\((.*)\)$/)||[];var eventName=(modName+'.'+events).replace(filter[0],'');var filterName=filter[1]||'';var callback=function(_,item){var res=item&&item.call(that,params);res===false&&result===null&&(result=false)};if(params===EV_REMOVE){delete(that.cache.event[eventName]||{})[filterName];return that}if(fn){config.event[eventName]=config.event[eventName]||{};if(filterName){config.event[eventName][filterName]=[fn]}else{config.event[eventName][filterName]=config.event[eventName][filterName]||[];config.event[eventName][filterName].push(fn)}return this}mbui.each(config.event[eventName],function(key,item){if(filterName==='{*}'){mbui.each(item,callback);return}key===''&&mbui.each(item,callback);(filterName&&key===filterName)&&mbui.each(item,callback)});return result};win.mbui=new Mbui()}(window);
  2. mbui.define([],function(exports){"use strict";var tool={ajax:function(options,callback){let format='json';if(options.hasOwnProperty('data')){format=options.data.hasOwnProperty('format')?options.data.format:'json'}callback=callback||options.success;callback&&delete options.success;let optsetting={timeout:10000};if(format=='jsonp'){optsetting={timeout:10000,dataType:'jsonp',jsonp:'callback'}}let opts=$.extend({},optsetting,{success:function(res){if(callback&&typeof callback==='function'){callback(res)}}},options);$.ajax(opts)},get:function(url,data,callback){this.ajax({url:url,type:"GET",data:data},callback)},post:function(url,data,callback){this.ajax({url:url,type:"POST",data:data},callback)},put:function(url,data,callback){this.ajax({url:url,type:"PUT",data:data},callback)},delete:function(url,data,callback){this.ajax({url:url,type:"DELETE",data:data},callback)},reload:function(delay){if(delay&&delay>0){setTimeout(function(){location.reload()},delay)}else{location.reload()}},replace:function(url,delay){if(delay&&delay>0){setTimeout(function(){window.location.replace(url)},delay)}else{window.location.replace(url)}},renderSize:function(val){if(null==val||val==''){return"0 Bytes"}var unitArr=new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");var index=0;var srcsize=parseFloat(val);index=Math.floor(Math.log(srcsize)/Math.log(1024));var size=srcsize/Math.pow(1024,index);size=size.toFixed(2);return size+unitArr[index]},file_item:function(file,view=''){let image=['jpg','jpeg','png','gif'];let fileshow='<div class="mbui-file-icon"><i class="iconfont icon-weizhigeshi"></i></div>';if(file['fileext']=='pdf'){}if(image.includes(file['fileext'])){fileshow='<div class="mbui-file-icon file-img"><img src="'+file['filepath']+'" alt="'+file['name']+'"></div>'}let file_del='';if(view==''){file_del='<div class="mbui-file-del"><i class="iconfont icon-cuowukongxin"></i></div>'}let filesize=this.renderSize(file['filesize']);let filedate=this.formatDate(file['create_time']);let item='<div class="mbui-file-div"data-id="'+file['id']+'"> '+fileshow+' <div class="mbui-file-info"> <div class="mbui-file-name line-limit-1">'+file['name']+'</div> <div class="mbui-file-size">'+filesize+','+filedate+'</div> </div> '+file_del+' </div>';return item},countdown:function(options){var that=this;options=$.extend(true,{date:new Date(),now:new Date()},options);var args=arguments;if(args.length>1){options.date=new Date(args[0]);options.now=new Date(args[1]);options.clock=args[2]}var inst={options:options,clear:function(){clearTimeout(inst.timer)},reload:function(opts){this.clear();$.extend(true,this.options,{now:new Date()},opts);count()}};typeof options.ready==='function'&&options.ready();var count=(function fn(){var date=new Date(options.date);var now=new Date(options.now);var countTime=function(time){return time>0?time:0}(date.getTime()-now.getTime());var result={d:Math.floor(countTime/(1000*60*60*24)),h:Math.floor(countTime/(1000*60*60))%24,m:Math.floor(countTime/(1000*60))%60,s:Math.floor(countTime/1000)%60};var next=function(){now.setTime(now.getTime()+1000);options.now=now;count()};inst.timer=setTimeout(next,1000);typeof options.clock==='function'&&options.clock(result,inst);if(countTime<=0){clearTimeout(inst.timer);typeof options.done==='function'&&options.done(result,inst)}return fn})();return inst},timeAgo:function(time,onlyDate){var that=this;var arr=[[],[]];var stamp=new Date().getTime()-new Date(time).getTime();if(stamp>1000*60*60*24*31){stamp=new Date(time);arr[0][0]=that.digit(stamp.getFullYear(),4);arr[0][1]=that.digit(stamp.getMonth()+1);arr[0][2]=that.digit(stamp.getDate());if(!onlyDate){arr[1][0]=that.digit(stamp.getHours());arr[1][1]=that.digit(stamp.getMinutes());arr[1][2]=that.digit(stamp.getSeconds())}return arr[0].join('-')+' '+arr[1].join(':')}if(stamp>=1000*60*60*24){return((stamp/1000/60/60/24)|0)+' 天前'}else if(stamp>=1000*60*60){return((stamp/1000/60/60)|0)+' 小时前'}else if(stamp>=1000*60*3){return((stamp/1000/60)|0)+' 分钟前'}else if(stamp<0){return'未来'}else{return'刚刚'}},formatDate:function(timestamp,formatStr='YYYY-MM-DD HH:mm:ss'){const date=new Date(timestamp);if(timestamp.toString().length===10){date.setTime(timestamp*1000)}const padZero=(num)=>String(num).padStart(2,'0');const replacements={YYYY:date.getFullYear(),MM:padZero(date.getMonth()+1),DD:padZero(date.getDate()),HH:padZero(date.getHours()),mm:padZero(date.getMinutes()),ss:padZero(date.getSeconds())};return Object.entries(replacements).reduce((str,[key,value])=>{return str.replace(key,value)},formatStr)},time:function(){return Math.floor((new Date).getTime()/1e3)},date:function(n,t){var e,r,u=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"],o=/\\?(.?)/gi,i=function(n,t){return r[n]?r[n]():t},c=function(n,t){for(n=String(n);n.length<t;)n="0"+n;return n};r={d:function(){return c(r.j(),2)},D:function(){return r.l().slice(0,3)},j:function(){return e.getDate()},l:function(){return u[r.w()]+"day"},N:function(){return r.w()||7},S:function(){var n=r.j(),t=n%10;return t<=3&&1===parseInt(n%100/10,10)&&(t=0),["st","nd","rd"][t-1]||"th"},w:function(){return e.getDay()},z:function(){var n=new Date(r.Y(),r.n()-1,r.j()),t=new Date(r.Y(),0,1);return Math.round((n-t)/864e5)},W:function(){var n=new Date(r.Y(),r.n()-1,r.j()-r.N()+3),t=new Date(n.getFullYear(),0,4);return c(1+Math.round((n-t)/864e5/7),2)},F:function(){return u[6+r.n()]},m:function(){return c(r.n(),2)},M:function(){return r.F().slice(0,3)},n:function(){return e.getMonth()+1},t:function(){return new Date(r.Y(),r.n(),0).getDate()},L:function(){var n=r.Y();return n%4==0&n%100!=0|n%400==0},o:function(){var n=r.n(),t=r.W();return r.Y()+(12===n&&t<9?1:1===n&&t>9?-1:0)},Y:function(){return e.getFullYear()},y:function(){return r.Y().toString().slice(-2)},a:function(){return e.getHours()>11?"pm":"am"},A:function(){return r.a().toUpperCase()},B:function(){var n=3600*e.getUTCHours(),t=60*e.getUTCMinutes(),r=e.getUTCSeconds();return c(Math.floor((n+t+r+3600)/86.4)%1e3,3)},g:function(){return r.G()%12||12},G:function(){return e.getHours()},h:function(){return c(r.g(),2)},H:function(){return c(r.G(),2)},i:function(){return c(e.getMinutes(),2)},s:function(){return c(e.getSeconds(),2)},u:function(){return c(1e3*e.getMilliseconds(),6)},e:function(){throw new Error("Not supported (see source code of date() for timezone on how to add support)")},I:function(){return new Date(r.Y(),0)-Date.UTC(r.Y(),0)!=new Date(r.Y(),6)-Date.UTC(r.Y(),6)?1:0},O:function(){var n=e.getTimezoneOffset(),t=Math.abs(n);return(n>0?"-":"+")+c(100*Math.floor(t/60)+t%60,4)},P:function(){var n=r.O();return n.substr(0,3)+":"+n.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-e.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(o,i)},r:function(){return"D, d M Y H:i:s O".replace(o,i)},U:function(){return e/1e3|0}};return function(n,t){return e=void 0===t?new Date:t instanceof Date?new Date(t):new Date(1e3*t),n.replace(o,i)}(n,t)},strtotime:function(text,now){var parsed,match,today,year,date,days,ranges,len,times,regex,i,fail=false;if(!text){return fail}text=text.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," ").replace(/[\t\r\n]/g,"").toLowerCase();match=text.match(/^(\d{1,4})([\-\.\/\:])(\d{1,2})([\-\.\/\:])(\d{1,4})(?:\s(\d{1,2}):(\d{2})?:?(\d{2})?)?(?:\s([A-Z]+)?)?$/);if(match&&match[2]===match[4]){if(match[1]>1901){switch(match[2]){case"-":if(match[3]>12||match[5]>31){return fail}return new Date(match[1],parseInt(match[3],10)-1,match[5],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000;case".":return fail;case"/":if(match[3]>12||match[5]>31){return fail}return new Date(match[1],parseInt(match[3],10)-1,match[5],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000}}else{if(match[5]>1901){switch(match[2]){case"-":if(match[3]>12||match[1]>31){return fail}return new Date(match[5],parseInt(match[3],10)-1,match[1],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000;case".":if(match[3]>12||match[1]>31){return fail}return new Date(match[5],parseInt(match[3],10)-1,match[1],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000;case"/":if(match[1]>12||match[3]>31){return fail}return new Date(match[5],parseInt(match[1],10)-1,match[3],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000}}else{switch(match[2]){case"-":if(match[3]>12||match[5]>31||(match[1]<70&&match[1]>38)){return fail}year=match[1]>=0&&match[1]<=38?+match[1]+2000:match[1];return new Date(year,parseInt(match[3],10)-1,match[5],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000;case".":if(match[5]>=70){if(match[3]>12||match[1]>31){return fail}return new Date(match[5],parseInt(match[3],10)-1,match[1],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000}if(match[5]<60&&!match[6]){if(match[1]>23||match[3]>59){return fail}today=new Date();return new Date(today.getFullYear(),today.getMonth(),today.getDate(),match[1]||0,match[3]||0,match[5]||0,match[9]||0)/1000}return fail;case"/":if(match[1]>12||match[3]>31||(match[5]<70&&match[5]>38)){return fail}year=match[5]>=0&&match[5]<=38?+match[5]+2000:match[5];return new Date(year,parseInt(match[1],10)-1,match[3],match[6]||0,match[7]||0,match[8]||0,match[9]||0)/1000;case":":if(match[1]>23||match[3]>59||match[5]>59){return fail}today=new Date();return new Date(today.getFullYear(),today.getMonth(),today.getDate(),match[1]||0,match[3]||0,match[5]||0)/1000}}}}if(text==="now"){return now===null||isNaN(now)?new Date().getTime()/1000|0:now|0}if(!isNaN(parsed=Date.parse(text))){return parsed/1000|0}date=now?new Date(now*1000):new Date();days={"sun":0,"mon":1,"tue":2,"wed":3,"thu":4,"fri":5,"sat":6};ranges={"yea":"FullYear","mon":"Month","day":"Date","hou":"Hours","min":"Minutes","sec":"Seconds"};function lastNext(type,range,modifier){var diff,day=days[range];if(typeof day!=="undefined"){diff=day-date.getDay();if(diff===0){diff=7*modifier}else{if(diff>0&&type==="last"){diff-=7}else{if(diff<0&&type==="next"){diff+=7}}}date.setDate(date.getDate()+diff)}}function process(val){var splt=val.split(" "),type=splt[0],range=splt[1].substring(0,3),typeIsNumber=/\d+/.test(type),ago=splt[2]==="ago",num=(type==="last"?-1:1)*(ago?-1:1);if(typeIsNumber){num*=parseInt(type,10)}if(ranges.hasOwnProperty(range)&&!splt[1].match(/^mon(day|\.)?$/i)){return date["set"+ranges[range]](date["get"+ranges[range]]()+num)}if(range==="wee"){return date.setDate(date.getDate()+(num*7))}if(type==="next"||type==="last"){lastNext(type,range,num)}else{if(!typeIsNumber){return false}}return true}times="(years?|months?|weeks?|days?|hours?|minutes?|min|seconds?|sec|sunday|sun\\.?|monday|mon\\.?|tuesday|tue\\.?|wednesday|wed\\.?|thursday|thu\\.?|friday|fri\\.?|saturday|sat\\.?)";regex="([+-]?\\d+\\s"+times+"|(last|next)\\s"+times+")(\\sago)?";match=text.match(new RegExp(regex,"gi"));if(!match){return fail}for(i=0,len=match.length;i<len;i++){if(!process(match[i])){return fail}}return(date.getTime()/1000)},date_eq:function(strDate1,strDate2){var date1=new Date(strDate1.replace(/\-/g,"\/"));var date2=new Date(strDate2.replace(/\-/g,"\/"));if((date1-date2)>=0){return true}else{return false}},timeline:function(tt){var today=new Date();var d=new Date(tt*1000);var m=today.getTime()-d.getTime();if(m<=0){m=1000}if(m<60*1000){return Math.floor(m/1000)+"秒前"}else{if(m<60*60*1000){return Math.floor(m/(1000*60))+"分钟前"}else{if(m<60*60*1000*24){return Math.floor(m/(1000*60*60))+"小时前"}else{if(m<60*60*1000*24*7){return Math.floor(m/(1000*60*60*24))+"天前"}else{if(m<60*60*1000*24*7*56){return Math.floor(m/(1000*60*60*24*7))+"周前"}else{return Math.floor(m/(1000*60*60*24*7*52))+"年前"}}}}}},getFirstNowLastDay:function(nowDate){var now=nowDate?new Date(nowDate):new Date();var strLink="-";var year=now.getFullYear();var month=now.getMonth()+1;var day=now.getDate();if(month>=1&&month<=9){month="0"+month}if(day>=1&&day<=9){day="0"+day}var yearMonth=year+strLink+month;var firstDate=year+strLink+month+strLink+'01';var sysDate=year+strLink+month+strLink+day;var lastDay=this.getLastDay(year,month);var lastDate=year+strLink+month+strLink+lastDay;return[firstDate,sysDate,lastDate,yearMonth]},getLastDay:function(year,month){var new_year=year;var new_month=month++;if(month>12){new_month-=12;new_year++}return new Date(new_year,new_month,0).getDate()},array_keys:function(r,n,a){var e=void 0!==n,o=[],t=!!a,i=!0,y="";for(y in r)r.hasOwnProperty(y)&&(i=!0,e&&(t&&r[y]!==n?i=!1:r[y]!==n&&(i=!1)),i&&(o[o.length]=y));return o},array_values:function(r){var n=[],a="";for(a in r)n[n.length]=r[a];return n},array_unique:function(r){var n="",t={},u="";for(n in r)r.hasOwnProperty(n)&&(u=r[n],!1===function(r,n){var t="";for(t in n)if(n.hasOwnProperty(t)&&n[t]+""==r+"")return t;return!1}(u,t)&&(t[n]=u));return t},array_slice:function(r,i,e,t){var o="";if("[object Array]"!==Object.prototype.toString.call(r)||t&&0!==i){var a=0,c={};for(o in r)a+=1,c[o]=r[o];r=c,i=i<0?a+i:i,e=void 0===e?a:e<0?a+e-i:e;var n={},l=!1,f=-1,s=0,v=0;for(o in r){if(++f,s>=e)break;f===i&&(l=!0),l&&(++s,is_int(o)&&!t?n[v++]=r[o]:n[o]=r[o])}return n}return void 0===e?r.slice(i):e>=0?r.slice(i,i+e):r.slice(i,e)},array_search:function(r,e,t){var n=!!t,i="";if("object"==typeof r&&r.exec){if(!n){var o="i"+(r.global?"g":"")+(r.multiline?"m":"")+(r.sticky?"y":"");r=new RegExp(r.source,o)}for(i in e)if(e.hasOwnProperty(i)&&r.test(e[i]))return i;return!1}for(i in e)if(e.hasOwnProperty(i)&&(n&&e[i]===r||!n&&e[i]==r))return i;return!1},is_array:function(t){if(!t||"object"!=typeof t)return!1;if(function(t){if(!t||"object"!=typeof t||"number"!=typeof t.length)return!1;var e=t.length;return t[t.length]="bogus",e!==t.length?(t.length-=1,!0):(delete t[t.length],!1)}(t))return!0;var e=Object.prototype.toString.call(t),n=function(t){var e=/\W*function\s+([\w$]+)\s*\(/.exec(t);return e?e[1]:"(Anonymous)"}(t.constructor);return"[object Object]"===e&&"Object"===n},in_array:function(r,n,i){var f="";if(!i){for(f in n)if(n[f]==r)return!0}else for(f in n)if(n[f]===r)return!0;return!1},sort:function(inputArr,sort_flags,strictForIn=true){var valArr=[],keyArr=[],k='',i=0,sorter=false,populateArr=[];switch(sort_flags){case'SORT_STRING':sorter=function(a,b){return strnatcmp(a,b)};break;case'SORT_NUMERIC':sorter=function(a,b){return(a-b)};break;default:sorter=function(a,b){var aFloat=parseFloat(a),bFloat=parseFloat(b),aNumeric=aFloat+''===a,bNumeric=bFloat+''===b;if(aNumeric&&bNumeric){return aFloat>bFloat?1:aFloat<bFloat?-1:0}else if(aNumeric&&!bNumeric){return 1}else if(!aNumeric&&bNumeric){return-1}return a>b?1:a<b?-1:0};break}populateArr=strictForIn?inputArr:populateArr;for(k in inputArr){if(inputArr.hasOwnProperty(k)){valArr.push(inputArr[k]);if(strictForIn){delete inputArr[k]}}}valArr.sort(sorter);for(i=0;i<valArr.length;i++){populateArr[i]=valArr[i]}return strictForIn||populateArr},is_int:function(i){return i===+i&&isFinite(i)&&!(i%1)},is_float:function(i){return!(+i!==i||isFinite(i)&&!(i%1))},is_object:function(t){return"[object Array]"!==Object.prototype.toString.call(t)&&(null!==t&&"object"==typeof t)},function_exists:function(n){var o="undefined"!=typeof window?window:global;return"string"==typeof n&&(n=o[n]),"function"==typeof n},serialize:function(r){var e,t,a,n="",o=0,i=function(r){var e,t,a,n,o=typeof r;if("object"===o&&!r)return"null";if("object"===o){if(!r.constructor)return"object";a=r.constructor.toString(),e=a.match(/(\w+)\(/),e&&(a=e[1].toLowerCase()),n=["boolean","number","string","array"];for(t in n)if(a==n[t]){o=n[t];break}}return o},c=i(r);switch(c){case"function":e="";break;case"boolean":e="b:"+(r?"1":"0");break;case"number":e=(Math.round(r)==r?"i":"d")+":"+r;break;case"string":e="s:"+function(r){var e=0,t=0,a=r.length,n="";for(t=0;t<a;t++)n=r.charCodeAt(t),e+=n<128?1:n<2048?2:3;return e}(r)+':"'+r+'"';break;case"array":case"object":e="a";for(t in r)if(r.hasOwnProperty(t)){if("function"===i(r[t]))continue;a=t.match(/^[0-9]+$/)?parseInt(t,10):t,n+=this.serialize(a)+this.serialize(r[t]),o++}e+=":"+o+":{"+n+"}";break;case"undefined":default:e="N"}return"object"!==c&&"array"!==c&&(e+=";"),e},unserialize:function(r){var e=this,n=function(r){var e=r.charCodeAt(0);return e<128?0:e<2048?1:2};return error=function(r,n,a,t){throw new e.window[r](n,a,t)},read_until=function(r,e,n){for(var a=2,t=[],i=r.slice(e,e+1);i!=n;)a+e>r.length&&error("Error","Invalid"),t.push(i),i=r.slice(e+(a-1),e+a),a+=1;return[t.length,t.join("")]},read_chrs=function(r,e,a){var t,i,u;for(u=[],t=0;t<a;t++)i=r.slice(e+(t-1),e+t),u.push(i),a-=n(i);return[u.length,u.join("")]},_unserialize=function(r,e){var n,a,t,i,u,s,o,l,c,d,f,h,_,p,w,b,k,g,v=0,I=function(r){return r};switch(e||(e=0),n=r.slice(e,e+1).toLowerCase(),a=e+2,n){case"i":I=function(r){return parseInt(r,10)},c=read_until(r,a,";"),v=c[0],l=c[1],a+=v+1;break;case"b":I=function(r){return 0!==parseInt(r,10)},c=read_until(r,a,";"),v=c[0],l=c[1],a+=v+1;break;case"d":I=function(r){return parseFloat(r)},c=read_until(r,a,";"),v=c[0],l=c[1],a+=v+1;break;case"n":l=null;break;case"s":d=read_until(r,a,":"),v=d[0],f=d[1],a+=v+2,c=read_chrs(r,a+1,parseInt(f,10)),v=c[0],l=c[1],a+=v+2,v!=parseInt(f,10)&&v!=l.length&&error("SyntaxError","String length mismatch");break;case"a":for(l={},t=read_until(r,a,":"),v=t[0],i=t[1],a+=v+2,s=parseInt(i,10),u=!0,h=0;h<s;h++)p=_unserialize(r,a),w=p[1],_=p[2],a+=w,b=_unserialize(r,a),k=b[1],g=b[2],a+=k,_!==h&&(u=!1),l[_]=g;if(u){for(o=new Array(s),h=0;h<s;h++)o[h]=l[h];l=o}a+=1;break;default:error("SyntaxError","Unknown / Unhandled data type(s): "+n)}return[n,a-e,I(l)]},_unserialize(r+"",0)[2]},uniqid:function(n,e){void 0===n&&(n="");var t,i=function(n,e){return n=parseInt(n,10).toString(16),e<n.length?n.slice(n.length-e):e>n.length?Array(e-n.length+1).join("0")+n:n},o="undefined"!=typeof window?window:global;o.$locutus=o.$locutus||{};var d=o.$locutus;return d.php=d.php||{},d.php.uniqidSeed||(d.php.uniqidSeed=Math.floor(123456789*Math.random())),d.php.uniqidSeed++,t=n,t+=i(parseInt((new Date).getTime()/1e3,10),8),t+=i(d.php.uniqidSeed,5),e&&(t+=(10*Math.random()).toFixed(8).toString()),t},intval:function(i,t){var n,a,e=typeof i;return"boolean"===e?+i:"string"===e?(0===t&&(a=i.match(/^\s*0(x?)/i),t=a?a[1]?16:8:10),n=parseInt(i,t||10),isNaN(n)||!isFinite(n)?0:n):"number"===e&&isFinite(i)?i<0?Math.ceil(i):Math.floor(i):0},floatval:function(a){return parseFloat(a)||0},log:function(arr){console.log(arr)},trim:function(r,n){var t=[" ","\n","\r","\t","\f","\v"," "," "," "," "," "," "," "," "," "," "," "," ","​","\u2028","\u2029"," "].join(""),e=0,i=0;for(r+="",n&&(t=(n+"").replace(/([[\]().?\/*{}+$^:])/g,"$1")),e=r.length,i=0;i<e;i++)if(-1===t.indexOf(r.charAt(i))){r=r.substring(i);break}for(e=r.length,i=e-1;i>=0;i--)if(-1===t.indexOf(r.charAt(i))){r=r.substring(0,i+1);break}return-1===t.indexOf(r.charAt(0))?r:""},rtrim:function(e,r){return r=r?(r+"").replace(/([[\]().?\/*{}+$^:])/g,"\\$1"):" \\s ",(e+"").replace(new RegExp("["+r+"]+$","g"),"")},ltrim:function(e,r){return r=r?(r+"").replace(/([[\]().?\/*{}+$^:])/g,"$1"):" \\s ",(e+"").replace(new RegExp("^["+r+"]+","g"),"")},strtrim:function(a){return a.replace(/\s+/g," ")},str_replace:function(t,o,e,c){var r=0,l=0,n="",a="",i=0,p=0,u=[].concat(t),f=[].concat(o),g=e,y="[object Array]"===Object.prototype.toString.call(f),b="[object Array]"===Object.prototype.toString.call(g);g=[].concat(g);var j="undefined"!=typeof window?window:global;j.$locutus=j.$locutus||{};var v=j.$locutus;if(v.php=v.php||{},"object"==typeof t&&"string"==typeof o){for(n=o,o=[],r=0;r<t.length;r+=1)o[r]=n;n="",f=[].concat(o),y="[object Array]"===Object.prototype.toString.call(f)}for(void 0!==c&&(c.value=0),r=0,i=g.length;r<i;r++)if(""!==g[r])for(l=0,p=u.length;l<p;l++)n=g[r]+"",a=y?void 0!==f[l]?f[l]:"":f[0],g[r]=n.split(u[l]).join(a),void 0!==c&&(c.value+=n.split(u[l]).length-1);return b?g:g[0]},strip_tags:function(input,allowed){allowed=(((allowed||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");var tags=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,commentsAndPhpTags=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;return input.replace(commentsAndPhpTags,"").replace(tags,function($0,$1){return allowed.indexOf("<"+$1.toLowerCase()+">")>-1?$0:""})},ucfirst:function(t){return t+="",t.charAt(0).toUpperCase()+t.substr(1)},htmlencode:function(sStr){var htmlspecialchars=function(e,E,T,_){var r=0,t=0,a=!1;("undefined"==typeof E||null===E)&&(E=2),e=e.toString(),_!==!1&&(e=e.replace(/&/g,"&amp;")),e=e.replace(/</g,"&lt;").replace(/>/g,"&gt;");var N={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===E&&(a=!0),"number"!=typeof E){for(E=[].concat(E),t=0;t<E.length;t++)0===N[E[t]]?a=!0:N[E[t]]&&(r|=N[E[t]]);E=r}return E&N.ENT_HTML_QUOTE_SINGLE&&(e=e.replace(/'/g,"&#039;")),a||(e=e.replace(/"/g,"&quot;")),e};return htmlspecialchars(sStr)},htmldecode:function(sStr){var htmlspecialchars_decode=function(e,E){var T=0,_=0,r=!1;"undefined"==typeof E&&(E=2),e=e.toString().replace(/&lt;/g,"<").replace(/&gt;/g,">");var t={ENT_NOQUOTES:0,ENT_HTML_QUOTE_SINGLE:1,ENT_HTML_QUOTE_DOUBLE:2,ENT_COMPAT:2,ENT_QUOTES:3,ENT_IGNORE:4};if(0===E&&(r=!0),"number"!=typeof E){for(E=[].concat(E),_=0;_<E.length;_++)0===t[E[_]]?r=!0:t[E[_]]&&(T|=t[E[_]]);E=T}return E&t.ENT_HTML_QUOTE_SINGLE&&(e=e.replace(/&#0*39;/g,"'")),r||(e=e.replace(/&quot;/g,'"')),e=e.replace(/&amp;/g,"&")};return htmlspecialchars_decode(sStr)},escape:function(html){var exp=/[<"'>]|&(?=#[a-zA-Z0-9]+)/g;if(html===undefined||html===null)return'';html+='';if(!exp.test(html))return html;return html.replace(/&(?!#?[a-zA-Z0-9]+;)/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/'/g,'&#39;').replace(/"/g,'&quot;')},unescape:function(html){if(html===undefined||html===null)html='';html+='';return html.replace(/\&amp;/g,'&').replace(/\&lt;/g,'<').replace(/\&gt;/g,'>').replace(/\&#39;/g,'\'').replace(/\&quot;/g,'"')},base64_decode:function(n){var r=function(n){return decodeURIComponent(n.split("").map(function(n){return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)}).join(""))};if("undefined"==typeof window)return new Buffer(n,"base64").toString("utf-8");if(void 0!==window.atob)return r(window.atob(n));var e,t,o,i,d,f,a,c,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,w=0,C="",g=[];if(!n)return n;n+="";do{i=u.indexOf(n.charAt(h++)),d=u.indexOf(n.charAt(h++)),f=u.indexOf(n.charAt(h++)),a=u.indexOf(n.charAt(h++)),c=i<<18|d<<12|f<<6|a,e=c>>16&255,t=c>>8&255,o=255&c,g[w++]=64===f?String.fromCharCode(e):64===a?String.fromCharCode(e,t):String.fromCharCode(e,t,o)}while(h<n.length);return C=g.join(""),r(C.replace(/\0+$/,""))},base64_encode:function(e){var r=function(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,r){return String.fromCharCode("0x"+r)})};if("undefined"==typeof window)return new Buffer(e).toString("base64");if(void 0!==window.btoa)return window.btoa(r(e));var n,t,o,i,a,c,d,f,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,w=0,A="",l=[];if(!e)return e;e=r(e);do{n=e.charCodeAt(u++),t=e.charCodeAt(u++),o=e.charCodeAt(u++),f=n<<16|t<<8|o,i=f>>18&63,a=f>>12&63,c=f>>6&63,d=63&f,l[w++]=h.charAt(i)+h.charAt(a)+h.charAt(c)+h.charAt(d)}while(u<e.length);A=l.join("");var C=e.length%3;return(C?A.slice(0,C-3):A)+"===".slice(C||3)},urlencode:function(e){return e+="",encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/~/g,"%7E").replace(/%20/g,"+")},urldecode:function(e){return decodeURIComponent((e+"").replace(/%(?![\da-f]{2})/gi,function(){return"%25"}).replace(/\+/g,"%20"))},unicode_decode:function(e){return e=e.replace(/\\/g,"%"),unescape(e)},unicode_encode:function(n){if(1==(arguments.length>1&&void 0!==arguments[1]&&arguments[1])){for(var r=[],t=0;t<n.length;t++)r[t]=("00"+n.charCodeAt(t).toString(16)).slice(-4);return"\\u"+r.join("\\u")}var e=function(n){for(var r=[],t=0;t<n.length;t++)r[t]=("00"+n.charCodeAt(t).toString(16)).slice(-4);return"\\u"+r.join("\\u")},u=/[\ud800-\udbff][\udc00-\udfff]/g;return n=n.replace(u,function(n){return 2===n.length?e(n):n})},get_params:function(c){var e=c+"=",b=window.location.href,h=b.indexOf("?"),b=b.slice(h+1),a=b.split("&"),d=0,f="",g=a.length;for(d=0;d<g;d++){var f=a[d];if(f.indexOf(e)===0){return decodeURIComponent(f.slice(e.length).replace(/\+/g,"%20"))}}return null},mt_rand:function(r,e){var n=arguments.length;if(0===n)r=0,e=2147483647;else{if(1===n)throw new Error("Warning: mt_rand() expects exactly 2 parameters, 1 given");r=parseInt(r,10),e=parseInt(e,10)}return Math.floor(Math.random()*(e-r+1))+r},rand:function(r,e){var n=arguments.length;if(0===n)r=0,e=2147483647;else if(1===n)throw new Error("Warning: rand() expects exactly 2 parameters, 1 given");return Math.floor(Math.random()*(e-r+1))+r},strcut:function(str,iMaxBytes,sSuffix){if(isNaN(iMaxBytes)){return str}if(strlen(str)<=iMaxBytes){return str}var i=0,bytes=0;for(;i<str.length&&bytes<iMaxBytes;++i,++bytes){if(str.charCodeAt(i)>255){++bytes}}sSuffix=sSuffix||"";return(bytes-iMaxBytes==1?str.substr(0,i-1):str.substr(0,i))+sSuffix},strfind:function(string,find){return!(string.indexOf(find)===-1)},is_num:function(num){var reg=new RegExp("^[0-9]*$");return reg.test(num)},is_mobile:function(num){var reg=/^1\d{10}$/;return reg.test(num)},is_qq:function(num){var reg=/^[1-utf8_decode]{1}\d{4,11}$/;return reg.test(num)},is_email:function(str){var reg=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;return reg.test(str)},is_chinese:function(num){var reg=/[\u4e00-\u9fa5]/g;return reg.test(num)},is_reg:function(num){var reg=/^([a-zA-z_]{1})([\w]*)$/g;return reg.test(num)},is_tel:function(str){var reg=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;return reg.test(str)},is_ip:function(strIP){if(isNull(strIP)){return false}var re=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g;if(re.test(strIP)){if(RegExp.$1<256&&RegExp.$2<256&&RegExp.$3<256&&RegExp.$4<256){return true}}return false},is_zipcode:function(str){var reg=/^(\d){6}$/;return reg.test(str)},is_english:function(str){var reg=/^[A-Za-z]+$/;return reg.test(str)},is_url:function(url){var strRegex=/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;var re=new RegExp(strRegex);return re.test(url)},is_http:function(url){if(url.indexOf("http://")===-1&&url.indexOf("https://")===-1){return false}return true},is_money:function(n){return!!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(n)},is_CardNumber:function(num){return num.toString().replace(/\s/g,'').replace(/(.{4})/g,"$1 ")},is_IDCard:function(idcode){var weight_factor=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];var check_code=['1','0','X','9','8','7','6','5','4','3','2','x'];var code=idcode+"";var last=idcode[17];var seventeen=code.substring(0,17);var arr=seventeen.split("");var len=arr.length;var num=0;for(var i=0;i<len;i++){num=num+arr[i]*weight_factor[i]}var resisue=num%11;var last_no=check_code[resisue];var idcard_patter=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;var format=idcard_patter.test(idcode);return last===last_no&&format},in_int:function(n,iMin,iMax){if(!isFinite(n)){return false}if(!/^[+-]?\d+$/.test(n)){return false}if(iMin!=undefined&&parseInt(n)<parseInt(iMin)){return false}if(iMax!=undefined&&parseInt(n)>parseInt(iMax)){return false}return true},in_float:function(n,fMin,fMax){if(!isFinite(n)){return false}if(fMin!=undefined&&parseFloat(n)<parseFloat(fMin)){return false}if(fMax!=undefined&&parseFloat(n)>parseFloat(fMax)){return false}return true},number_format:function(e,n,t,i){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var r=isFinite(+e)?+e:0,o=isFinite(+n)?Math.abs(n):0,a=void 0===i?",":i,d=void 0===t?".":t,u="";return u=(o?function(e,n){if(-1===(""+e).indexOf("e"))return+(Math.round(e+"e+"+n)+"e-"+n);var t=(""+e).split("e"),i="";return+t[1]+n>0&&(i="+"),(+(Math.round(+t[0]+"e"+i+(+t[1]+n))+"e-"+n)).toFixed(n)}(r,o).toString():""+Math.round(r)).split("."),u[0].length>3&&(u[0]=u[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,a)),(u[1]||"").length<o&&(u[1]=u[1]||"",u[1]+=new Array(o-u[1].length+1).join("0")),u.join(d)},digit:function(num,length){var str='';num=String(num);length=length||2;for(var i=num.length;i<length;i++){str+='0'}return num<Math.pow(10,length)?str+(num|0):num},upDigit:function(num,is_head=false){var fraction=['角','分','厘'];var digit=['零','壹','贰','叁','肆','伍','陆','柒','捌','玖'];var unit=[['元','万','亿'],['','拾','佰','仟']];var head=num<0?'欠人民币':'人民币';num=Math.abs(num);var s='',i;for(i=0;i<fraction.length;i++){s+=(digit[Math.floor(num*10*Math.pow(10,i))%10]+fraction[i]).replace(/零./,'')}s=s||'整';num=Math.floor(num);for(i=0;i<unit[0].length&&num>0;i++){var p='';for(var j=0;j<unit[1].length&&num>0;j++){p=digit[num%10]+unit[1][j]+p;num=Math.floor(num/10)}s=p.replace(/(零.)*零$/,'').replace(/^$/,'零')+unit[0][i]+s}if(is_head==true){return head+s.replace(/(零.)*零元/,'元').replace(/(零.)+/g,'零').replace(/^整$/,'零元整')}else{return s.replace(/(零.)*零元/,'元').replace(/(零.)+/g,'零').replace(/^整$/,'零元整')}},hidebank:function(s="6217995510035399947"){return s.replace(/^(\d{8})\d+(\d{4})$/,"$1*******$2")},hidemobile:function(s="18291447788"){return s.replace(/^(\d{3})\d+(\d{4})$/,"$1****$2")},addcss:function(e){var t=document.createElement("style"),d=document.head||document.getElementsByTagName("head")[0];if(t.type="text/css",t.styleSheet){var a=function(){try{t.styleSheet.cssText=e}catch(e){}};t.styleSheet.disabled?setTimeout(a,10):a()}else{var s=document.createTextNode(e);t.appendChild(s)}d.appendChild(t)},addjs:function(t){var e=document.createElement("script");e.type="text/javascript";try{e.appendChild(document.createTextNode(t))}catch(d){e.text=t}document.head.appendChild(e)},loadjs:function(e,a){var t=document.createElement("script");t.src=e,t.onload=function(){var e=t.readyState&&"complete"!=t.readyState&&"loaded"!=t.readyState;a&&a(!e)},document.head.appendChild(t)},loadcss:function(e,n){var t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.onerror=function(){n(!1)},t.onload=function(){n(!0)},t.href=e,document.head.appendChild(t)},gethost:function(){return window.location.protocol+"//"+window.location.host},distance:function(latlngFirst,latlngLast){var La1=latlngFirst.lat*Math.PI/180.0;var La2=latlngLast.lat*Math.PI/180.0;var La3=La1-La2;var Lb3=latlngFirst.lng*Math.PI/180.0-latlngLast.lng*Math.PI/180.0;var dis=2*Math.asin(Math.sqrt(Math.pow(Math.sin(La3/2),2)+Math.cos(La1)*Math.cos(La2)*Math.pow(Math.sin(Lb3/2),2)));dis=dis*6378.137;dis=Math.round(dis*10000)/10000;return dis.toFixed(2)},setCookie:function(name,value,iDay){var oDate=new Date();oDate.setDate(oDate.getDate()+iDay);document.cookie=name+'='+value+';expires='+oDate},getCookie:function(name){var arr=document.cookie.split('; ');for(var i=0;i<arr.length;i++){var arr2=arr[i].split('=');if(arr2[0]==name){return arr2[1]}}return''},removeCookie:function(name){this.setCookie(name,1,-1)},computeProgres:function(thisNum,totalNum){var num=parseFloat(thisNum)||0.00,total=parseFloat(totalNum)||0.00;return Math.round(num/total*10000)/100},token:function(length){length=length||32;var char='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';var result='';for(var i=0;i<length;i++){result+=char.charAt(Math.floor(Math.random()*char.length))}return result}};$('body').on('click','.link-a',function(){let url=$(this).data('href');if(url&&url!==''){window.location.replace(url)}return false});exports('tool',tool)});
  3. //加载
  4. window.rootPath = (function (src) {
  5. src = document.currentScript ? document.currentScript.src : document.scripts[document.scripts.length - 1].src;
  6. let src_array = src.split('?v=');
  7. if (src_array.length == 2) {
  8. window.webVersion = src_array[1];
  9. }
  10. return src.substring(0, src.lastIndexOf("/") + 1);
  11. })();
  12. if (typeof jQuery === "undefined") {
  13. console.error('请引入jQuery')
  14. }
  15. if (typeof moduleInit == "undefined") {
  16. window.moduleInit = [];
  17. }
  18. mbui.config({
  19. base: rootPath + "module/",
  20. version: window.webVersion ? window.webVersion : '58'
  21. }).use(moduleInit, function () {
  22. if (typeof mbuiInit === 'function') {
  23. mbuiInit();
  24. }
  25. });