PageSourceSearch

https://www.forkliftaction.com/Redesign/Scripts/fla-countdownTimer.js?v0049-10

js forkliftaction.com collected 2026-10-02 07:44:19 UTC 2,133 bytes, 71 lines download raw bytes

1!function ($, undefined) {
2
3    "use strict";
4
5    var countdownTimer = function (element, options) {
6        this.init(element, options);
7    };
8
9    countdownTimer.prototype = {
10        constructor: countdownTimer,
11
12        init: function (element, options) {
13            this.$element = $(element);
14            this.options = $.extend({}, { timestamp: null }, this.$element.data(), options);
15
16            this.timestamp = moment.unix(this.options.timestamp);
17
18            this.isCountdown = this.timestamp.isAfter(moment());
19
20            this.setTime();
21            this.startTimer();
22
23            //console.log('countdown-timer', this);
24        },
25
26        setTime: function () {
27
28            var cd = countdown(this.timestamp);
29
30            var v = cd.toString();
31
32            if (this.isCountdown && fla.nullOrEmpty(v)) v = '0 seconds'
33
34            this.$element.html((this.isCountdown ? 'in ' : '') + v);
35
36            if (this.isCountdown && Math.floor(cd.value / 1000) >= 0) {
37
38                this.clearTimer();
39
40                // trigger an event for completion
41                var ev = $.Event('completed.countdownTimer', { timestamp: this.timestamp.toDate() });
42                this.$element.trigger(ev);
43            }
44        },
45
46        startTimer: function () {
47            var self = this;
48            this.interval = setInterval(function () { self.setTime(); }, 1000);
49        },
50
51        clearTimer: function () {
52            clearInterval(this.interval);
53        }
54    };
55
56    $.fn.countdownTimer = function (option) {
57        var args = arguments;
58        [].shift.apply(args);
59
60        return this.each(function () {
61            var $this = $(this),
62                data = $this.data('fla.countdownTimer'),
63                options = typeof option == 'object' && option;
64            if (!data) $this.data('fla.countdownTimer', (data = new countdownTimer(this, options)));
65            if (typeof option == 'string') data[option].apply(data, args);
66        });
67    };
68
69    $.fn.countdownTimer.constructor = countdownTimer;
70
71}(window.jQuery);

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.