PageSourceSearch

https://sempreinter.com/wp-content/cache/min/1/wp-content/themes/f…/static/js/timeago.js?ver=1789984249

js sempreinter.com collected 2026-09-24 21:13:26 UTC 3,545 bytes, 14 lines download raw bytes

1!function(root,factory){if(typeof module==='object'&&module.exports){module.exports=factory(root);module.exports['default']=module.exports}else root.timeago=factory(root)}(typeof window!=='undefined'?window:this,function(){var indexMapEn='second_minute_hour_day_week_month_year'.split('_'),indexMapZh='秒_分钟_小时_天_周_月_年'.split('_'),locales={'en':function(number,index){if(index===0)return['just now','right now'];var unit=indexMapEn[parseInt(index/2)];if(number>1)unit+='s';return[number+' '+unit+' ago','in '+number+' '+unit]},'zh_CN':function(number,index){if(index===0)return['刚刚','片刻后'];var unit=indexMapZh[parseInt(index/2)];return[number+unit+'前',number+unit+'后']}},SEC_ARRAY=[60,60,24,7,365/7/12,12],SEC_ARRAY_LEN=6,ATTR_DATETIME='datetime',ATTR_DATA_TID='data-tid',timers={};function toDate(input){if(input instanceof Date)return input;if(!isNaN(input))return new Date(toInt(input));if(/^\d+$/.test(input))return new Date(toInt(input));input=(input||'').trim().replace(/\.\d+/,'').replace(/-/,'/').replace(/-/,'/').replace(/(\d)T(\d)/,'$1 $2').replace(/Z/,' UTC').replace(/([\+\-]\d\d)\:?(\d\d)/,' $1$2');return new Date(input)}
2function toInt(f){return parseInt(f)}
3function formatDiff(diff,locale,defaultLocale){locale=locales[locale]?locale:(locales[defaultLocale]?defaultLocale:'en');var i=0,agoin=diff<0?1:0,total_sec=diff=Math.abs(diff);for(;diff>=SEC_ARRAY[i]&&i<SEC_ARRAY_LEN;i++){diff/=SEC_ARRAY[i]}
4diff=toInt(diff);i*=2;if(diff>(i===0?9:1))i+=1;return locales[locale](diff,i,total_sec)[agoin].replace('%s',diff)}
5function diffSec(date,nowDate){nowDate=nowDate?toDate(nowDate):new Date();return(nowDate-toDate(date))/1000}
6function nextInterval(diff){var rst=1,i=0,d=Math.abs(diff);for(;diff>=SEC_ARRAY[i]&&i<SEC_ARRAY_LEN;i++){diff/=SEC_ARRAY[i];rst*=SEC_ARRAY[i]}
7d=d%rst;d=d?rst-d:rst;return Math.ceil(d)}
8function getDateAttr(node){if(node.dataset&&node.dataset.timeago)return node.dataset.timeago;return getAttr(node,ATTR_DATETIME)}
9function getAttr(node,name){if(node.getAttribute)return node.getAttribute(name);if(node.attr)return node.attr(name)}
10function setTidAttr(node,val){if(node.setAttribute)return node.setAttribute(ATTR_DATA_TID,val);if(node.attr)return node.attr(ATTR_DATA_TID,val)}
11function getTidFromNode(node){return getAttr(node,ATTR_DATA_TID)}
12function Timeago(nowDate,defaultLocale){this.nowDate=nowDate;this.defaultLocale=defaultLocale||'en'}
13Timeago.prototype.doRender=function(node,date,locale){var diff=diffSec(date,this.nowDate),self=this,tid;node.innerHTML=formatDiff(diff,locale,this.defaultLocale);node.setAttribute('title',toDate(date).toLocaleString('en-GB'));timers[tid=setTimeout(function(){self.doRender(node,date,locale);delete timers[tid]},Math.min(nextInterval(diff)*1000,0x7FFFFFFF))]=0;setTidAttr(node,tid)};Timeago.prototype.format=function(date,locale){return formatDiff(diffSec(date,this.nowDate),locale,this.defaultLocale)};Timeago.prototype.render=function(nodes,locale){if(nodes.length===undefined)nodes=[nodes];for(var i=0,len=nodes.length;i<len;i++){this.doRender(nodes[i],getDateAttr(nodes[i]),locale)}};Timeago.prototype.setLocale=function(locale){this.defaultLocale=locale};function timeagoFactory(nowDate,defaultLocale){return new Timeago(nowDate,defaultLocale)}
14timeagoFactory.register=function(locale,localeFunc){locales[locale]=localeFunc};timeagoFactory.cancel=function(node){var tid;if(node){tid=getTidFromNode(node);if(tid){clearTimeout(tid);delete timers[tid]}}else{for(tid in timers)clearTimeout(tid);timers={}}};return timeagoFactory})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.