PageSourceSearch

https://welcometotwinpeaks.com/wp-content/plugins/wpc-coupon-listi…/jquery.countdown_zp.js?ver=1.4.1

js welcometotwinpeaks.com collected 2026-10-02 03:10:21 UTC 8,829 bytes, 261 lines download raw bytes

vendor: 8,829 bytes, lines 1-261
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(
39      /[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
40  matchers = new RegExp(matchers.join('|'));
41
42  function parseDateString(dateString) {
43    if (dateString instanceof Date) {
44      return dateString;
45    }
46    if (String(dateString).match(matchers)) {
47      if (String(dateString).match(/^[0-9]*$/)) {
48        dateString = Number(dateString);
49      }
50      if (String(dateString).match(/\-/)) {
51        dateString = String(dateString).replace(/\-/g, '/');
52      }
53      return new Date(dateString);
54    } else {
55      throw new Error('Couldn\'t cast `' + dateString + '` to a date object.');
56    }
57  }
58
59  var DIRECTIVE_KEY_MAP = {
60    Y: 'years',
61    m: 'months',
62    n: 'daysToMonth',
63    d: 'daysToWeek',
64    w: 'weeks',
65    W: 'weeksToMonth',
66    H: 'hours',
67    M: 'minutes',
68    S: 'seconds',
69    D: 'totalDays',
70    I: 'totalHours',
71    N: 'totalMinutes',
72    T: 'totalSeconds',
73  };
74
75  function escapedRegExp(str) {
76    var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
77    return new RegExp(sanitize);
78  }
79
80  function strftime(offsetObject) {
81    return function(format) {
82      var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
83      if (directives) {
84        for (var i = 0, len = directives.length; i < len; ++i) {
85          var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),
86              regexp = escapedRegExp(directive[0]),
87              modifier = directive[1] || '', plural = directive[3] || '',
88              value = null;
89          directive = directive[2];
90          if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
91            value = DIRECTIVE_KEY_MAP[directive];
92            value = Number(offsetObject[value]);
93          }
94          if (value !== null) {
95            if (modifier === '!') {
96              value = pluralize(plural, value);
97            }
98            if (modifier === '') {
99              if (value < 10) {
100                value = '0' + value.toString();
101              }
102            }
103            format = format.replace(regexp, value.toString());
104          }
105        }
106      }
107      format = format.replace(/%%/, '%');
108      return format;
109    };
110  }
111
112  function pluralize(format, count) {
113    var plural = 's', singular = '';
114    if (format) {
115      format = format.replace(/(:|;|\s)/gi, '').split(/\,/);
116      if (format.length === 1) {
117        plural = format[0];
118      } else {
119        singular = format[0];
120        plural = format[1];
121      }
122    }
123    if (count === 1) {
124      return singular;
125    } else {
126      return plural;
127    }
128  }
129
130  var Countdown = function(el, finalDate, options) {
131    this.el = el;
132    this.$el = $(el);
133    this.interval = null;
134    this.offset = {};
135    this.options = $.extend({}, defaultOptions);
136    this.instanceNumber = instances.length;
137    instances.push(this);
138    this.$el.data('countdown-instance', this.instanceNumber);
139    if (options) {
140      if (typeof options === 'function') {
141        this.$el.on('update.countdown', options);
142        this.$el.on('stoped.countdown', options);
143        this.$el.on('finish.countdown', options);
144      } else {
145        this.options = $.extend({}, defaultOptions, options);
146      }
147    }
148    this.setFinalDate(finalDate);
149    if (this.options.defer === false) {
150      this.start();
151    }
152  };
153  $.extend(Countdown.prototype, {
154    start: function() {
155      if (this.interval !== null) {
156        clearInterval(this.interval);
157      }
158      var self = this;
159      this.update();
160      this.interval = setInterval(function() {
161        self.update.call(self);
162      }, this.options.precision);
163    },
164    stop: function() {
165      clearInterval(this.interval);
166      this.interval = null;
167      this.dispatchEvent('stoped');
168    },
169    toggle: function() {
170      if (this.interval) {
171        this.stop();
172      } else {
173        this.start();
174      }
175    },
176    pause: function() {
177      this.stop();
178    },
179    resume: function() {
180      this.start();
181    },
182    remove: function() {
183      this.stop.call(this);
184      instances[this.instanceNumber] = null;
185      delete this.$el.data().countdownInstance;
186    },
187    setFinalDate: function(value) {
188      this.finalDate = parseDateString(value);
189    },
190    update: function() {
191      if (this.$el.closest('html').length === 0) {
192        this.remove();
193        return;
194      }
195      var hasEventsAttached = $._data(this.el, 'events') !== undefined,
196          now = new Date(), newTotalSecsLeft;
197      newTotalSecsLeft = this.finalDate.getTime() - now.getTime();
198      newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3);
199      newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0
200          ? 0
201          : Math.abs(newTotalSecsLeft);
202      if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) {
203        return;
204      } else {
205        this.totalSecsLeft = newTotalSecsLeft;
206      }
207      this.elapsed = now >= this.finalDate;
208      this.offset = {
209        seconds: this.totalSecsLeft % 60,
210        minutes: Math.floor(this.totalSecsLeft / 60) % 60,
211        hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
212        days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
213        daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
214        daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
215        weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
216        weeksToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7) % 4,
217        months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
218        years: Math.abs(this.finalDate.getFullYear() - now.getFullYear()),
219        totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
220        totalHours: Math.floor(this.totalSecsLeft / 60 / 60),
221        totalMinutes: Math.floor(this.totalSecsLeft / 60),
222        totalSeconds: this.totalSecsLeft,
223      };
224      if (!this.options.elapse && this.totalSecsLeft === 0) {
225        this.stop();
226        this.dispatchEvent('finish');
227      } else {
228        this.dispatchEvent('update');
229      }
230    },
231    dispatchEvent: function(eventName) {
232      var event = $.Event(eventName + '.countdown');
233      event.finalDate = this.finalDate;
234      event.elapsed = this.elapsed;
235      event.offset = $.extend({}, this.offset);
236      event.strftime = strftime(this.offset);
237      this.$el.trigger(event);
238    },
239  });
240  $.fn.countdown = function() {
241    var argumentsArray = Array.prototype.slice.call(arguments, 0);
242    return this.each(function() {
243      var instanceNumber = $(this).data('countdown-instance');
244      if (instanceNumber !== undefined) {
245        var instance = instances[instanceNumber], method = argumentsArray[0];
246        if (Countdown.prototype.hasOwnProperty(method)) {
247          instance[method].apply(instance, argumentsArray.slice(1));
248        } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) {
249          instance.setFinalDate.call(instance, method);
250          instance.start();
251        } else {
252          $.error(
253              'Method %s does not exist on jQuery.countdown'.replace(/\%s/gi,
254                  method));
255        }
256      } else {
257        new Countdown(this, argumentsArray[0], argumentsArray[1]);
258      }
259    });
260  };
261});

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.