2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
|
(function(){var e;e=function(){function f(g,h){this['startInterval']=0xea60,this['init'](g,h);}return f['prototype']['init']=function(i,j){return this['$element']=$(i),this['options']=$['extend']({},$['fn']['timeago']['defaults'],j),this['updateTime'](),this['startTimer']();},f['prototype']['startTimer']=function(){var f;return f=this,this['interval']=setInterval(function(){return f['refresh']();},this['startInterval']);},f['prototype']['stopTimer']=function(){return clearInterval(this['interval']);},f['prototype']['restartTimer']=function(){return this['stopTimer'](),this['startTimer']();},f['prototype']['refresh']=function(){return this['updateTime'](),this['updateInterval']();},f['prototype']['updateTime']=function(){var f;return f=this,this['$element']['findAndSelf'](this['options']['selector'])['each'](function(){var m;return m=f['timeAgoInWords']($(this)['attr'](f['options']['attr'])),$(this)['html'](m);});},f['prototype']['updateInterval']=function(){var f,o,p,q;if(this['$element']['findAndSelf'](this['options']['selector'])['length']>0x0){if('up'===this['options']['dir']?f=':first':'down'===this['options']['dir']&&(f=':last'),q=this['$element']['findAndSelf'](this['options']['selector'])['filter'](f)['attr'](this['options']['attr']),o=this['parse'](q),(p=this['getTimeDistanceInMinutes'](o))>=0x0&&p<=0x2c&&0xea60!==this['startInterval'])return this['startInterval']=0xea60,this['restartTimer']();if(p>=0x2d&&p<=0x59&&0x142440!==this['startInterval'])return this['startInterval']=0x142440,this['restartTimer']();if(p>=0x5a&&p<=0x9d7&&0x1b7740!==this['startInterval'])return this['startInterval']=0x1b7740,this['restartTimer']();if(p>=0x9d8&&0x2932e00!==this['startInterval'])return this['startInterval']=0x2932e00,this['restartTimer']();}},f['prototype']['timeAgoInWords']=function(r){var s;return s=this['parse'](r),''+this['options']['lang']['prefixes']['ago']+this['distanceOfTimeInWords'](s);},f['prototype']['parse']=function(t){var u;return u=(u=(u=(u=(u=$['trim'](t))['replace'](/\.\d\d\d+/,''))['replace'](/-/,'/')['replace'](/-/,'/'))['replace'](/T/,'\x20')['replace'](/Z/,'\x20UTC'))['replace'](/([\+\-]\d\d)\:?(\d\d)/,'\x20$1$2'),new Date(u);},f['prototype']['getTimeDistanceInMinutes']=function(v){var w;return w=new Date()['getTime']()-v['getTime'](),Math['round'](Math['abs'](w)/0x3e8/0x3c);},f['prototype']['distanceOfTimeInWords']=function(x){var y;return 0x0===(y=this['getTimeDistanceInMinutes'](x))?''+this['options']['lang']['prefixes']['lt']:0x1===y?'1\x20'+this['options']['lang']['units']['minute']+this['options']['lang']['suffix']:y>=0x2&&y<=0x2c?y+'\x20'+this['options']['lang']['units']['minutes']+this['options']['lang']['suffix']:y>=0x2d&&y<=0x59?'\x201\x20'+this['options']['lang']['units']['hour']+this['options']['lang']['suffix']:y>=0x5a&&y<=0x59f?'\x20'+Math['round'](y/0x3c)+'\x20'+this['options']['lang']['units']['hours']+this['options']['lang']['suffix']:y>=0x5a0&&y<=0x9d7?'1\x20'+this['options']['lang']['units']['day']:y>=0x9d8&&y<=0xa8bf?Math['round'](y/0x5a0)+'\x20'+this['options']['lang']['units']['days']+this['options']['lang']['suffix']:y>=0xa8c0&&y<=0x1517f?'\x201\x20'+this['options']['lang']['units']['month']+this['options']['lang']['suffix']:y>=0x15180&&y<=0x8051f?Math['round'](y/0xa8c0)+'\x20'+this['options']['lang']['units']['months']+this['options']['lang']['suffix']:y>=0x80520&&y<=0x9ff5f?'\x201\x20'+this['options']['lang']['units']['year']+this['options']['lang']['suffix']:y>=0x9ff60&&y<=0xdf3df?this['options']['lang']['prefixes']['over']+'\x201\x20'+this['options']['lang']['units']['year']+this['options']['lang']['suffix']:y>=0xdf3e0&&y<=0x100a3f?this['options']['lang']['prefixes']['almost']+'\x202\x20'+this['options']['lang']['units']['years']+this['options']['lang']['suffix']:'\x20'+Math['round'](y/0x80520)+'\x20'+this['options']['lang']['units']['years']+this['options']['lang']['suffix'];},f;}(),$['fn']['timeago']=function(z){return null==z&&(z={}),this['each'](function(){var A,B;return(B=(A=$(this))['data']('timeago'))?'string'==typeof z?B[z]():void 0x0:A['data']('timeago',new e(this,z))
|