PageSourceSearch

http://eezitec.com/js/script303a.js?ver=4.7.21.34

js eezitec.com collected 2026-09-27 11:47:19 UTC 20,589 bytes, 533 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    function add_debug_message(product_id, debug) {
5        if(debug){
6            if(debug.debug_display_type == 'log' || debug.debug_display_type == 'both'){
7                console.log(product_id, debug);
8            }
9            
10            if(debug.debug_display_type == 'screen' || debug.debug_display_type == 'both'){
11                if($('#pi-edd-debug-msg-'+product_id).length > 0){
12                    $('#pi-edd-debug-msg-'+product_id).html(debug.debug_message);
13                }else{
14                    $('.pi-estimate-' + product_id).after('<div class="debug-info-container"><a class="debug-info-button" data-target="'+product_id+'" title="Click to view the information used to calculate the estimate date"></a><div class="pi-edd-debug-msg" id="pi-edd-debug-msg-'+product_id+'">'+debug.debug_message+'</div></div>');
15                }
16            }
17        }
18    }
19
20    function debug_info_toggle() {
21
22        $(document).on('click', '.debug-info-button', function (e) {
23            e.preventDefault();
24            var target = $(this).data('target');
25            $('#pi-edd-debug-msg-' + target).toggle();
26        }
27        );
28    }
29    debug_info_toggle();
30
31    function variable_product_estimate() {
32        this.reset_called_for_product = '';
33        this.init = function () {
34            this.variation_change();
35            this.variation_reset();
36            /** woocommerce bundled product plugin */
37            this.variation_change_woobundle();
38            this.variation_reset_woobundle();
39            /** end */
40            this.customTrigger();
41        }
42
43        this.customTrigger = function () {
44            var parent = this;
45            jQuery(document).on('pi_edd_custom_get_estimate_trigger', function (e, product_id, variation_id) {
46                parent.set_loading(product_id);
47                parent.get_estimate_msg_by_ajax(variation_id).done(function (response) {
48                    parent.add_estimate_msg(product_id, response.estimate_msg);
49                    add_debug_message(product_id, response.debug);
50                    jQuery(document).trigger('pi_edd_variation_estimate_loaded', [response, product_id, variation_id]);
51                }).always(function () {
52                    parent.remove_loading(product_id);
53                });
54
55            });
56        }
57
58        this.variation_change = function () {
59            var parent = this;
60            $(document).on('show_variation.pi_edd_variation_change', "form.variations_form", function (event, data) {
61
62                /**
63                 * using this we can prevent the default action of the event
64                 */
65                var get_estimate_event = jQuery.Event('pi_edd_get_single_variation_product_estimate');
66
67                $(document).trigger(get_estimate_event, {'element': this, 'data': data});
68
69                if (get_estimate_event.isDefaultPrevented()) {
70                    return;
71                }
72
73                var form = $(event.target).closest('form.variations_form');
74                var product_id = form.data('product_id');
75                if (data?.variation_id) {
76                    var variation_id = data.variation_id;
77                    if (pi_edd_data.load_single_by_ajax) {
78                        parent.set_loading(product_id);
79                        parent.get_estimate_msg_by_ajax(variation_id).done(function (response) {
80                            parent.add_estimate_msg(product_id, response.estimate_msg);
81                            add_debug_message(product_id, response.debug);
82                            jQuery(document).trigger('pi_edd_variation_estimate_loaded', [response, product_id, variation_id]);
83                        }).always(function () {
84                            parent.remove_loading(product_id);
85                        });
86                    } else {
87                        var estimate_msg = parent.get_estimate_msg_from_data(variation_id, data);
88                        parent.add_estimate_msg(product_id, estimate_msg);
89                    }
90                }
91
92            });
93
94        }
95
96        /**
97         * only used for woocommerce bundle product plugin
98         */
99        this.variation_change_woobundle = function () {
100            var parent = this;
101            $(document).on('show_variation.pi_edd_variation_change', ".bundled_item_cart_content.variations_form", function (event, data) {
102
103                /**
104                 * using this we can prevent the default action of the event
105                 */
106                var get_estimate_event = jQuery.Event('pi_edd_get_single_variation_product_estimate');
107
108                $(document).trigger(get_estimate_event, {'element': this, 'data': data});
109
110                if (get_estimate_event.isDefaultPrevented()) {
111                    return;
112                }
113
114                var product_id =  $(this).data('product_id');
115                console.log(product_id);
116                if (data?.variation_id) {
117                    var variation_id = data.variation_id;
118                    if (pi_edd_data.load_single_by_ajax) {
119                        parent.set_loading(product_id);
120                        parent.get_estimate_msg_by_ajax(variation_id).done(function (response) {
121                            parent.add_estimate_msg(product_id, response.estimate_msg);
122                            add_debug_message(product_id, response.debug);
123                            jQuery(document).trigger('pi_edd_variation_estimate_loaded', [response, product_id, variation_id]);
124                        }).always(function () {
125                            parent.remove_loading(product_id);
126                        });
127                    } else {
128                        var estimate_msg = parent.get_estimate_msg_from_data(variation_id, data);
129                        parent.add_estimate_msg(product_id, estimate_msg);
130                    }
131                }
132
133            });
134
135        }
136
137        this.variation_reset = function () {
138            var parent = this;
139            $(document).on('reset_data.pi_edd_variation_reset', "form.variations_form", function (event, data) {
140
141                /**
142                 * using this we can prevent the default action of the event
143                 */
144                var get_estimate_event = jQuery.Event('pi_edd_get_single_variation_product_estimate');
145
146                $(document).trigger(get_estimate_event, {'element': this, 'data': data});
147
148                if (get_estimate_event.isDefaultPrevented()) {
149                    return;
150                }
151                
152                var form = $(event.target).closest('form.variations_form');
153                var product_id = form.data('product_id');
154                parent.no_variation_selected(product_id);
155            });
156        }
157
158        /**
159         * only used for woocommerce bundle product plugin
160         */
161        this.variation_reset_woobundle = function () {
162            var parent = this;
163            $(document).on('reset_data.pi_edd_variation_reset', ".bundled_item_cart_content.variations_form", function (event, data) {
164                var product_id = $(this).data('product_id');
165                parent.no_variation_selected(product_id);
166            });
167        }
168
169        this.get_estimate_msg_from_data = function (product_id, data) {
170            return data.estimate_msg;
171        }
172
173        this.get_estimate_msg_by_ajax = function (product_id) {
174            var action = 'pi-get-single-product-estimate';
175            return $.ajax({
176                url: pi_edd_data.wc_ajax_url.toString().replace('%%endpoint%%', action),
177                method: 'POST',
178                dataType: 'json',
179                data: {
180                    product_id: product_id,
181                }
182            });
183        }
184
185        this.set_loading = function (product_id) {
186            $('.pi-estimate-' + product_id).addClass('pi-loading');
187        }
188
189        this.remove_loading = function (product_id) {
190            $('.pi-estimate-' + product_id).removeClass('pi-loading');
191        }
192
193        this.add_estimate_msg = function (product_id, msg) {
194            $('.pi-estimate-' + product_id).html(msg);
195            jQuery(document).trigger('pi_edd_update_counter');
196        }
197
198        this.no_variation_selected = function (product_id) {
199            var parent = this;
200
201            if ('first-variation' == pi_edd_data.show_first_variation_estimate) {
202                /**
203                 * reset_data event is fired 3 times on every reset so to avoid making multiple request we have added this check so that it only make one request
204                 */
205                if (parent.reset_called_for_product != product_id) {
206                    this.set_loading(product_id);
207                    this.get_estimate_msg_by_ajax(product_id).done(function (response) {
208                        parent.add_estimate_msg(product_id, response.estimate_msg);
209                        add_debug_message(product_id, response.debug);
210                    }).always(function () {
211                        parent.reset_called_for_product = '';
212                        parent.remove_loading(product_id);
213                    });
214                    parent.reset_called_for_product = product_id;
215                }
216            } else {
217                this.add_estimate_msg(product_id, pi_edd_data.no_variation_selected_msg);
218            }
219        }
220
221    }
222
223    function simple_product_load_by_ajax() {
224        this.products = [];
225        this.init = function () {
226            this.get_estimates();
227            this.custom_trigger();
228        }
229
230        this.custom_trigger = function () {
231            var parent = this;
232            jQuery(document).on('pi_edd_load_loop_ajax pisol_shipping_address_updated pisol_load_single_product_estimate', function () {
233                parent.get_estimates();
234            });
235        }
236
237        this.get_products = function () {
238            var parent = this;
239            jQuery(".pi-edd-ajax-simple").each(function () {
240                var id = $(this).data('product');
241                var type = $(this).data('type');
242                var message = $(this).data('message');
243                parent.products.push({ 'product_id': id, 'type': type, 'message': message });
244            });
245        }
246
247        this.get_estimates = function () {
248            this.get_products();
249            var parent = this;
250            if (this.products.length > 0) {
251                var action = 'pi-get-bulk-product-estimate';
252
253                jQuery.each(parent.products, function (index, product) {
254                    parent.set_loading(product.product_id);
255                });
256
257                $.ajax({
258                    url: pi_edd_data.wc_ajax_url.toString().replace('%%endpoint%%', action),
259                    method: 'POST',
260                    dataType: 'json',
261                    data: {
262                        products: parent.products,
263                    }
264                }).done(function (response) {
265                    parent.set_estimate_msgs(response.estimates);
266                    parent.set_debug_msgs(response.debug);
267                });
268            }
269        }
270
271        this.set_debug_msgs = function (debug) {
272            if(debug){
273                jQuery.each(debug, function (product_id, data) {
274                    add_debug_message(product_id, data);
275                });
276            }
277        }
278
279        this.set_estimate_msgs = function (estimates) {
280            var parent = this;
281            $.each(estimates, function (product_id, msg) {
282                parent.set_estimate_msg(product_id, msg)
283            });
284        }
285
286        this.set_estimate_msg = function (product_id, msg) {
287            $('.pi-estimate-' + product_id).html(msg);
288            jQuery(document).trigger('pi_edd_update_counter',{'product_id': product_id, 'msg': msg});
289            this.remove_loading(product_id);
290        }
291
292        this.set_loading = function (product_id) {
293            $('.pi-estimate-' + product_id).addClass('pi-loading');
294        }
295
296        this.remove_loading = function (product_id) {
297            $('.pi-estimate-' + product_id).removeClass('pi-loading');
298        }
299    }
300
301    function frontEndVariables() {
302        this.init = function () {
303            this.detect();
304        }
305
306        this.detect = function () {
307            var ids = [];
308            jQuery('.pi-min-date').each(function () {
309                var element_id = jQuery(this).data('id');
310                if (element_id && !isNaN(element_id)) {
311                    ids.push(element_id);
312                }
313            });
314
315            jQuery('.pi-max-date').each(function () {
316                var element_id = jQuery(this).data('id');
317                if (element_id && !isNaN(element_id)) {
318                    ids.push(element_id);
319                }
320            });
321
322            jQuery('.pi-min-days').each(function () {
323                var element_id = jQuery(this).data('id');
324                if (element_id && !isNaN(element_id)) {
325                    ids.push(element_id);
326                }
327            });
328
329            jQuery('.pi-max-days').each(function () {
330                var element_id = jQuery(this).data('id');
331                if (element_id && !isNaN(element_id)) {
332                    ids.push(element_id);
333                }
334            });
335
336            jQuery('.pi-date').each(function () {
337                var element_id = jQuery(this).data('id');
338                if (element_id && !isNaN(element_id)) {
339                    ids.push(element_id);
340                }
341            });
342
343            jQuery('.pi-days').each(function () {
344                var element_id = jQuery(this).data('id');
345                if (element_id && !isNaN(element_id)) {
346                    ids.push(element_id);
347                }
348            });
349
350            jQuery('.pi-min-preparation-days').each(function () {
351                var element_id = jQuery(this).data('id');
352                if (element_id && !isNaN(element_id)) {
353                    ids.push(element_id);
354                }
355            });
356
357            jQuery('.pi-max-preparation-days').each(function () {
358                var element_id = jQuery(this).data('id');
359                if (element_id && !isNaN(element_id)) {
360                    ids.push(element_id);
361                }
362            });
363
364            jQuery('.pi-preparation-days').each(function () {
365                var element_id = jQuery(this).data('id');
366                if (element_id && !isNaN(element_id)) {
367                    ids.push(element_id);
368                }
369            });
370
371
372            if (ids.length > 0) {
373                this.ajaxCall(ids);
374            }
375        }
376
377        this.ajaxCall = function (ids) {
378            var parent = this;
379            var action = 'get_estimate_dates';
380            jQuery.ajax({
381                url: pi_edd_data.wc_ajax_url.toString().replace('%%endpoint%%', action),
382                method: 'post',
383                data: {
384                    ids: ids,
385                },
386                success: function (response) {
387                    if (response?.product_estimates) {
388                        parent.replaceElements(response.product_estimates)
389                    }
390                }
391            });
392        }
393
394        this.replaceElements = function (estimates) {
395            var parent = this;
396            jQuery.each(estimates, function (id, estimate) {
397                parent.minDate(id, estimate.min_date);
398                parent.minDays(id, estimate.min_days);
399                parent.maxDate(id, estimate.max_date);
400                parent.maxDays(id, estimate.max_days);
401                parent.date(id, estimate.date);
402                parent.days(id, estimate.days);
403
404                parent.minPreparationDays(id, estimate.min_preparation_days);
405                parent.maxPreparationDays(id, estimate.max_preparation_days);
406                parent.preparationDays(id, estimate.preparation_days);
407            })
408        }
409
410        this.minDate = function (id, min_date) {
411            if (jQuery('.pi-min-date-' + id).length > 0) {
412                jQuery('.pi-min-date-' + id).html(min_date);
413            }
414        }
415
416        this.minDays = function (id, min_days) {
417            if (jQuery('.pi-min-days-' + id).length > 0) {
418                jQuery('.pi-min-days-' + id).html(min_days);
419            }
420        }
421
422        this.maxDate = function (id, max_date) {
423            if (jQuery('.pi-max-date-' + id).length > 0) {
424                jQuery('.pi-max-date-' + id).html(max_date);
425            }
426        }
427
428        this.maxDays = function (id, max_days) {
429            if (jQuery('.pi-max-days-' + id).length > 0) {
430                jQuery('.pi-max-days-' + id).html(max_days);
431            }
432        }
433
434        this.date = function (id, date) {
435            if (jQuery('.pi-date-' + id).length > 0) {
436                jQuery('.pi-date-' + id).html(date);
437            }
438        }
439
440        this.days = function (id, days) {
441            if (jQuery('.pi-days-' + id).length > 0) {
442                jQuery('.pi-days-' + id).html(days);
443            }
444        }
445
446        this.minPreparationDays = function (id, min_days) {
447            if (jQuery('.pi-min-preparation-days-' + id).length > 0) {
448                jQuery('.pi-min-preparation-days-' + id).html(min_days);
449            }
450        }
451
452        this.maxPreparationDays = function (id, max_days) {
453            if (jQuery('.pi-max-preparation-days-' + id).length > 0) {
454                jQuery('.pi-max-preparation-days-' + id).html(max_days);
455            }
456        }
457
458        this.preparationDays = function (id, days) {
459            if (jQuery('.pi-preparation-days-' + id).length > 0) {
460                jQuery('.pi-preparation-days-' + id).html(days);
461            }
462        }
463    }
464
465    function updateCountdown() {
466        jQuery(".pi-edd-counter").each(function () {//23 56
467
468            try {
469                // Get the countdown details from the data attribute
470                let countdownElement = $(this);
471                let remainingTotalMinutes = parseInt(countdownElement.data('min'), 10);
472        
473                // Calculate the remaining time in minutes
474        
475                // If the remaining time has reached zero or negative, reload the page
476                if (remainingTotalMinutes <= 0) {
477                location.reload();
478                return; // Stop the countdown
479                }
480        
481                // Calculate hours and minutes from remaining total minutes
482                let remainingHoursToShow = Math.floor(remainingTotalMinutes / 60);
483                let remainingMinutesToShow = remainingTotalMinutes % 60;
484        
485                // Display the countdown
486                let countdownElementText = '';
487
488                let message_template = countdownElement.data('message') ?? '[hr] hours [min] minutes';
489
490                
491                countdownElementText = message_template.replace('[hr]',  remainingHoursToShow).replace('[min]', remainingMinutesToShow);
492                
493                countdownElement.text(countdownElementText);
494
495                remainingTotalMinutes--;
496
497                countdownElement.data('min', remainingTotalMinutes);
498
499            } catch (error) {
500                console.error('Error updating countdown:', error);
501            }
502
503        });
504    }
505    
506      
507
508    jQuery(function ($) {
509        var variable_product_estimate_obj = new variable_product_estimate();
510        variable_product_estimate_obj.init();
511
512        var simple_product_load_by_ajax_obj = new simple_product_load_by_ajax();
513        simple_product_load_by_ajax_obj.init();
514
515        var frontEndVariablesObj = new frontEndVariables();
516        frontEndVariablesObj.init();
517
518        // Update the countdown every second
519      setInterval(function(){
520        jQuery(document).trigger('pi_edd_update_counter');
521      }, 60000);
522    
523      // Initial update
524
525      jQuery(document).on('pi_edd_update_counter', function () {    
526            updateCountdown();
527      });
528     
529      updateCountdown();
530
531    });
532
533})(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.