PageSourceSearch

https://www.mugdali.com/modules/estimateddelivery/views/js/estimateddelivery-1.7.js

js mugdali.com collected 2026-10-07 00:18:41 UTC 6,153 bytes, 164 lines download raw bytes

1/**
2/** * Estimated Delivery - Front Office Feature
3 *
4 * NOTICE OF LICENSE
5 *
6 * @author    Pol Rué
7 * @copyright Smart Modules 2015
8 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
9 * @category Transport & Logistics
10 * Registered Trademark & Property of smart-modules.com
11 *
12 * ***************************************************
13 * *               Estimated Delivery                *
14 * *          http://www.smart-modules.com           *
15 * *                                                  *
16 * ***************************************************
17*/
18
19var ed_repo = false;
20
21function repopulateED(tries, check = true, e = false) {
22    // console.log({
23    //     tries: tries,
24    //     check: check,
25    //     e: e,
26    //     ed_repo: ed_repo,
27    //     ed_in_modal: ed_in_modal,
28    //     ed_placement: ed_placement
29    // });
30    if (ed_placement === 0) {
31        // Skip, default placement
32        // console.log('ED: skip, is default placement');
33        return;
34    }
35    if (check && ed_repo) {
36        // console.log('ED: Check and no repo. Aborting');
37        return false;
38    }
39
40    ed_repo = true;
41
42    if (tries === 0) {
43        return;
44    }
45
46    if (check || !e) {
47        // console.log('ED: Check elements');
48        const movedElement = $('#add-to-cart-or-refresh #estimateddelivery.moved');
49        const productElement = $('.product-information #estimateddelivery');
50
51        e = movedElement.length > 0 ? movedElement : (productElement.length > 0 ? productElement : false);
52
53        if (e) {
54            e.filter(':not(.hide-default)').remove();
55        } else {
56            setTimeout(() => {
57                repopulateED(tries - 1, false);
58            }, 200);
59            return;
60        }
61    }
62
63    setTimeout(() => {
64        // console.log('ED: Init placement');
65        ed_product_placement_init(10, 100);
66        ed_repo = false;
67    }, ed_refresh_delay);
68}
69
70let ac_init = false;
71// Cart Modal Display and Repopulate
72
73if (document.readyState !== 'loading') {
74    init_ac();
75} else {
76    document.addEventListener('DOMContentLoaded', function () {
77        init_ac();
78    });
79}
80function init_ac() {
81    if (ac_init) {
82        return;
83    }
84    ac_init = true;
85    setTimeout(function () {
86        $(document).ajaxComplete(function (ev, jqXHR, settings) {
87            if (typeof jqXHR.responseJSON !== 'undefined' && jqXHR.responseJSON != null) {
88                // console.log(jqXHR.responseJSON);
89                // console.log(settings.data);
90                let need_repopulate = checkRefreshOrUpdateFromSettings(settings.data);
91                if (typeof jqXHR.responseJSON.product_additional_info !== 'undefined' && (parseInt(jqXHR.responseJSON.id_product_attribute) > 0 || need_repopulate)) {
92                    // console.log('ED: repopulate');
93                    ed_pp = false;
94                    repopulateED(150);
95                }
96                if (typeof jqXHR.responseJSON.modal !== 'undefined' && jqXHR.responseJSON.modal) {
97                    if (ed_in_modal == 0)
98                        return false;
99                    //console.log('IN');
100                    var params = {}, hash;
101                    var vars = settings.data.split('&');
102                    for (var i = 0; i < vars.length; i++) {
103                        hash = vars[i].split('=');
104                        params[hash[0]] = hash[1];
105                    }
106                    params['modalAction'] = 1;
107                    params['ajax'] = 1;
108                    params['action'] = 'cart';
109                    var returnData = $.ajax({
110                        type: 'POST',
111                        headers: {"cache-control": "no-cache"},
112                        url: front_ajax_url,
113                        async: false,
114                        cache: false,
115                        dataType: "json",
116                        data: params,
117                        complete: function (res) {
118                            //console.log(res);
119                            if (res.statusText == 'OK') {
120                                return res;
121                            }
122                        }
123                    });
124                    if (returnData != '') {
125                        // var ed_data = '<div class="col-md-12">' + returnData.responseJSON + '</div>';
126                        var ed_data = returnData.responseJSON;
127                        var jsonArray = $.parseHTML(jqXHR.responseJSON.modal);
128                        var modalDom;
129                        for (var i = 0; i < jsonArray.length; i++) {
130                            if ($(jsonArray[i])[0] instanceof Element) {
131                                modalDom = $(jsonArray[i])[0];
132                            }
133                        }
134                        setTimeout(() => {
135                            if ($('#ed_modal').length == 0) {
136                                // $(modalDom).find('.modal-body .row .col-md-5 .row').append(ed_data);
137                                $(modalDom).find('.modal-body .cart-content').first().append(ed_data);
138                                var tmp = document.createElement("div");
139                                tmp.appendChild($(modalDom)[0]);
140                                jqXHR.responseJSON.modal = tmp.innerHTML;
141                            }
142                        }, 1500)
143                    }
144                }
145            }
146        });
147    }, ed_ajax_delay);
148
149    function checkRefreshOrUpdateFromSettings(url) {
150        if (url == '' || typeof url == 'undefined') {
151            return false;
152        }
153        let vars = url.split('&');
154        for (let i = 0; i < vars.length; i++) {
155            let hash = vars[i].split('=');
156            // console.log(hash[0] + ' >> ' + hash[1]);
157            // Check if hash[0] equals to refresh or update
158            if (hash[1] == 'refresh' || hash[1] == 'update') {
159                return true;
160            }
161        }
162        return false;
163    }
164}

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.