PageSourceSearch

https://idahoansforsafetechnology.org/wp-content/plugins/raffle-ti…/includes/js/jquery.countdown.js?ver=7.0.4

js idahoansforsafetechnology.org collected 2026-09-24 14:05:31 UTC 10,251 bytes, 246 lines download raw bytes

vendor: 10,251 bytes, lines 1-246
1/*!
2 * The Final Countdown for jQuery v2.2.0 (http://hilios.github.io/jQuery.countdown/)
3 * Copyright (c) 2016 Edson Hilios
4 * 
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 * 
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 * 
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22(function(factory) {
23    "use strict";
24    if (typeof define === "function" && define.amd) {
25        define([ "jquery" ], factory);
26    } else {
27        factory(jQuery);
28    }
29})(function($) {
30    "use strict";
31    var instances = [], matchers = [], defaultOptions = {
32        precision: 100,
33        elapse: false,
34        defer: false
35    };
36    matchers.push(/^[0-9]*$/.source);
37    matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
38    matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
39    matchers = new RegExp(matchers.join("|"));
40    function parseDateString(dateString) {
41        if (dateString instanceof Date) {
42            return dateString;
43        }
44        if (String(dateString).match(matchers)) {
45            if (String(dateString).match(/^[0-9]*$/)) {
46                dateString = Number(dateString);
47            }
48            if (String(dateString).match(/\-/)) {
49                dateString = String(dateString).replace(/\-/g, "/");
50            }
51            return new Date(dateString);
52        } else {
53            throw new Error("Couldn't cast `" + dateString + "` to a date object.");
54        }
55    }
56    var DIRECTIVE_KEY_MAP = {
57        Y: "years",
58        m: "months",
59        n: "daysToMonth",
60        d: "daysToWeek",
61        w: "weeks",
62        W: "weeksToMonth",
63        H: "hours",
64        M: "minutes",
65        S: "seconds",
66        D: "totalDays",
67        I: "totalHours",
68        N: "totalMinutes",
69        T: "totalSeconds"
70    };
71    function escapedRegExp(str) {
72        var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
73        return new RegExp(sanitize);
74    }
75    function strftime(offsetObject) {
76        return function(format) {
77            var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
78            if (directives) {
79                for (var i = 0, len = directives.length; i < len; ++i) {
80                    var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null;
81                    directive = directive[2];
82                    if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
83                        value = DIRECTIVE_KEY_MAP[directive];
84                        value = Number(offsetObject[value]);
85                    }
86                    if (value !== null) {
87                        if (modifier === "!") {
88                            value = pluralize(plural, value);
89                        }
90                        if (modifier === "") {
91                            if (value < 10) {
92                                value = "0" + value.toString();
93                            }
94                        }
95                        format = format.replace(regexp, value.toString());
96                    }
97                }
98            }
99            format = format.replace(/%%/, "%");
100            return format;
101        };
102    }
103    function pluralize(format, count) {
104        var plural = "s", singular = "";
105        if (format) {
106            format = format.replace(/(:|;|\s)/gi, "").split(/\,/);
107            if (format.length === 1) {
108                plural = format[0];
109            } else {
110                singular = format[0];
111                plural = format[1];
112            }
113        }
114        if (Math.abs(count) > 1) {
115            return plural;
116        } else {
117            return singular;
118        }
119    }
120    var Countdown = function(el, finalDate, options) {
121        this.el = el;
122        this.$el = $(el);
123        this.interval = null;
124        this.offset = {};
125        this.options = $.extend({}, defaultOptions);
126        this.instanceNumber = instances.length;
127        instances.push(this);
128        this.$el.data("countdown-instance", this.instanceNumber);
129        if (options) {
130            if (typeof options === "function") {
131                this.$el.on("update.countdown", options);
132                this.$el.on("stoped.countdown", options);
133                this.$el.on("finish.countdown", options);
134            } else {
135                this.options = $.extend({}, defaultOptions, options);
136            }
137        }
138        this.setFinalDate(finalDate);
139        if (this.options.defer === false) {
140            this.start();
141        }
142    };
143    $.extend(Countdown.prototype, {
144        start: function() {
145            if (this.interval !== null) {
146                clearInterval(this.interval);
147            }
148            var self = this;
149            this.update();
150            this.interval = setInterval(function() {
151                self.update.call(self);
152            }, this.options.precision);
153        },
154        stop: function() {
155            clearInterval(this.interval);
156            this.interval = null;
157            this.dispatchEvent("stoped");
158        },
159        toggle: function() {
160            if (this.interval) {
161                this.stop();
162            } else {
163                this.start();
164            }
165        },
166        pause: function() {
167            this.stop();
168        },
169        resume: function() {
170            this.start();
171        },
172        remove: function() {
173            this.stop.call(this);
174            instances[this.instanceNumber] = null;
175            delete this.$el.data().countdownInstance;
176        },
177        setFinalDate: function(value) {
178            this.finalDate = parseDateString(value);
179        },
180        update: function() {
181            if (this.$el.closest("html").length === 0) {
182                this.remove();
183                return;
184            }
185            var hasEventsAttached = $._data(this.el, "events") !== undefined, now = new Date(), newTotalSecsLeft;
186            newTotalSecsLeft = this.finalDate.getTime() - now.getTime();
187            newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3);
188            newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0 ? 0 : Math.abs(newTotalSecsLeft);
189            if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) {
190                return;
191            } else {
192                this.totalSecsLeft = newTotalSecsLeft;
193            }
194            this.elapsed = now >= this.finalDate;
195            this.offset = {
196                seconds: this.totalSecsLeft % 60,
197                minutes: Math.floor(this.totalSecsLeft / 60) % 60,
198                hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
199                days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
200                daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
201                daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
202                weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
203                weeksToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7) % 4,
204                months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
205                years: Math.abs(this.finalDate.getFullYear() - now.getFullYear()),
206                totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
207                totalHours: Math.floor(this.totalSecsLeft / 60 / 60),
208                totalMinutes: Math.floor(this.totalSecsLeft / 60),
209                totalSeconds: this.totalSecsLeft
210            };
211            if (!this.options.elapse && this.totalSecsLeft === 0) {
212                this.stop();
213                this.dispatchEvent("finish");
214            } else {
215                this.dispatchEvent("update");
216            }
217        },
218        dispatchEvent: function(eventName) {
219            var event = $.Event(eventName + ".countdown");
220            event.finalDate = this.finalDate;
221            event.elapsed = this.elapsed;
222            event.offset = $.extend({}, this.offset);
223            event.strftime = strftime(this.offset);
224            this.$el.trigger(event);
225        }
226    });
227    $.fn.countdown = function() {
228        var argumentsArray = Array.prototype.slice.call(arguments, 0);
229        return this.each(function() {
230            var instanceNumber = $(this).data("countdown-instance");
231            if (instanceNumber !== undefined) {
232                var instance = instances[instanceNumber], method = argumentsArray[0];
233                if (Countdown.prototype.hasOwnProperty(method)) {
234                    instance[method].apply(instance, argumentsArray.slice(1));
235                } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) {
236                    instance.setFinalDate.call(instance, method);
237                    instance.start();
238                } else {
239                    $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method));
240                }
241            } else {
242                new Countdown(this, argumentsArray[0], argumentsArray[1]);
243            }
244        });
245    };
246});

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.