PageSourceSearch

https://distribucionmayorista.online/modules/bonpromotopbanner/views/js/jquery.countdown.js

js distribucionmayorista.online collected 2026-10-04 13:26:36 UTC 4,612 bytes, 151 lines download raw bytes

1/*!
2 * The Final Countdown for jQuery v2.1.0 (http://hilios.github.io/jQuery.countdown/)
3 * Copyright (c) 2015 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($){
23
24    // Number of seconds in every time division
25    var days	= 24*60*60,
26        hours	= 60*60,
27        minutes	= 60;
28
29    // Creating the plugin
30    $.fn.topcountdown = function(prop){
31
32        var options = $.extend({
33            callback	: function(){},
34            timestamp	: 0
35        },prop);
36
37        var left, d, h, m, s, positions;
38
39        // Initialize the plugin
40        init(this, options);
41
42        positions = this.find('.position');
43
44        (function tick(){
45
46            // Time left
47            left = Math.floor((options.timestamp - (new Date())) / 1000);
48
49            if(left < 0){
50                left = 0;
51            }
52
53            // Number of days left
54            d = Math.floor(left / days);
55            updateDuo(0, 1, d);
56            left -= d*days;
57
58            // Number of hours left
59            h = Math.floor(left / hours);
60            updateDuo(2, 3, h);
61            left -= h*hours;
62
63            // Number of minutes left
64            m = Math.floor(left / minutes);
65            updateDuo(4, 5, m);
66            left -= m*minutes;
67
68            // Number of seconds left
69            s = left;
70            updateDuo(6, 7, s);
71
72            // Calling an optional user supplied callback
73            options.callback(d, h, m, s);
74
75            // Scheduling another call of this function in 1s
76            setTimeout(tick, 1000);
77        })();
78
79        // This function updates two digit positions at once
80        function updateDuo(minor,major,value){
81            switchDigit(positions.eq(minor),Math.floor(value/10)%10);
82            switchDigit(positions.eq(major),value%10);
83        }
84
85        return this;
86    };
87
88
89    function init(elem, options){
90        elem.addClass('countdownHolder');
91
92        // Creating the markup inside the container
93        $.each(['Days','Hours','Minutes','Seconds'],function(i){
94            $('<span class="count'+this+'">').html(
95                '<span class="position">\
96                    <span class="digit static">0</span>\
97                </span>\
98                <span class="position">\
99                    <span class="digit static">0</span>\
100                </span>'
101            ).appendTo(elem);
102
103            if(this!="Seconds"){
104                elem.append('<span class="countDiv countDiv'+i+'">:</span>');
105            }
106        });
107
108    }
109
110    // Creates an animated transition between the two numbers
111    function switchDigit(position,number){
112
113        var digit = position.find('.digit')
114
115        if(digit.is(':animated')){
116            return false;
117        }
118
119        if(position.data('digit') == number){
120            // We are already showing this number
121            return false;
122        }
123
124        position.data('digit', number);
125
126        var replacement = $('<span>',{
127            'class':'digit',
128            css:{
129                top:'-2.1em',
130                opacity:0
131            },
132            html:number
133        });
134
135        // The .static class is added when the animation
136        // completes. This makes it run smoother.
137
138        digit
139            .before(replacement)
140            .removeClass('static')
141            .animate({top:'2.5em',opacity:0}
141,'fast',function(){
142                digit.remove();
143            })
144
145        replacement
146            .delay(100)
147            .animate({top:0,opacity:1},'fast',function(){
148                replacement.addClass('static');
149            });
150    }
151})(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.