PageSourceSearch

https://top-bit.biz/wp-content/plugins/wc-dynamic-pricing-and-disc…/assets/scripts.js?ver=2.3.9

js top-bit.biz collected 2026-10-08 06:31:30 UTC 4,037 bytes, 119 lines download raw bytes

1/**
2 * WooCommerce Dynamic Pricing & Discounts - Promotion - Countdown Timer - Scripts
3 */
4jQuery(document).ready(function() {
5
6    /**
7     * Initialize live product update
8     */
9    jQuery('.rp_wcdpd_promotion_countdown_timer_container').each(function() {
10
11        // Get product id
12        var product_id = jQuery(this).data('product_id');
13
14        // Initialize live update
15        jQuery(this).rightpress_live_product_update({
16
17            // Params
18            ajax_url:   rp_wcdpd_promotion_countdown_timer.ajaxurl,
19            action:     'rp_wcdpd_promotion_countdown_timer_update',
20            product_id: product_id,
21
22            // Callback
23            response_handler: function(response) {
24
25                // Display timer
26                if (typeof response === 'object' && typeof response.result !== 'undefined' && response.result === 'success' && response.display) {
27
28                    // Remove outdated timer
29                    if (typeof jQuery(this).data('rp-wcdpd-hash') !== 'undefined' && jQuery(this).data('rp-wcdpd-hash') !== response.hash) {
30                        jQuery(this).html('');
31                        jQuery(this).removeData('rp-wcdpd-hash');
32                    }
33
34                    // Display timer only if it's not displayed already
35                    if (typeof jQuery(this).data('rp-wcdpd-hash') === 'undefined') {
36
37                        // Update html
38                        jQuery(this).data('rp-wcdpd-hash', response.hash);
39                        jQuery(this).html(response.html);
40
41                        // Initialize timer
42                        initialize_timer(jQuery(this).find('.rp_wcdpd_promotion_countdown_timer'));
43
44                        // Show timer
45                        jQuery(this).slideDown();
46                    }
47                }
48                // Hide timer
49                else {
50                    jQuery(this).slideUp();
51                    jQuery(this).html('');
52                    jQuery(this).removeData('rp-wcdpd-hash');
53                }
54            }
55        });
56    });
57
58    /**
59     * Initialize timer
60     */
61    function initialize_timer(element)
62    {
63        // Get end time in browser's time
64        var end_time = new Date();
65        end_time = new Date(end_time.getTime() + (element.data('seconds') * 1000));
66
67        // Select elements
68        var element_days    = element.find('.rp_wcdpd_promotion_countdown_timer_days_value');
69        var element_hours   = element.find('.rp_wcdpd_promotion_countdown_timer_hours_value');
70        var element_minutes = element.find('.rp_wcdpd_promotion_countdown_timer_minutes_value');
71        var element_seconds = element.find('.rp_wcdpd_promotion_countdown_timer_seconds_value');
72
73        // Initialize
74        update_timer();
75        var interval = setInterval(update_timer, 1000);
76
77        /**
78         * Update timer
79         */
80        function update_timer()
81        {
82            // Get remaining time
83            var t = get_time_remaining(end_time);
84
85            // Update elements
86            element_days.html(('0' + t.days).slice(-2));
87            element_hours.html(('0' + t.hours).slice(-2));
88            element_minutes.html(('0' + t.minutes).slice(-2));
89            element_seconds.html(('0' + t.seconds).slice(-2));
90
91            // Clear interval when time runs up
92            if (t.total <= 0) {
93                clearInterval(interval);
94                element.remove();
95            }
96        }
97    }
98
99    /**
100     * Get time remaining
101     */
102    function get_time_remaining(end_time)
103    {
104        var t = Date.parse(end_time) - Date.parse(new Date());
105        var seconds = Math.floor((t / 1000) % 60);
106        var minutes = Math.floor((t / 1000 / 60) % 60);
107        var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
108        var days = Math.floor(t / (1000 * 60 * 60 * 24));
109
110        return {
111            'total':    t,
112            'days':     days,
113            'hours':    hours,
114            'minutes':  minutes,
115            'seconds':  seconds
116        };
117    }
118
119});

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.