PageSourceSearch

https://www.lucciarrosticini.it/js/myscript.js?v=2.0

js lucciarrosticini.it collected 2026-10-06 20:05:34 UTC 26,401 bytes, 698 lines download raw bytes

1var tpj=jQuery;
2tpj.noConflict();
3
4tpj(document).ready(function() {
5
6    // DataTable ordinamento decrescente
7    if(tpj('.table_order_desc').length) {
8        tpj('.table_order_desc').DataTable({
9            lengthChange: false,
10            "order": [[0, "desc"]]
11        });
12    }
13
14    var apiRevoSlider = tpj('.tp-banner').show().revolution(
15        {
16            sliderType: "standard",
17            jsFileLocation: "include/rs-plugin/js/",
18            sliderLayout: "fullwidth",
19            dottedOverlay: "none",
20            delay: 9000,
21            navigation: {},
22            responsiveLevels: [1200, 992, 768, 480, 320],
23            gridwidth: 1140,
24            gridheight: 500,
25            lazyType: "none",
26            shadow: 0,
27            spinner: "off",
28            autoHeight: "off",
29            disableProgressBar: "on",
30            hideThumbsOnMobile: "off",
31            hideSliderAtLimit: 0,
32            hideCaptionAtLimit: 0,
33            hideAllCaptionAtLilmit: 0,
34            debugMode: false,
35            fallbacks: {
36                simplifyAll: "off",
37                disableFocusListener: false
38            },
39            navigation: {
40                keyboardNavigation: "off",
41                keyboard_direction: "horizontal",
42                mouseScrollNavigation: "off",
43                onHoverStop: "off",
44                touch: {
45                    touchenabled: "on",
46                    swipe_threshold: 75,
47                    swipe_min_touches: 1,
48                    swipe_direction: "horizontal",
49                    drag_block_vertical: false
50                },
51                arrows: {
52                    style: "ares",
53                    enable: true,
54                    hide_onmobile: false,
55                    hide_onleave: false,
56                    tmp: '<div class="tp-title-wrap">	<span class="tp-arr-titleholder">{{title}}</span> </div>',
57                    left: {
58                        h_align: "left",
59                        v_align: "center",
60                        h_offset: 10,
61                        v_offset: 0
62                    },
63                    right: {
64                        h_align: "right",
65                        v_align: "center",
66                        h_offset: 10,
67                        v_offset: 0
68                    }
69                }
70            }
71        });
72
73    apiRevoSlider.bind("revolution.slide.onloaded", function (e) {
74        SEMICOLON.slider.sliderParallaxDimensions();
75    });
76
77    tpj('#shop').isotope({
78        transitionDuration: '0.65s',
79        getSortData: {
80            name: '.product-title',
81            quantity: function (itemElem) {
82                if (tpj(itemElem).find('.product-qta').find('ins').length > 0) {
83                    var qta = tpj(itemElem).find('.product-qta ins').text();
84                } else {
85                    var qta = tpj(itemElem).find('.product-qta').text();
86                }
87
88                return parseInt(qta);
89            },
90            price_lh: function (itemElem) {
91                if (tpj(itemElem).find('.product-price').find('ins').length > 0) {
92                    var price = tpj(itemElem).find('.product-price ins').text();
93                } else {
94                    var price = tpj(itemElem).find('.product-price').text();
95                }
96
97                priceNum = price.split("€");
98
99                return parseFloat(priceNum[0]);
100            },
101            price_hl: function (itemElem) {
102                if (tpj(itemElem).find('.product-price').find('ins').length > 0) {
103                    var price = tpj(itemElem).find('.product-price ins').text();
104                } else {
105                    var price = tpj(itemElem).find('.product-price').text();
106                }
107
108                priceNum = price.split("€");
109
110                return parseFloat(priceNum[0]);
111            }
112        },
113        sortAscending: {
114            name: true,
115            quantity: true,
116            price_lh: false,
117            price_hl: false
118        }
119    });
120
121    tpj('.custom-filter:not(.no-count)').children('li:not(.widget-filter-reset)').each(function () {
122        var element = tpj(this),
123            elementFilter = element.children('a').attr('data-filter'),
124            elementFilterContainer = element.parents('.custom-filter').attr('data-container');
125
126        elementFilterCount = Number(jQuery(elementFilterContainer).find(elementFilter).length);
127
128        element.append('<span>' + elementFilterCount + '</span>');
129
130    });
131
132    tpj('.shop-sorting li').click(function () {
133        tpj('.shop-sorting').find('li').removeClass('active-filter');
134        tpj(this).addClass('active-filter');
135        var sortByValue = tpj(this).find('a').attr('data-sort-by');
136        tpj('#shop').isotope({sortBy: sortByValue});
137        return false;
138    });
139
140    if (tpj('.removeafterfiftysecond').length) {
141        setTimeout(function () {
142            tpj('.removeafterfiftysecond').fadeOut();
143        }, 5000);
144    }
145
146    // Calcolo prezzo spedizione ed elenco corrieri in base all'indirizzo scelto
147    if (tpj('#shipping-form-address_id').length && tpj('#section_shopping_method').length) {
148        tpj('#shipping-form-address_id').unbind("change", onSelectAddressID);
149        tpj('#shipping-form-address_id').bind("change", onSelectAddressID);
150        tpj('#shipping-form-address_id').trigger("change");
151    }
152
153    // Compilo i dati della fatturazione dal campo select
154    if (tpj('#billing-form-address_id').length) {
155        tpj('#billing-form-address_id').unbind("change", onSelectAddressBillingID);
156        tpj('#billing-form-address_id').bind("change", onSelectAddressBillingID);
157        tpj('#billing-form-address_id').trigger("change");
158    }
159
160    // Calcolo prezzo spedizione ed elenco corrieri in base alla città scelta
161    if (tpj('#shipping-form-cap').length && tpj('#section_shopping_method').length) {
162        tpj('#shipping-form-cap').unbind("change", onSelectCap);
163        tpj('#shipping-form-cap').bind("change", onSelectCap);
164        tpj('#shipping-form-cap').unbind("blur", onSelectCap);
165        tpj('#shipping-form-cap').bind("blur", onSelectCap);
166        tpj('#shipping-form-cap').trigger("change");
167    }
168
169    // Disattivo la selezione shop se seleziono un metodo di spedizione
170    if(tpj('input[name=shipping_method_id]').length){
171        tpj('input[name=shipping_method_id]').unbind("change", onChangeTypeShipping);
172        tpj('input[name=shipping_method_id]').bind("change", onChangeTypeShipping);
173    }
174
175    // Disattivo la selezione di un metodo di spedizione se seleziono uno shop
176    if(tpj('input[name=shop_id]').length){
177        tpj('input[name=shop_id]').unbind("change", onChangeTypeShipping);
178        tpj('input[name=shop_id]').bind("change", onChangeTypeShipping);
179    }
180
181    tpj('.datetimepicker3').datetimepicker({
182        format:'DD/MM/YYYY HH:mm'
183    });
184
185    tpj('.default-datepicker').datepicker({
186        autoclose: true,
187        format:'dd/mm/yyyy'
188    });
189
190    if (typeof data_ritiro !== 'undefined') {
191        tpj('.datetimepicker3').val(data_ritiro);
192    }
193});
194
195// Change action select address
196function onSelectAddressID(){
197    var address_id = tpj('#shipping-form-address_id').val();
198
199    if(address_id !== "") {
200        // Popolo form spedizione
201        tpj(".form-process").show();
202        MyScript.get_address_id(address_id, function(info_address){
203            tpj("#newAdrressSection").find("#shipping-form-companyname").val(info_address.company_name);
204            tpj("#newAdrressSection").find("#shipping-form-address").val(info_address.address);
205            tpj("#newAdrressSection").find("#shipping-form-city").val(info_address.city);
206            tpj("#newAdrressSection").find("#shipping-form-city-id").val(info_address.city_id);
207            tpj("#newAdrressSection").find("#shipping-form-cap").val(info_address.cap);
208            tpj("#newAdrressSection").find("#shipping-form-email").val(info_address.email);
209            tpj("#newAdrressSection").find("#shipping-form-phone").val(info_address.phone_1);
210            tpj(".form-process").hide();
211        });
212
213        // Recupero la lista dei metodi di spedizione
214        MyScript.get_shopping_method_by_address_id(address_id, function (shipping_method) {
215            let html = "";
216            if (shipping_method.length <= 0) {
217                html = "<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>";
218                tpj('#section_shopping_method').html(html);
219            } else {
220                html = "<table width='100%' class='nobottommargin'>";
221                for (var i = 0; i < shipping_method.length; i++) {
222                    var checked = "";
223                    if (typeof shopping_id_selected !== 'undefined') {
224                        if (shopping_id_selected === shipping_method[i].id) {
225                            checked = "checked";
226                        }
227                    }
228                    html += "<tr>";
229                    html += "<td>";
230                    html += "<input type='radio' id='radio-4-" + shipping_method[i].id + "shi' name='shipping_method_id' class='form-control radio-style' value='" + shipping_method[i].id + "' "+checked+"/>";
231                    html += "<label for='radio-4-" + shipping_method[i].id + "shi' class='radio-style-1-label'>" + shipping_method[i].name + "</label>";
232                    html += "</td>";
233                    if (shipping_method[i].shipping_time > 0) {
234                        html += "<td align='right'>";
235                        html += MyScriptLang.strConsegnaIn + " <b>" + shipping_method[i].shipping_time + " " + MyScriptLang.strOre + "</b>";
236                        html += "</td>";
237                    }
238                    html += "<td align='right'>";
239                    html += "<b>+ " + shipping_method[i].shipping_price + " €</b>";
240                    html += "</td>";
241                    html += "</tr>";
242                }
243                html += "</table>";
244                tpj('#section_shopping_method').html(html);
245
246                // Disattivo la selezione shop se seleziono un metodo di spedizione
247                if(tpj('input[name=shipping_method_id]').length){
248                    tpj('input[name=shipping_method_id]').unbind("change", onChangeTypeShipping);
249                    tpj('input[name=shipping_method_id]').bind("change", onChangeTypeShipping);
250                }
251            }
252        });
253    } else {
254        tpj('#section_shopping_method').html("<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>");
255    }
256}
257
258// Change action address billing
259function onSelectAddressBillingID(){
260    var address_id = tpj(this).val();
261
262    if(address_id !== "") {
263        MyScript.get_address_id(address_id, function (info_address) {
264            if (info_address != null) {
265                tpj("select[name=type_person]").val(info_address.type_person);
266                tpj("input[name=company]").val(info_address.company_name);
267                tpj("input[name=address]").val(info_address.address);
268                tpj("input[name=city]").val(info_address.city);
269                tpj("input[name=city_id]").val(info_address.city_id);
270                tpj("input[name=cap]").val(info_address.cap);
271                tpj("input[name=phone]").val(info_address.phone_1);
272                tpj("input[name=note]").val(info_address.note);
273                tpj("input[name=pi]").val(info_address.pi);
274                tpj("input[name=cf]").val(info_address.cf);
275                tpj("input[name=pec]").val(info_address.pec);
276                tpj("input[name=cu]").val(info_address.cu);
277                tpj("input[name=email]").val(info_address.email);
278            } else {
279                tpj("select[name=type_person]").val("");
280                tpj("input[name=company]").val("");
281                tpj("input[name=address]").val("");
282                tpj("input[name=cap]").val("");
283                tpj("input[name=city]").val("");
284                tpj("input[name=city_id]").val("");
285                tpj("input[name=phone]").val("");
286                tpj("input[name=note]").val("");
287                tpj("input[name=pi]").val("");
288                tpj("input[name=cf]").val("");
289                tpj("input[name=pec]").val("");
290                tpj("input[name=cu]").val("");
291                tpj("input[name=email]").val("");
292            }
293        });
294    } else {
295        tpj("select[name=type_person]").val("");
296        tpj("input[name=company]").val("");
297        tpj("input[name=address]").val("");
298        tpj("input[name=cap]").val("");
299        tpj("select[name=city_id]").val("");
300        tpj("input[name=phone]").val("");
301        tpj("input[name=note]").val("");
302        tpj("input[name=pi]").val("");
303        tpj("input[name=cf]").val("");
304        tpj("input[name=pec]").val("");
305        tpj("input[name=cu]").val("");
306        tpj("input[name=email]").val("");
307    }
308}
309
310// Change action select city
311function onSelectCityID(){
312    var city_id = tpj('#shipping-form-city-id').val();
313
314    if(city_id != "") {
315        MyScript.get_shopping_method_by_city_id(city_id, function (shipping_method) {
316            if (shipping_method.length <= 0) {
317                var html = "<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>";
318            } else {
319                var html = "<table width='100%'>";
320                for (var i = 0; i < shipping_method.length; i++) {
321                    html += "<tr>";
322                    html += "<td>";
323                    html += "<input type='radio' id='radio-4-" + shipping_method[i].id + "shi' name='shipping_method_id' class='form-control radio-style' value='" + shipping_method[i].id + "'/>";
324                    html += "<label for='radio-4-" + shipping_method[i].id + "shi' class='radio-style-1-label'>" + shipping_method[i].name + "</label>";
325                    html += "</td>";
326                    if (shipping_method[i].shipping_time > 0) {
327                        html += "<td align='right'>";
328                        html += MyScriptLang.strConsegnaIn + " <b>" + shipping_method[i].shipping_time + " " + MyScriptLang.strOre + "</b>";
329                        html += "</td>";
330                    }
331                    html += "<td align='right'>";
332                    html += "<b>+ " + shipping_method[i].shipping_price + " €</b>";
333                    html += "</td>";
334                    html += "</tr>";
335                }
336                html += "</table>";
337            }
338
339            tpj('#section_shopping_method').html(html);
340        });
341    } else {
342        tpj('#section_shopping_method').html("<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>");
343    }
344}
345
346// Change action select city
347function onSelectCap(){
348    var cap = tpj('#shipping-form-cap').val();
349
350    if(cap != "") {
351        MyScript.get_shopping_method_by_cap(cap, function (shipping_method) {
352            if (shipping_method.length <= 0) {
353                var html = "<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>";
354            } else {
355                var html = "<table width='100%'>";
356                for (var i = 0; i < shipping_method.length; i++) {
357                    html += "<tr>";
358                    html += "<td>";
359                    html += "<input type='radio' id='radio-4-" + shipping_method[i].id + "shi' name='shipping_method_id' class='form-control radio-style' value='" + shipping_method[i].id + "'/>";
360                    html += "<label for='radio-4-" + shipping_method[i].id + "shi' class='radio-style-1-label'>" + shipping_method[i].name + "</label>";
361                    html += "</td>";
362                    if (shipping_method[i].shipping_time > 0) {
363                        html += "<td align='right'>";
364                        html += MyScriptLang.strConsegnaIn + " <b>" + shipping_method[i].shipping_time + " " + MyScriptLang.strOre + "</b>";
365                        html += "</td>";
366                    }
367                    html += "<td align='right'>";
368                    html += "<b>+ " + shipping_method[i].shipping_price + " €</b>";
369                    html += "</td>";
370                    html += "</tr>";
371                }
372                html += "</table>";
373            }
374
375            tpj('#section_shopping_method').html(html);
376        });
377    } else {
378        tpj('#section_shopping_method').html("<i>"+MyScriptLang.strAddressNotAvaibleForShipping+"</i>");
379    }
380}
381
382// Verifica la selezione del tipo di spedizione o il ritiro in negozio permettendo solo uno dei due disabilitando l'uno o l'altro in base alla scelta
383function onChangeTypeShipping(){
384    let selected = tpj(this).attr("name");
385    console.log(selected);
386
387    if(selected === "shop_id"){
388        tpj(tpj('input[name=shipping_method_id]')).each(function(index) {
389            tpj(this).prop("checked", false);
390        });
391    }
392    if(selected === "shipping_method_id") {
393        tpj(tpj('input[name=shop_id]')).each(function(index) {
394            tpj(this).prop("checked", false);
395        });
396    }
397}
398
399/******************************************************************* CLASSE */
400
401var MyScript = {};
402
403// Ritorna i metodi di spediizione in base all'indirizzo scelto
404MyScript.get_shopping_method_by_address_id = function(address_id, callback){
405
406    if (address_id != "") {
407        var param = {};
408        param.action = "get_shipping_method_by_address_id";
409        param.info = {
410            "address_id": address_id
411        };
412
413        tpj.ajax({
414            url: "api/api-call.php",
415            type: 'POST',
416            cache: false,
417            dataType: 'json',
418            data: JSON.stringify(param),
419            processData: false, // Don't process the files
420            contentType: false, // Set content type to false as jQuery will tell the server its a query string request
421            success: function (reply, textStatus, jqXHR) {
422                if (!reply) {
423                    console.log("error: " + textStatus)
424                }
425
426                callback(reply.data);
427            },
428            error: function (jqXHR, textStatus, errorThrown) {
429                console.log("error: " + textStatus)
430            }
431        });
432    }
433};
434
435// Ritorna i metodi di spedizione in base alla città selezionata
436MyScript.get_shopping_method_by_city_id = function(city_id, callback){
437
438    if (city_id != "") {
439        var param = {};
440        param.action = "get_shipping_method_by_city_id";
441        param.info = {
442            "city_id": city_id
443        };
444
445        tpj.ajax({
446            url: "api/api-call.php",
447            type: 'POST',
448            cache: false,
449            dataType: 'json',
450            data: JSON.stringify(param),
451            processData: false, // Don't process the files
452            contentType: false, // Set content type to false as jQuery will tell the server its a query string request
453            success: function (reply, textStatus, jqXHR) {
454                if (!reply) {
455                    console.log("error: " + textStatus)
456                }
457
458                callback(reply.data);
459            },
460            error: function (jqXHR, textStatus, errorThrown) {
461                console.log("error: " + textStatus)
462            }
463        });
464    }
465};
466
467// Ritorna i metodi di spedizione in base al CAP
468MyScript.get_shopping_method_by_cap = function(cap, callback){
469
470    if (cap != "") {
471        var param = {};
472        param.action = "get_shipping_method_by_cap";
473        param.info = {
474            "cap": cap
475        };
476
477        tpj.ajax({
478            url: "api/api-call.php",
479            type: 'POST',
480            cache: false,
481            dataType: 'json',
482            data: JSON.stringify(param),
483            processData: false, // Don't process the files
484            contentType: false, // Set content type to false as jQuery will tell the server its a query string request
485            success: function (reply, textStatus, jqXHR) {
486                if (!reply) {
487                    console.log("error: " + textStatus)
488                }
489
490                callback(reply.data);
491            },
492            error: function (jqXHR, textStatus, errorThrown) {
493                console.log("error: " + textStatus)
494            }
495        });
496    }
497};
498
499// Ritorna le info dell'indirizzo
500MyScript.get_address_id = function(address_id, callback){
501    if (address_id != "") {
502        var param = {};
503        param.action = "get_address_id";
504        param.info = {
505            "address_id": address_id
506        };
507
508        tpj.ajax({
509            url: "api/api-call.php",
510            type: 'POST',
511            cache: false,
512            dataType: 'json',
513            data: JSON.stringify(param),
514            processData: false, // Don't process the files
515            contentType: false, // Set content type to false as jQuery will tell the server its a query string request
516            success: function (reply, textStatus, jqXHR) {
517                if (!reply) {
518                    console.log("error: " + textStatus)
519                }
520
521                callback(reply.data);
522            },
523            error: function (jqXHR, textStatus, errorThrown) {
524                console.log("error: " + textStatus)
525            }
526        });
527    }
528};
529
530// Open file input
531MyScript.onClickChangeProfileImage = function(){
532    tpj("input[name='path_profile_image']").click();
533};
534
535MyScript.onSelectImageProfile = function(){
536    if(tpj('#upload-demo').data('croppie')) {
537        tpj('#upload-demo').croppie('destroy');
538    }
539
540    readFile(tpj(this));
541
542    var $uploadCrop;
543    function readFile(input) {
544        if (input[0].files && input[0].files[0]) {
545            var reader = new FileReader();
546
547            reader.onload = function (e) {
548                $uploadCrop.croppie('bind', {
549                    url: e.target.result
550                }).then(function(){
551                    tpj('.cr-slider').attr({'min':0.5000, 'max':1.5000});
552                });
553            };
554
555            reader.readAsDataURL(input[0].files[0]);
556        }
557    }
558
559    $uploadCrop = tpj('#upload-demo').croppie({
560        viewport: {
561            width: 100,
562            height: 100,
563            type: 'circle'
564        },
565        enableExif: true
566    });
567
568    tpj('#onModalCropProfileImage').modal('show');
569};
570
571// Upload profile image
572MyScript.onUploadProfilePhoto = function(){
573    tpj(".form-process").show();
574
575    tpj('#upload-demo').croppie('result', {
576        type: 'canvas',
577        size: 'viewport'
578    }).then(function (resp) {
579        tpj('#image-profile').attr('src', resp);
580
581        var param = {};
582        param.action = "upload_image";
583        param.info = {
584            "image": resp,
585            "user_id": user_id
586        };
587
588        tpj.ajax({
589            url: "api/api-call.php",
590            type: 'POST',
591            cache: false,
592            dataType: 'json',
593            data: JSON.stringify(param),
594            processData: false, // Don't process the files
595            contentType: false, // Set content type to false as jQuery will tell the server its a query string request
596            success: function (reply, textStatus, jqXHR) {
597                tpj(".form-process").hide();
598            },
599            error: function (jqXHR, textStatus, errorThrown) {
600                console.log("error: " + textStatus)
601            }
602        });
603    });
604};
605
606// Processa il login con facebook
607MyScript.onFacebookLogin = function(event){
608    event.preventDefault();
609
610    tpj(".form-process").show();
611    FB.getLoginStatus(function(response) {
612        console.log(response);
613        MyScript.statusChangeCallback(response);
614    });
615};
616
617// Verifica se è stata già data autorizzazione al login
618MyScript.statusChangeCallback = function(response) {
619    if (response.status === 'connected') {
620        // Logged into your app and Facebook.
621        MyScript.processFacebookLogin();
622    } else {
623        FB.login(function (response) {
624            if (response.session || response.status === 'connected' ) {
625                MyScript.processFacebookLogin();
626            }
627        }, { scope: 'email' });
628    }
629};
630
631// Processa il login con facebook
632MyScript.processFacebookLogin = function() {
633    FB.api('/me?fields=first_name,last_name,email', function(response) {
634        var first_name = response.first_name;
635        var last_name = response.last_name;
636        var email = response.email;
637        var facebookId = response.id;
638
639        if (first_name !== "" && last_name !== "" && email !== "" && facebookId !== "") {
640            var param = {};
641            param.action = "facebook_login";
642            param.info = {
643                "first_name": first_name,
644                "last_name": last_name,
645                "email": email,
646                "facebook_id": facebookId
647            };
648
649            tpj.ajax({
650                url: "api/api-call.php",
651                type: 'POST',
652                cache: false,
653                dataType: 'json',
654                data: JSON.stringify(param),
655                processData: false, // Don't process the files
656                contentType: false, // Set content type to false as jQuery will tell the server its a query string request
657                success: function (reply, textStatus, jqXHR) {
658                    if (!reply) {
659                        console.log("error: " + textStatus)
660                    }
661
662                    tpj(".form-process").hide();
663
664                    if(reply.success){
665                        location.reload();
666                    } else {
667                        location.href = window.location.origin + '/login?message=error_facebook_login';
668                    }
669                },
670                error: function (jqXHR, textStatus, errorThrown) {
671                    console.log("error: " + textStatus)
672                }
673            });
674        } else {
675            location.href = window.location.origin + '/login?message=error_facebook_login';
676        }
677    });
678};
679
680MyScript.autocompleteCity = function() {
681    tpj('.autocomplete-city').each(function(){
682        let element = tpj(this);
683        tpj(this).autocomplete({
684            source: function (request, response) {
685                tpj.ajax({
686                    url: "autocomplete/cities_shop/" + request.term,
687                    success: function (data) {
688                        response(tpj.parseJSON(data));
689                    }
690                });
691            },
692            minLength: 3,
693            select: function (event, ui) {
694                element.closest("form").find('input[name="city_id"]').val(ui.item.id);
695            }
696        });
697    });
698};

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.