PageSourceSearch

http://www.herculife.com/catalog/view/theme/journal2/lib/countdown/jquery.countdown.js?j2v=2.15.9

js herculife.com collected 2026-10-06 18:59:35 UTC 3,880 bytes, 133 lines download raw bytes

1// Generated by CoffeeScript 1.4.0
2
3/*
4countdown is a simple jquery plugin for countdowns
5
6Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
7and GPL-3.0 (http://opensource.org/licenses/GPL-3.0) licenses.
8
9@source: http://github.com/rendro/countdown/
10@autor: Robert Fleischmann
11@version: 1.0.1
12*/
13
14
15(function() {
16
17  (function($) {
18    $.countdown = function(el, options) {
19      var getDateData,
20        _this = this;
21      this.el = el;
22      this.$el = $(el);
23      this.$el.data("countdown", this);
24      this.init = function() {
25        _this.options = $.extend({}, $.countdown.defaultOptions, options);
26        if (_this.options.refresh) {
27          _this.interval = setInterval(function() {
28            return _this.render();
29          }, _this.options.refresh);
30        }
31        _this.render();
32        return _this;
33      };
34      getDateData = function(endDate) {
35        var dateData, diff;
36        endDate = Date.parse($.isPlainObject(_this.options.date) ? _this.options.date : new Date(_this.options.date));
37        diff = (endDate - Date.parse(new Date)) / 1000;
38        if (diff <= 0) {
39          diff = 0;
40          if (_this.interval) {
41            _this.stop();
42          }
43          _this.options.onEnd.apply(_this);
44        }
45        dateData = {
46          years: 0,
47          days: 0,
48          hours: 0,
49          min: 0,
50          sec: 0,
51          millisec: 0
52        };
53        if (diff >= (365.25 * 86400)) {
54          dateData.years = Math.floor(diff / (365.25 * 86400));
55          diff -= dateData.years * 365.25 * 86400;
56        }
57        if (diff >= 86400) {
58          dateData.days = Math.floor(diff / 86400);
59          diff -= dateData.days * 86400;
60        }
61        if (diff >= 3600) {
62          dateData.hours = Math.floor(diff / 3600);
63          diff -= dateData.hours * 3600;
64        }
65        if (diff >= 60) {
66          dateData.min = Math.floor(diff / 60);
67          diff -= dateData.min * 60;
68        }
69        dateData.sec = diff;
70        return dateData;
71      };
72      this.leadingZeros = function(num, length) {
73        if (length == null) {
74          length = 2;
75        }
76        num = String(num);
77        while (num.length < length) {
78          num = "0" + num;
79        }
80        return num;
81      };
82      this.update = function(newDate) {
83        _this.options.date = newDate;
84        return _this;
85      };
86      this.render = function() {
87        _this.options.render.apply(_this, [getDateData(_this.options.date)]);
88        return _this;
89      };
90      this.stop = function() {
91        if (_this.interval) {
92          clearInterval(_this.interval);
93        }
94        _this.interval = null;
95        return _this;
96      };
97      this.start = function(refresh) {
98        if (refresh == null) {
99          refresh = _this.options.refresh || $.countdown.defaultOptions.refresh;
100        }
101        if (_this.interval) {
102          clearInterval(_this.interval);
103        }
104        _this.render();
105        _this.options.refresh = refresh;
106        _this.interval = setInterval(function() {
107          return _this.render();
108        }, _this.options.refresh);
109        return _this;
110      };
111      return this.init();
112    };
113    $.countdown.defaultOptions = {
114      date: "June 7, 2087 15:03:25",
115      refresh: 1000,
116      onEnd: $.noop,
117      render: function(date) {
118        return $(this.el).html("" + date.years + " years, " + date.days + " days, " + (this.leadingZeros(date.hours)) + " hours, " + (this.leadingZeros(date.min)) + " min and " + (this.leadingZeros(date.sec)) + " sec");
119      }
120    };
121    $.fn.countdown = function(options) {
122      return $.each(this, function(i, el) {
123        var $el;
124        $el = $(el);
125        if (!$el.data('countdown')) {
126          return $el.data('countdown', new $.countdown(el, options));
127        }
128      });
129    };
130    return void 0;
131  })(jQuery);
132
133}).call(this);

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.