1jQuery(document).ready(function () { 2 function priceCalculator(e, q, c, n) { 3 this.element = e; 4 this.basePrice = this.element.data("price"); 5 this.quantita = q; 6 this.personalizza = c; 7 this.nazione = n; 8 9 this.subtotale = this.element.find("#subtotale"); 10 this.personalizzazione = this.element.find("#personalizzazione"); 11 this.spedizione = this.element.find("#spedizione"); 12 this.totale = this.element.find("#totale"); 13 14 this.field_subtotale = this.element.parent().find("#field_subtotale"); 15 this.field_personalizzazione = this.element 16 .parent() 17 .find("#field_personalizzazione"); 18 this.field_spedizione = this.element.parent().find("#field_spedizione"); 19 this.field_totale = this.element.parent().find("#field_totale"); 20 21 var me = this; 22 23 this.formatPrice = function (number) { 24 var decPlaces = 2; 25 var decSep = ","; 26 var thouSep = "."; 27 28 var i = String( 29 parseInt((number = Math.abs(Number(number) || 0).toFixed(decPlaces))) 30 ); 31 var j = (j = i.length) > 3 ? j % 3 : 0; 32 return ( 33 (j ? i.substr(0, j) + thouSep : "") + 34 i.substr(j).replace(/(\decSep{3})(?=\decSep)/g, "$1" + thouSep) + 35 (decPlaces 36 ? decSep + 37 Math.abs(number - i) 38 .toFixed(decPlaces) 39 .slice(2) 40 : "") 41 ); 42 }; 43 44 this.addPriceTo = function (target, value) { 45 target.html(me.formatPrice(value)); 46 }; 47 48 this.priceUpdate = function () { 49 var pQ = me.quantita.val(); 50 var totale = 0; 51 52 if (pQ == "other") { 53 me.subtotale.children("span").html("--"); 54 me.personalizzazione.hide(); 55 me.spedizione.hide(); 56 me.totale.children("span").html("--"); 57 me.field_subtotale.val(0); 58 me.field_personalizzazione.val(0); 59 me.field_spedizione.val(0); 60 me.field_totale.val(0); 61 } else { 62 var sub = me.basePrice * pQ; 63 me.addPriceTo(me.subtotale.children("span"), sub); 64 me.field_subtotale.val(sub); 65 totale += sub; 66 67 if (me.personalizza.is(":checked")) { 68 var cust = me.personalizza.data("price"); 69 me.personalizzazione.show(); 70 me.addPriceTo(me.personalizzazione.children("span"), cust); 71 me.field_personalizzazione.val(cust); 72 totale += cust; 73 } 74 75 if (me.nazione.val() != "") { 76 var ship = me.nazione.children("option:selected").data("shipping"); 77 if (ship == "--") { 78 me.spedizione.children("span").html("--"); 79 me.field_spedizione.val(0); 80 } else { 81 me.spedizione.show(); 82 me.addPriceTo(me.spedizione.children("span"), ship); 83 me.field_spedizione.val(ship); 84 totale += ship; 85 } 86 } 87 88 me.addPriceTo(me.totale.children("span"), totale); 89 me.field_totale.val(totale); 90 } 91 }; 92 93 me.quantita.change(function () { 94 me.priceUpdate(); 95 }); 96 97 me.nazione.change(function () { 98 me.priceUpdate(); 99 }); 100 101 me.personalizza.change(function () { 102 me.priceUpdate(); 103 }); 104 105 me.personalizzazione.hide(); 106 me.spedizione.hide(); 107 me.priceUpdate(); 108 } 109 110 if (jQuery("#orderForm").length > 0) { 111 var orderForm = jQuery("#orderForm"); 112 113 var privacy = orderForm.find('input[name="privacy"]'); 114 var quantity = orderForm.find('select[name="quantita"]'); 115 var customize = orderForm.find('input[name="personalizza"]'); 116 var nation = orderForm.find('select[name="nazione"]'); 117 var submitButton = orderForm.find('button[type="submit"]'); 118 119 var priceCalculator = new priceCalculator( 120 orderForm.find("#price-calculator"), 121 quantity, 122 customize, 123 nation 124 ); 125 126 privacy.change(function () { 127 if (privacy.is(":checked")) submitButton.removeAttr("disabled"); 128 else submitButton.attr("disabled", "disabled"); 129 }); 130 131 orderForm.on("submit", function (e) { 132 e.preventDefault(); 133 e.stopPropagation(); 134 135 var wait = jQuery( 136 '<span id="waitIcon"><i class="fas fa-spinner fa-spin"></i></span>' 137 ); 138 139 submitButton.prepend(wait); 140 141 var formData = orderForm.serializeArray(); 142 143 var x = 0; 144 for (x in formData) { 145 var currentField = jQuery("#field_" + formData[x].name); 146 if (currentField.length > 0) { 147 formData[x].tagName = currentField[0].tagName; 148 formData[x].type = currentField[0].type; 149 if (currentField[0].hasAttribute("required")) 150 formData[x].required = true; 151 } 152 } 153 154 jQuery.post( 155 ajax_object.ajax_url, 156 { formData: formData, action: "verify_form" }, 157 function (response) { 158 switch (response.status) { 159 case "success": 160 grecaptcha.ready(function () { 161 grecaptcha 162 .execute(ajax_object.site_key, { action: "submit" }) 163 .then(function (token) { 164 jQuery.post( 165 ajax_object.ajax_url, 166 { token: token, action: "verify_google" }, 167 function (response) { 168 if (response.status == "success") { 169 jQuery.post( 170 ajax_object.ajax_url, 171 { formData: formData, action: "manage_order" }, 172 function (response) { 173 if (response.status == "success") 174 window.location.replace( 175 response.message + 176 "?status=" + 177 response.exitcode 178 ); 179 else { 180 alert(response.message); 181 wait.remove(); 182 } 183 }, 184 "json" 185 ); 186 } else { 187 orderForm.addClass("was-validated"); 188 alert(response.message); 189 wait.remove(); 190 } 191 }, 192 "json" 193 ); 194 }); 195 }); 196 197 break; 198 default: 199 orderForm.addClass("was-validated"); 200 alert(response.message); 201 wait.remove(); 202 break; 203 } 204 }, 205 "json" 206 ); 207 });
208 } 209 210 if (jQuery(".page-categories-wrapper").length > 0) { 211 jQuery(".page-categories-wrapper").each(function () { 212 var pageNavigatior = pageCategoryNavigator(jQuery(this)); 213 }); 214 } 215});
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.