PageSourceSearch

https://www.slclab.com/js/country.js

js slclab.com collected 2026-10-08 21:42:56 UTC 9,847 bytes, 230 lines download raw bytes

1(function ($) {
2    $.fn.county = function (options) {
3        var settings = $.extend({ endDateTime: new Date(), animation: 'fade', reflection: true, reflectionOpacity: 0.2, speed: 500, theme: 'black' }, options);
4
5        return this.each(function () {
6            var timeoutInterval = null;
7            var container = $(this);
8            container.addClass('county ' + settings.theme);
9            container.append('<span class="county-days-wrapper first"><span class="county-days">000</span></span><span class="county-hours-wrapper separator-left border-separator-right"><span class="county-hours">00</span></span><span class="county-minutes-wrapper separator-left separator-left"><span class="county-minutes">00</span></span><span class="county-seconds-wrapper separator-left last"><span class="county-seconds">00</span></span><div class="clearfix"></div><span class="county-label-days">Days</span><span class="county-label-hours">Hours</span><span class="county-label-minutes">Min<i>utes</i></span><span class="county-label-seconds">Sec<i>onds</i></span>');
10            if (container.attr('id') == undefined || container.attr('id') == null) {
11                container.attr('id', Math.random());
12            }
13            var w = 0;
14            container.find('>span').each(function () {
15                if ($(this).hasClass('county-days-wrapper') ||
16                $(this).hasClass('county-hours-wrapper') ||
17                $(this).hasClass('county-minutes-wrapper') ||
18                $(this).hasClass('county-seconds-wrapper'))
19                    w += $(this).outerWidth();
20            });
21
22            container.css({ width: w });
23
24            container.find('>span>span').each(function () {
25
26                $(this).css({ width: $(this).width(), height: $(this).height() });
27                $(this).parent().css({ width: $(this).width() });
28                $(this).addClass('loaded');
29                var daysLabel = container.find('.county-label-days');
30                var hoursLabel = container.find('.county-label-hours');
31                var minutesLabel = container.find('.county-label-minutes');
32                var secondsLabel = container.find('.county-label-seconds');
33                if ($(this).hasClass('county-days')) {
34                    daysLabel.css({ width: $(this).parent().outerWidth() });
35                }
36                if ($(this).hasClass('county-hours')) {
37                    hoursLabel.css({ width: $(this).parent().outerWidth() });
38                }
39                if ($(this).hasClass('county-minutes')) {
40                    minutesLabel.css({ width: $(this).parent().outerWidth() });
41                }
42                if ($(this).hasClass('county-seconds')) {
43                    secondsLabel.css({ width: $(this).parent().outerWidth() });
44                }
45            });
46
47            var reflectionContainer = container.clone().css({ opacity: settings.reflectionOpacity }).attr('id', container.attr('id') + '-refl').addClass('county-reflection');
48            if (settings.reflection)
49                container.after(reflectionContainer);
50
51            updateCounter();
52
53            getCountDown();
54
55            function getCountDown() {
56                clearTimeout(timeoutInterval);
57                timeoutInterval = setTimeout(function () {
58
59                    updateCounter();
60
61                }, 1000);
62            }
63            function updateCounter() {
64                var countDown = getCurrentCountDown();
65                var days = container.find('.county-days');
66                var hours = container.find('.county-hours');
67                var minutes = container.find('.county-minutes');
68                var seconds = container.find('.county-seconds');
69
70                var dayVal = days.html();
71                var hourVal = hours.html();
72                var minuteVal = minutes.html();
73                var secondVal = seconds.html();
74
75                if (dayVal == countDown.days) {
76                    days.html(countDown.days);
77                }
78                else {
79                    if (settings.reflection)
80                        aimateObject(days, reflectionContainer.find('.county-days'), dayVal, countDown.days, settings.animation);
81                    else
82                        aimateObject(days, null, dayVal, countDown.days, settings.animation);
83                }
84
85                if (hourVal == countDown.hours)
86                    hours.html(countDown.hours);
87                else {
88                    if (settings.reflection)
89                        aimateObject(hours, reflectionContainer.find('.county-hours'), hourVal, countDown.hours, settings.animation);
90                    else
91                        aimateObject(hours, null, hourVal, countDown.hours, settings.animation);
92                }
93
94                if (minuteVal == countDown.minutes)
95                    minutes.html(countDown.minutes);
96                else {
97                    if (settings.reflection)
98                        aimateObject(minutes, reflectionContainer.find('.county-minutes'), minuteVal, countDown.minutes, settings.animation);
99                    else
100                        aimateObject(minutes, null, minuteVal, countDown.minutes, settings.animation);
101                }
102                if (secondVal == countDown.seconds)
103                    seconds.html(countDown.seconds);
104                else {
105                    if (settings.reflection)
106                        aimateObject(seconds, reflectionContainer.find('.county-seconds'), secondVal, countDown.seconds, settings.animation);
107                    else
108                        aimateObject(seconds, null, secondVal, countDown.seconds, settings.animation);
109                }
110
111                getCountDown();
112            }
113            function aimateObject(element, reflectionElement, oldValue, newValue, type) {
114                if (type == 'fade') {
115                    element.fadeOut('fast').fadeIn('fast').html(newValue);
116                    if (settings.reflection)
117                        reflectionElement.fadeOut('fast').fadeIn('fast').html(newValue);
118                }
119                else if (type == 'scroll') {
120                    var copy = element.clone();
121                    var reflectionCopy = null;
122
123                    if (settings.reflection)
124                        reflectionCopy = reflectionElement.clone();
125
126                    var marginTop = copy.outerHeight();
127
128                    copy.css({ marginTop: -marginTop });
129                    copy.html(newValue);
130                    copy.prependTo(element.parent());
131
132                    if (settings.reflection) {
133                        reflectionCopy.css({ marginTop: -marginTop });
134                        reflectionCopy.html(newValue);
135                        reflectionCopy.prependTo(reflectionElement.parent());
136                    }
137
138                    element.animate({ marginTop: marginTop }, settings.speed, function () { $(this).remove(); });
139                    copy.animate({ marginTop: 0 }, settings.speed, function () { });
140
141                    if (settings.reflection) {
142                        reflectionElement.animate({ marginTop: marginTop }, settings.speed, function () { $(this).remove(); });
143                        reflectionCopy.animate({ marginTop: 0 }, settings.speed, function () { });
144                    }
145
146                }
147
148            }
149            function getCurrentCountDown() {
150
151                //var endDateTime = new Date('2012/12/25 10:00:00');
152                var currentDateTime = new Date();
153
154                var diff = parseFloat(settings.endDateTime - currentDateTime);
155
156                var seconds = 0;
157                var minutes = 0;
158                var hours = 0;
159                var total = parseFloat(((((diff / 1000.0) / 60.0) / 60.0) / 24.0));
160
161                var days = parseInt(total);
162
163                total -= days;
164
165                total *= 24.0;
166
167                hours = parseInt(total);
168
169                total -= hours;
170
171                total *= 60.0;
172
173                minutes = parseInt(total);
174
175                total -= minutes;
176
177                total *= 60;
178
179                seconds = parseInt(total);
180
181                return { days: formatNumber(Math.max(0, days), true), hours: formatNumber(Math.max(0, hours), false), minutes: formatNumber(Math.max(0, minutes), false), seconds: formatNumber(Math.max(0, seconds), false) };
182
183            }
184            function formatNumber(number, isday) {
185                var strNumber = number.toString();
186                if (!isday) {
187                    if (strNumber.length == 1)
188                        return '0' + strNumber;
189                    else
190                        return strNumber;
191                }
192                else {
193                    if (strNumber.length == 1)
194                        return '00' + strNumber;
195                    else if (strNumber == 2)
196                        return '0' + strNumber;
197                    else
198                        return strNumber;
199                }
200            }
201            function getHunderth(number) {
202                var strNumber = '' + number;
203
204                if (strNumber.length == 3)
205                    return strNumber.substr(0, 1);
206                else
207                    return '0';
208            }
209            function getTenth(number) {
210
211                var strNumber = '' + number;
212
213                if (strNumber.length == 2)
214                    return strNumber.substr(0, 1);
215                else
216                    return '0';
217            }
218
219            function getUnit(number) {
220                var strNumber = '' + number;
221
222                if (strNumber.length >= 1)
223                    return strNumber.substr(0, 1);
224                else
225                    return '0';
226            }
227            return this;
228        });
229    }
230})(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.