PageSourceSearch

https://yahida.com/wp-content/themes/bimber/js/jquery.timeago/jquery.timeago_ver-1.5.2.js

js yahida.com collected 2026-10-04 01:55:41 UTC 7,961 bytes, 235 lines download raw bytes

vendor: 7,961 bytes, lines 1-235
1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10/**
11 * Timeago is a jQuery plugin that makes it easy to support automatically
12 * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
13 *
14 * @name timeago
15 * @version 1.5.2
16 * @requires jQuery v1.2.3+
17 * @author Ryan McGeary
18 * @license MIT License - http://www.opensource.org/licenses/mit-license.php
19 *
20 * For usage and examples, visit:
21 * http://timeago.yarp.com/
22 *
23 * Copyright (c) 2008-2015, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
24 */
25
26(function (factory) {
27  if (typeof define === 'function' && define.amd) {
28    // AMD. Register as an anonymous module.
29    define(['jquery'], factory);
30  } else if (typeof module === 'object' && typeof module.exports === 'object') {
31    factory(require('jquery'));
32  } else {
33    // Browser globals
34    factory(jQuery);
35  }
36}(function ($) {
37  $.timeago = function(timestamp) {
38    if (timestamp instanceof Date) {
39      return inWords(timestamp);
40    } else if (typeof timestamp === "string") {
41      return inWords($.timeago.parse(timestamp));
42    } else if (typeof timestamp === "number") {
43      return inWords(new Date(timestamp));
44    } else {
45      return inWords($.timeago.datetime(timestamp));
46    }
47  };
48  var $t = $.timeago;
49
50  $.extend($.timeago, {
51    settings: {
52      refreshMillis: 60000,
53      allowPast: true,
54      allowFuture: false,
55      localeTitle: false,
56      cutoff: 0,
57      autoDispose: true,
58      strings: {
59        prefixAgo: null,
60        prefixFromNow: null,
61        suffixAgo: "ago",
62        suffixFromNow: "from now",
63        inPast: 'any moment now',
64        seconds: "less than a minute",
65        minute: "about a minute",
66        minutes: "%d minutes",
67        hour: "about an hour",
68        hours: "about %d hours",
69        day: "a day",
70        days: "%d days",
71        month: "about a month",
72        months: "%d months",
73        year: "about a year",
74        years: "%d years",
75        wordSeparator: " ",
76        numbers: []
77      }
78    },
79
80    inWords: function(distanceMillis) {
81      if (!this.settings.allowPast && ! this.settings.allowFuture) {
82        throw 'timeago allowPast and allowFuture settings can not both be set to false.';
83      }
84
85      var $l = this.settings.strings;
86      var prefix = $l.prefixAgo;
87      var suffix = $l.suffixAgo;
88      if (this.settings.allowFuture) {
89        if (distanceMillis < 0) {
90          prefix = $l.prefixFromNow;
91          suffix = $l.suffixFromNow;
92        }
93      }
94
95      if (!this.settings.allowPast && distanceMillis >= 0) {
96        return this.settings.strings.inPast;
97      }
98
99      var seconds = Math.abs(distanceMillis) / 1000;
100      var minutes = seconds / 60;
101      var hours = minutes / 60;
102      var days = hours / 24;
103      var years = days / 365;
104
105      function substitute(stringOrFunction, number) {
106        var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
107        var value = ($l.numbers && $l.numbers[number]) || number;
108        return string.replace(/%d/i, value);
109      }
110
111      var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
112          seconds < 90 && substitute($l.minute, 1) ||
113          minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
114          minutes < 90 && substitute($l.hour, 1) ||
115          hours < 24 && substitute($l.hours, Math.round(hours)) ||
116          hours < 42 && substitute($l.day, 1) ||
117          days < 30 && substitute($l.days, Math.round(days)) ||
118          days < 45 && substitute($l.month, 1) ||
119          days < 365 && substitute($l.months, Math.round(days / 30)) ||
120          years < 1.5 && substitute($l.year, 1) ||
121          substitute($l.years, Math.round(years));
122
123      var separator = $l.wordSeparator || "";
124      if ($l.wordSeparator === undefined) { separator = " "; }
125      return $.trim([prefix, words, suffix].join(separator));
126    },
127
128    parse: function(iso8601) {
129      var s = $.trim(iso8601);
130      s = s.replace(/\.\d+/,""); // remove milliseconds
131      s = s.replace(/-/,"/").replace(/-/,"/");
132      s = s.replace(/T/," ").replace(/Z/," UTC");
133      s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
134      s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
135      return new Date(s);
136    },
137    datetime: function(elem) {
138      var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
139      return $t.parse(iso8601);
140    },
141    isTime: function(elem) {
142      // jQuery's `is()` doesn't play well with HTML5 in IE
143      return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
144    }
145  });
146
147  // functions that can be called via $(el).timeago('action')
148  // init is default when no action is given
149  // functions are called with context of a single element
150  var functions = {
151    init: function() {
152      var refresh_el = $.proxy(refresh, this);
153      refresh_el();
154      var $s = $t.settings;
155      if ($s.refreshMillis > 0) {
156        this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
157      }
158    },
159    update: function(timestamp) {
160      var date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp);
161      $(this).data('timeago', { datetime: date });
162      if ($t.settings.localeTitle) $(this).attr("title", date.toLocaleString());
163      refresh.apply(this);
164    },
165    updateFromDOM: function() {
166      $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
167      refresh.apply(this);
168    },
169    dispose: function () {
170      if (this._timeagoInterval) {
171        window.clearInterval(this._timeagoInterval);
172        this._timeagoInterval = null;
173      }
174    }
175  };
176
177  $.fn.timeago = function(action, options) {
178    var fn = action ? functions[action] : functions.init;
179    if (!fn) {
180      throw new Error("Unknown function name '"+ action +"' for timeago");
181    }
182    // each over objects here and call the requested function
183    this.each(function() {
184      fn.call(this, options);
185    });
186    return this;
187  };
188
189  function refresh() {
190    var $s = $t.settings;
191
192    //check if it's still visible
193    if ($s.autoDispose && !$.contains(document.documentElement,this)) {
194      //stop if it has been removed
195      $(this).timeago("dispose");
196      return this;
197    }
198
199    var data = prepareData(this);
200
201    if (!isNaN(data.datetime)) {
202      if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
203        $(this).text(inWords(data.datetime));
204      }
205    }
206    return this;
207  }
208
209  function prepareData(element) {
210    element = $(element);
211    if (!element.data("timeago")) {
212      element.data("timeago", { datetime: $t.datetime(element) });
213      var text = $.trim(element.text());
214      if ($t.settings.localeTitle) {
215        element.attr("title", element.data('timeago').datetime.toLocaleString());
216      } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
217        element.attr("title", text);
218      }
219    }
220    return element.data("timeago");
221  }
222
223  function inWords(date) {
224    return $t.inWords(distance(date));
225  }
226
227  function distance(date) {
228    return (new Date().getTime() - date.getTime());
229  }
230
231  // fix for IE6 suckage
232  document.createElement("abbr");
233  document.createElement("time");
234}));
235}

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.