PageSourceSearch

https://www.uaza.co.za/wp-content/themes/denorious/js/jquery.downCount.js?ver=1.0.0

js uaza.co.za collected 2026-09-25 06:41:34 UTC 3,912 bytes, 109 lines download raw bytes

1/**
2 * downCount: Simple Countdown clock with offset
3 * Author: Sonny T. <[email protected]>, sonnyt.com
4 */
5
6(function ($) {
7
8    $.fn.downCount = function (options, callback) {
9        var settings = $.extend({
10                date: null,
11                offset: null
12            }, options);
13
14        // Throw error if date is not set
15        if (!settings.date) {
16            $.error('Date is not defined.');
17        }
18
19        // Throw error if date is set incorectly
20        if (!Date.parse(settings.date)) {
21            $.error('Incorrect date format, it should look like this, 12/24/2012 12:00:00.');
22        }
23
24        // Save container
25        var container = this;
26
27        /**
28         * Change client's local date to match offset timezone
29         * @return {Object} Fixed Date object.
30         */
31        var currentDate = function () {
32            // get client's current date
33            var date = new Date();
34			
35			// get timedifference between UTC and local time (in munites)
36			//var n = d.getTimezoneOffset();
37
38            // turn date to utc
39            var utc = date.getTime() + (date.getTimezoneOffset() * 60000);
40
41            // set new Date object
42            var new_date = new Date(utc + (3600000*settings.offset));
43			
44			//var brand_new_date = new_date - 25200000; /*This is for changing client time calculation issues as needed*/
45
46            return new_date;
47        };
48
49        /**
50         * Main downCount function that calculates everything
51         */
52        function countdown () {
53            var target_date = new Date(settings.date), // set target date
54                current_date = currentDate(); // get fixed current date
55
56            // difference of dates
57            var difference = target_date - current_date;
58
59            // if difference is negative than it's pass the target date
60            if (difference < 0) {
61                // stop timer
62                clearInterval(interval);
63
64                if (callback && typeof callback === 'function') callback();
65
66                return;
67            }
68
69            // basic math variables
70            var _second = 1000,
71                _minute = _second * 60,
72                _hour = _minute * 60,
73                _day = _hour * 24;
74
75            // calculate dates
76            var days = Math.floor(difference / _day),
77                hours = Math.floor((difference % _day) / _hour),
78                minutes = Math.floor((difference % _hour) / _minute),
79                seconds = Math.floor((difference % _minute) / _second);
80
81                // fix dates so that it will show two digets
82                days = (String(days).length >= 2) ? days : '0' + days;
83                hours = (String(hours).length >= 2) ? hours : '0' + hours;
84                minutes = (String(minutes).length >= 2) ? minutes : '0' + minutes;
85                seconds = (String(seconds).length >= 2) ? seconds : '0' + seconds;
86
87            // based on the date change the refrence wording
88            var ref_days = (days === 1) ? 'day' : 'days',
89                ref_hours = (hours === 1) ? 'hour' : 'hours',
90                ref_minutes = (minutes === 1) ? 'minute' : 'minutes',
91                ref_seconds = (seconds === 1) ? 'second' : 'seconds';
92
93            // set to DOM
94            container.find('.days').text(days);
95            container.find('.hours').text(hours);
96            container.find('.minutes').text(minutes);
97            container.find('.seconds').text(seconds);
98
99            container.find('.days_ref').text(ref_days);
100            container.find('.hours_ref').text(ref_hours);
101            container.find('.minutes_ref').text(ref_minutes);
102            container.find('.seconds_ref').text(ref_seconds);
103        };
104        
105        // start
106        var interval = setInterval(countdown, 1000);
107    };
108
109})(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.