github.com/drone/runner-go@v1.12.0/handler/static/files/timeago.js (about) 1 !function(t, e) { 2 "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e(t.timeago = {}) 3 }(this, function(t) { 4 "use strict"; 5 var f = [60, 60, 24, 7, 365 / 7 / 12, 12] 6 , o = function(t) { 7 return parseInt(t) 8 } 9 , n = function(t) { 10 return t instanceof Date ? t : !isNaN(t) || /^\d+$/.test(t) ? new Date(o(t)) : (t = (t || "").trim().replace(/\.\d+/, "").replace(/-/, "/").replace(/-/, "/").replace(/(\d)T(\d)/, "$1 $2").replace(/Z/, " UTC").replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"), 11 new Date(t)) 12 } 13 , s = function(t, e) { 14 for (var n = 0, r = t < 0 ? 1 : 0, a = t = Math.abs(t); f[n] <= t && n < f.length; n++) 15 t /= f[n]; 16 return (0 === (n *= 2) ? 9 : 1) < (t = o(t)) && (n += 1), 17 e(t, n, a)[r].replace("%s", t) 18 } 19 , d = function(t, e) { 20 return ((e = e ? n(e) : new Date) - n(t)) / 1e3 21 } 22 , r = "second_minute_hour_day_week_month_year".split("_") 23 , a = "秒_分钟_小时_天_周_个月_年".split("_") 24 , e = function(t, e) { 25 if (0 === e) 26 return ["just now", "right now"]; 27 var n = r[parseInt(e / 2)]; 28 return 1 < t && (n += "s"), 29 ["".concat(t, " ").concat(n, " ago"), "in ".concat(t, " ").concat(n)] 30 } 31 , i = { 32 en_US: e, 33 zh_CN: function(t, e) { 34 if (0 === e) 35 return ["刚刚", "片刻后"]; 36 var n = a[parseInt(e / 2)]; 37 return ["".concat(t, " ").concat(n, "前"), "".concat(t, " ").concat(n, "后")] 38 } 39 } 40 , c = function(t) { 41 return i[t] || e 42 } 43 , l = "timeago-tid" 44 , u = function(t, e) { 45 return t.getAttribute ? t.getAttribute(e) : t.attr ? t.attr(e) : void 0 46 } 47 , p = function(t) { 48 return u(t, l) 49 } 50 , _ = {} 51 , v = function(t) { 52 clearTimeout(t), 53 delete _[t] 54 } 55 , h = function t(e, n, r, a) { 56 v(p(e)); 57 var o = d(n, a); 58 e.innerHTML = s(o, r); 59 var i, c, u = setTimeout(function() { 60 t(e, n, r, a) 61 }, 1e3 * function(t) { 62 for (var e = 1, n = 0, r = Math.abs(t); f[n] <= t && n < f.length; n++) 63 t /= f[n], 64 e *= f[n]; 65 return r = (r %= e) ? e - r : e, 66 Math.ceil(r) 67 }(o), 2147483647); 68 _[u] = 0, 69 c = u, 70 (i = e).setAttribute ? i.setAttribute(l, c) : i.attr && i.attr(l, c) 71 }; 72 t.version = "4.0.0-beta.2", 73 t.format = function(t, e, n) { 74 var r = d(t, n); 75 return s(r, c(e)) 76 } 77 , 78 t.render = function(t, e, n) { 79 var r; 80 void 0 === t.length && (t = [t]); 81 for (var a = 0; a < t.length; a++) { 82 r = t[a]; 83 var o = u(r, "datetime") 84 , i = c(e); 85 h(r, o, i, n) 86 } 87 return t 88 } 89 , 90 t.cancel = function(t) { 91 if (t) 92 v(p(t)); 93 else 94 for (var e in _) 95 v(e) 96 } 97 , 98 t.register = function(t, e) { 99 i[t] = e 100 } 101 , 102 Object.defineProperty(t, "__esModule", { 103 value: !0 104 }) 105 });