PageSourceSearch

https://censo2020.mx/js/jquery.countdown.min.js?ver=1.0

js censo2020.mx collected 2026-09-28 12:19:19 UTC 23,780 bytes, 584 lines download raw bytes

1/* http://keith-wood.name/countdown.html
2   Countdown for jQuery v1.5.8.
3   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
4   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
5   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
6   Please attribute the author if you use it. */
7(function($) {
8    function Countdown() {
9        this.regional = [];
10        this.regional[''] = {
11            labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
12            labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
13            compactLabels: ['y', 'm', 'w', 'd'],
14            whichLabels: null,
15            timeSeparator: ':',
16            isRTL: false
17        };
18        this._defaults = {
19            until: null,
20            since: null,
21            timezone: null,
22            serverSync: null,
23            format: 'dHMS',
24            layout: '',
25            compact: false,
26            significant: 0,
27            description: '',
28            expiryUrl: '',
29            expiryText: '',
30            alwaysExpire: false,
31            onExpiry: null,
32            onTick: null,
33            tickInterval: 1
34        };
35        $.extend(this._defaults, this.regional['']);
36        this._serverSyncs = []
37    }
38    var w = 'countdown';
39    var Y = 0;
40    var O = 1;
41    var W = 2;
42    var D = 3;
43    var H = 4;
44    var M = 5;
45    var S = 6;
46    $.extend(Countdown.prototype, {
47        markerClassName: 'hasCountdown',
48        _timer: setInterval(function() {
49            $.countdown._updateTargets()
50        }, 980),
51        _timerTargets: [],
52        setDefaults: function(a) {
53            this._resetExtraLabels(this._defaults, a);
54            extendRemove(this._defaults, a || {})
55        },
56        UTCDate: function(a, b, c, e, f, g, h, i) {
57            if (typeof b == 'object' && b.constructor == Date) {
58                i = b.getMilliseconds();
59                h = b.getSeconds();
60                g = b.getMinutes();
61                f = b.getHours();
62                e = b.getDate();
63                c = b.getMonth();
64                b = b.getFullYear()
65            }
66            var d = new Date();
67            d.setUTCFullYear(b);
68            d.setUTCDate(1);
69            d.setUTCMonth(c || 0);
70            d.setUTCDate(e || 1);
71            d.setUTCHours(f || 0);
72            d.setUTCMinutes((g || 0) - (Math.abs(a) < 30 ? a * 60 : a));
73            d.setUTCSeconds(h || 0);
74            d.setUTCMilliseconds(i || 0);
75            return d
76        },
77        periodsToSeconds: function(a) {
78            return a[0] * 31557600 + a[1] * 2629800 + a[2] * 604800 + a[3] * 86400 + a[4] * 3600 + a[5] * 60 + a[6]
79        },
80        _settingsCountdown: function(a, b) {
81            if (!b) {
82                return $.countdown._defaults
83            }
84            var c = $.data(a, w);
85            return (b == 'all' ? c.options : c.options[b])
86        },
87        _attachCountdown: function(a, b) {
88            var c = $(a);
89            if (c.hasClass(this.markerClassName)) {
90                return
91            }
92            c.addClass(this.markerClassName);
93            var d = {
94                options: $.extend({}, b),
95                _periods: [0, 0, 0, 0, 0, 0, 0]
96            };
97            $.data(a, w, d);
98            this._changeCountdown(a)
99        },
100        _addTarget: function(a) {
101            if (!this._hasTarget(a)) {
102                this._timerTargets.push(a)
103            }
104        },
105        _hasTarget: function(a) {
106            return ($.inArray(a, this._timerTargets) > -1)
107        },
108        _removeTarget: function(b) {
109            this._timerTargets = $.map(this._timerTargets, function(a) {
110                return (a == b ? null : a)
111            })
112        },
113        _updateTargets: function() {
114            for (var i = this._timerTargets.length - 1; i >= 0; i--) {
115                this._updateCountdown(this._timerTargets[i])
116            }
117        },
118        _updateCountdown: function(a, b) {
119            var c = $(a);
120            b = b || $.data(a, w);
121            if (!b) {
122                return
123            }
124            c.html(this._generateHTML(b));
125            c[(this._get(b, 'isRTL') ? 'add' : 'remove') + 'Class']('countdown_rtl');
126            var d = this._get(b, 'onTick');
127            if (d) {
128                var e = b._hold != 'lap' ? b._periods : this._calculatePerio
128ds(b, b._show, this._get(b, 'significant'), new Date());
129                var f = this._get(b, 'tickInterval');
130                if (f == 1 || this.periodsToSeconds(e) % f == 0) {
131                    d.apply(a, [e])
132                }
133            }
134            var g = b._hold != 'pause' && (b._since ? b._now.getTime() < b._since.getTime() : b._now.getTime() >= b._until.getTime());
135            if (g && !b._expiring) {
136                b._expiring = true;
137                if (this._hasTarget(a) || this._get(b, 'alwaysExpire')) {
138                    this._removeTarget(a);
139                    var h = this._get(b, 'onExpiry');
140                    if (h) {
141                        h.apply(a, [])
142                    }
143                    var i = this._get(b, 'expiryText');
144                    if (i) {
145                        var j = this._get(b, 'layout');
146                        b.options.layout = i;
147                        this._updateCountdown(a, b);
148                        b.options.layout = j
149                    }
150                    var k = this._get(b, 'expiryUrl');
151                    if (k) {
152                        window.location = k
153                    }
154                }
155                b._expiring = false
156            } else if (b._hold == 'pause') {
157                this._removeTarget(a)
158            }
159            $.data(a, w, b)
160        },
161        _changeCountdown: function(a, b, c) {
162            b = b || {};
163            if (typeof b == 'string') {
164                var d = b;
165                b = {};
166                b[d] = c
167            }
168            var e = $.data(a, w);
169            if (e) {
170                this._resetExtraLabels(e.options, b);
171                extendRemove(e.options, b);
172                this._adjustSettings(a, e);
173                $.data(a, w, e);
174                var f = new Date();
175                if ((e._since && e._since < f) || (e._until && e._until > f)) {
176                    this._addTarget(a)
177                }
178                this._updateCountdown(a, e)
179            }
180        },
181        _resetExtraLabels: function(a, b) {
182            var c = false;
183            for (var n in b) {
184                if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
185                    c = true;
186                    break
187                }
188            }
189            if (c) {
190                for (var n in a) {
191                    if (n.match(/[Ll]abels[0-9]/)) {
192                        a[n] = null
193                    }
194                }
195            }
196        },
197        _adjustSettings: function(a, b) {
198            var c;
199            var d = this._get(b, 'serverSync');
200            var e = 0;
201            var f = null;
202            for (var i = 0; i < this._serverSyncs.length; i++) {
203                if (this._serverSyncs[i][0] == d) {
204                    f = this._serverSyncs[i][1];
205                    break
206                }
207            }
208            if (f != null) {
209                e = (d ? f : 0);
210                c = new Date()
211            } else {
212                var g = (d ? d.apply(a, []) : null);
213                c = new Date();
214                e = (g ? c.getTime() - g.getTime() : 0);
215                this._serverSyncs.push([d, e])
216            }
217            var h = this._get(b, 'timezone');
218            h = (h == null ? -c.getTimezoneOffset() : h);
219            b._since = this._get(b, 'since');
220            if (b._since != null) {
221                b._since = this.UTCDate(h, this._determineTime(b._since, null));
222                if (b._since && e) {
223                    b._since.setMilliseconds(b._since.getMilliseconds() + e)
224                }
225            }
226            b._until = this.UTCDate(h, this._determineTime(this._get(b, 'until'), c));
227            if (e) {
228                b._until.setMilliseconds(b._until.getMilliseconds() + e)
229            }
230            b._show = this._determineShow(b)
231        },
232        _destroyCountdown: function(a) {
233            var b = $(a);
234            if (!b.hasClass(this.markerClassName)) {
235                return
236            }
237            this._removeTarget(a);
238            b.removeClass(this.markerClassName).empty();
239            $.removeData(a, w)
240        },
241        _pauseCountdown: function(a) {
242            this._hold(a, 'pause')
243        },
244        _lapCountdown: function(a) {
245            this._hold(a, 'lap')
246        },
247        _resumeCountdown: function(a) {
248            this._hold(a, null)
249        },
250        _hold: function(a, b) {
251            var c = $.data(a, w);
252            if (c) {
253                if (c._hold == 'pause' && !b) {
254                    c._periods = c._savePeriods;
255                    var d = (c._since ? '-' : '+');
256                    c[c._since ? '_since' : '_until'] = this._determineTime(d + c._periods[0] + 'y' + d + c._periods[1] + 'o' + d + c._periods[2] + 'w' + d + c._periods[3] + 'd' + d + c._periods[4] + 'h' 
256+ d + c._periods[5] + 'm' + d + c._periods[6] + 's');
257                    this._addTarget(a)
258                }
259                c._hold = b;
260                c._savePeriods = (b == 'pause' ? c._periods : null);
261                $.data(a, w, c);
262                this._updateCountdown(a, c)
263            }
264        },
265        _getTimesCountdown: function(a) {
266            var b = $.data(a, w);
267            return (!b ? null : (!b._hold ? b._periods : this._calculatePeriods(b, b._show, this._get(b, 'significant'), new Date())))
268        },
269        _get: function(a, b) {
270            return (a.options[b] != null ? a.options[b] : $.countdown._defaults[b])
271        },
272        _determineTime: function(k, l) {
273            var m = function(a) {
274                var b = new Date();
275                b.setTime(b.getTime() + a * 1000);
276                return b
277            };
278            var n = function(a) {
279                a = a.toLowerCase();
280                var b = new Date();
281                var c = b.getFullYear();
282                var d = b.getMonth();
283                var e = b.getDate();
284                var f = b.getHours();
285                var g = b.getMinutes();
286                var h = b.getSeconds();
287                var i = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
288                var j = i.exec(a);
289                while (j) {
290                    switch (j[2] || 's') {
291                        case 's':
292                            h += parseInt(j[1], 10);
293                            break;
294                        case 'm':
295                            g += parseInt(j[1], 10);
296                            break;
297                        case 'h':
298                            f += parseInt(j[1], 10);
299                            break;
300                        case 'd':
301                            e += parseInt(j[1], 10);
302                            break;
303                        case 'w':
304                            e += parseInt(j[1], 10) * 7;
305                            break;
306                        case 'o':
307                            d += parseInt(j[1], 10);
308                            e = Math.min(e, $.countdown._getDaysInMonth(c, d));
309                            break;
310                        case 'y':
311                            c += parseInt(j[1], 10);
312                            e = Math.min(e, $.countdown._getDaysInMonth(c, d));
313                            break
314                    }
315                    j = i.exec(a)
316                }
317                return new Date(c, d, e, f, g, h, 0)
318            };
319            var o = (k == null ? l : (typeof k == 'string' ? n(k) : (typeof k == 'number' ? m(k) : k)));
320            if (o) o.setMilliseconds(0);
321            return o
322        },
323        _getDaysInMonth: function(a, b) {
324            return 32 - new Date(a, b, 32).getDate()
325        },
326        _normalLabels: function(a) {
327            return a
328        },
329        _generateHTML: function(c) {
330            var d = this._get(c, 'significant');
331            c._periods = (c._hold ? c._periods : this._calculatePeriods(c, c._show, d, new Date()));
332            var e = false;
333            var f = 0;
334            var g = d;
335            var h = $.extend({}, c._show);
336            for (var i = Y; i <= S; i++) {
337                e |= (c._show[i] == '?' && c._periods[i] > 0);
338                h[i] = (c._show[i] == '?' && !e ? null : c._show[i]);
339                f += (h[i] ? 1 : 0);
340                g -= (c._periods[i] > 0 ? 1 : 0)
341            }
342            var j = [false, false, false, false, false, false, false];
343            for (var i = S; i >= Y; i--) {
344                if (c._show[i]) {
345                    if (c._periods[i]) {
346                        j[i] = true
347                    } else {
348                        j[i] = g > 0;
349                        g--
350                    }
351                }
352            }
353            var k = this._get(c, 'compact');
354            var l = this._get(c, 'layout');
355            var m = (k ? this._get(c, 'compactLabels') : this._get(c, 'labels'));
356            var n = this._get(c, 'whichLabels') || this._normalLabels;
357            var o = this._get(c, 'timeSeparator');
358            var p = this._get(c, 'description') || '';
359            var q = function(a) {
360                var b = $.countdown._get(c, 'compactLabels' + n(c._periods[a]));
361                return (h[a] ? c._periods[a] + (b ? b[a] : m[a]) + ' ' : '')
362            };
363			
364var reemplazarAcentos=function(cadena) {
365	var chars={"í":"i"}
366	var expr=/[áàéèíìóòúùñ]/ig;
367	var res=cadena.replace(expr,function(e){return chars[e]});
368	return res;
369}
370 
371			
372            var r = function(a) {
373                var b = $.countdown._get(c, 'labels' + n(c._periods[a]));
374               return ((!d && h[a]) || (d && j[a]) ? '<span class="countdown_section"> <div  id="' + reemplazarAcentos(b ? b[a] : m[a]) + '"><span class="countdown_amount">'+ c._periods[a] +'</span></div><br><div  id="' + reemplazarAcentos(b ? b[a] : m[a]) + '-C" class="centrado"><span id="' + reemplazarAcentos(b ? b[a] : m[a]) + '-F" >' + (b ? b[a] : m[a]) + '</span></div><br/></span>' : '')
375            };
376            return (l ? this._buildLayout(c, h, l, k, d, j) : ((k ? '<span class="countdown_row countdown_amount' + (c._hold ? ' countdown_holding' : '') + '">' + q(Y) + q(O) + q(W) + q(D) + (h[H] ? this._minDigits(c._periods[H], 2) : '') + (h[M] ? (h[H] ? o : '') + this._minDigits(c._periods[M], 2) : '') + (h[S] ? (h[H] || h[M] ? o : '') + this._minDigits(c._periods[S], 2) : '') : '<span class="countdown_row countdown_show' + (d || f) + (c._hold ? ' countdown_holding' : '') + '">' + r(Y) + r(O) + r(W) + r(D) + r(H) + r(M) + r(S)) + '</span>' + (p ? '<span class="countdown_row countdown_descr">' + p + '</span>' : '')))
377        },
378        _buildLayout: function(c, d, e, f, g, h) {
379            var j = this._get(c, (f ? 'compactLabels' : 'labels'));
380            var k = this._get(c, 'whichLabels') || this._normalLabels;
381            var l = function(a) {
382                return ($.countdown._get(c, (f ? 'compactLabels' : 'labels') + k(c._periods[a])) || j)[a]
383            };
384            var m = function(a, b) {
385                return Math.floor(a / b) % 10
386            };
387            var o = {
388                desc: this._get(c, 'description'),
389                sep: this._get(c, 'timeSeparator'),
390                yl: l(Y),
391                yn: c._periods[Y],
392                ynn: this._minDigits(c._periods[Y], 2),
393                ynnn: this._minDigits(c._periods[Y], 3),
394                y1: m(c._periods[Y], 1),
395                y10: m(c._periods[Y], 10),
396                y100: m(c._periods[Y], 100),
397                y1000: m(c._periods[Y], 1000),
398                ol: l(O),
399                on: c._periods[O],
400                onn: this._minDigits(c._periods[O], 2),
401                onnn: this._minDigits(c._periods[O], 3),
402                o1: m(c._periods[O], 1),
403                o10: m(c._periods[O], 10),
404                o100: m(c._periods[O], 100),
405                o1000: m(c._periods[O], 1000),
406                wl: l(W),
407                wn: c._periods[W],
408                wnn: this._minDigits(c._periods[W], 2),
409                wnnn: this._minDigits(c._periods[W], 3),
410                w1: m(c._periods[W], 1),
411                w10: m(c._periods[W], 10),
412                w100: m(c._periods[W], 100),
413                w1000: m(c._periods[W], 1000),
414                dl: l(D),
415                dn: c._periods[D],
416                dnn: this._minDigits(c._periods[D], 2),
417                dnnn: this._minDigits(c._periods[D], 3),
418                d1: m(c._periods[D], 1),
419                d10: m(c._periods[D], 10),
420                d100: m(c._periods[D], 100),
421                d1000: m(c._periods[D], 1000),
422                hl: l(H),
423                hn: c._periods[H],
424                hnn: this._minDigits(c._periods[H], 2),
425                hnnn: this._minDigits(c._periods[H], 3),
426                h1: m(c._periods[H], 1),
427                h10: m(c._periods[H], 10),
428                h100: m(c._periods[H], 100),
429                h1000: m(c._periods[H], 1000),
430                ml: l(M),
431                mn: c._periods[M],
432                mnn: this._minDigits(c._periods[M], 2),
433                mnnn: this._minDigits(c._periods[M], 3),
434                m1: m(c._periods[M], 1),
435                m10: m(c._periods[M], 10),
436                m100: m(c._periods[M], 100),
437                m1000: m(c._periods[M], 1000),
438                sl: l(S),
439                sn: c._periods[S],
440                snn: this._minDigits(c._periods[S], 2),
441                snnn: this._minDigits(c._periods[S], 3),
442                s1: m(c._periods[S], 1),
443                s10: m(c._periods[S], 10),
444                s100: m(c._periods[S], 100),
445                s1000: m(c._periods[S], 1000)
446            };
447            var p = e;
448            for (var i = Y; i <= S; i++) {
449                var q = 'yowdhms'.charAt(i);
450                var r = new RegExp('\\{' + q + '<\\}(.*)\\{' + q + '>\\}', 'g');
451                p = p.replace(r, ((!g && d[i]) || (g && h[i]) ? '$1' : ''))
452            }
453            $.each(o, function(n, v) {
454                var a = new RegExp('\\{' + n + '\\}', 'g');
455                p = p.replace(a, v)
456            });
457            return p
458        },
459        _minDigits: function(a, b) {
460            a = '' + a;
461            if (a.length >= b) {
462                return a
463            }
464            a = '0000000000' + a;
465            return a.substr(a.length - b)
466        },
467        _determineShow: function(a) {
468            var b = this._get(a, 'format');
469            var c = [];
470            c[Y] = (b.match('y') ? '?' : (b.match('Y') ? '!' : null));
471            c[O] = (b.match('o') ? '?' : (b.match('O') ? '!' : null));
472            c[W] = (b.match('w') ? '?' : (b.match('W') ? '!' : null));
473            c[D] = (b.match('d') ? '?' : (b.match('D') ? '!' : null));
474            c[H] = (b.match('h') ? '?' : (b.match('H') ? '!' : null));
475            c[M] = (b.match('m') ? '?' : (b.match('M') ? '!' : null));
476            c[S] = (b.match('s') ? '?' : (b.match('S') ? '!' : null));
477            return c
478        },
479        _calculatePeriods: function(c, d, e, f) {
480            c._now = f;
481            c._now.setMilliseconds(0);
482            var g = new Date(c._now.getTime());
483            if (c._since) {
484                if (f.getTime() < c._since.getTime()) {
485                    c._now = f = g
486                } else {
487                    f = c._since
488                }
489            } else {
490                g.setTime(c._until.getTime());
491                if (f.getTime() > c._until.getTime()) {
492                    c._now = f = g
493                }
494            }
495            var h = [0, 0, 0, 0, 0, 0, 0];
496            if (d[Y] || d[O]) {
497                var i = $.countdown._getDaysInMonth(f.getFullYear(), f.getMonth());
498                var j = $.countdown._getDaysInMonth(g.getFullYear(), g.getMonth());
499                var k = (g.getDate() == f.getDate() || (g.getDate() >= Math.min(i, j) && f.getDate() >= Math.min(i, j)));
500                var l = function(a) {
501                    return (a.getHours() * 60 + a.getMinutes()) * 60 + a.getSeconds()
502                };
503                var m = Math.max(0, (g.getFullYear() - f.getFullYear()) * 12 + g.getMonth() - f.getMonth() + ((g.getDate() < f.getDate() && !k) || (k && l(g) < l(f)) ? -1 : 0));
504                h[Y] = (d[Y] ? Math.floor(m / 12) : 0);
505                h[O] = (d[O] ? m - h[Y] * 12 : 0);
506                f = new Date(f.getTime());
507                var n = (f.getDate() == i);
508                var o = $.countdown._getDaysInMonth(f.getFullYear() + h[Y], f.getMonth() + h[O]);
509                if (f.getDate() > o) {
510                    f.setDate(o)
511                }
512                f.setFullYear(f.getFullYear() + h[Y]);
513                f.setMonth(f.getMonth() + h[O]);
514                if (n) {
515                    f.setDate(o)
516                }
517            }
518            var p = Math.floor((g.getTime() - f.getTime()) / 1000);
519            var q = function(a, b) {
520                h[a] = (d[a] ? Math.floor(p / b) : 0);
521                p -= h[a] * b
522            };
523            q(W, 604800);
524            q(D, 86400);
525            q(H, 3600);
526            q(M, 60);
527            q(S, 1);
528            if (p > 0 && !c._since) {
529                var r = [1, 12, 4.3482, 7, 24, 60, 60];
530                var s = S;
531                var t = 1;
532                for (var u = S; u >= Y; u--) {
533                    if (d[u]) {
534                        if (h[s] >= t) {
535                            h[s] = 0;
536                            p = 1
537                        }
538                        if (p > 0) {
539                            h[u]++;
540                            p = 0;
541                            s = u;
542                            t = 1
543                        }
544                    }
545                    t *= r[u]
546                }
547            }
548            if (e) {
549                for (var u = Y; u <= S; u++) {
550                    if (e && h[u]) {
551                        e--
552                    } else if (!e) {
553                        h[u] = 0
554                    }
555                }
556            }
557            return h
558        }
559    });
560
561    function extendRemove(a, b) {
562        $.extend(a, b);
563        for (var c in b) {
564            if (b[c] == null) {
565                a[c] = null
566            }
567        }
568        return a
569    }
570    $.fn.countdown = function(a) {
571        var b = Array.prototype.slice.call(arguments, 1);
572        if (a == 'getTimes' || a == 'settings') {
573            return $.countdown['_' + a + 'Countdown'].apply($.countdown, [this[0]].concat(b))
574        }
575        return this.each(function() {
576            if (typeof a == 'string') {
577                $.countdown['_' + a + 'Countdown'].apply($.countdown, [this].concat(b))
578            } else {
579                $.countdown._attachCountdown(this, a)
580            }
581        })
582    };
583    $.countdown = new Countdown()
584})(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.