1 2/* Cart */ 3 4var Cart = function () { 5 this.init = function () { 6 jQuery.ajax({ 7 method: 'GET', 8 url: wsUrls.showMini 9 }).done(function (html) { 10 11 if (jQuery('#mini-cart').length > 0) { // show mini-cart 12 13 if (jQuery('header div#mini-cart').length > 0) { // show mini-cart 14 jQuery('header div#mini-cart').html(html); 15 jQuery('span.mini-cart-num-items').html(jQuery('header input#nTot').val()); 16 } 17 if (jQuery('div#spt_mobile_footer div#mini-cart').length > 0) { // show mini-cart mobile 18 jQuery('div#spt_mobile_footer div#mini-cart').html(html); 19 } 20 } 21 }); 22 if (jQuery('#cart').length > 0) { // show cart 23 jQuery('#cart').load(wsUrls.show); 24 } 25 if (jQuery('#static-cart').length > 0) { // show static-cart 26 jQuery('#static-cart').load(wsUrls.showStatic); 27 } 28 }; 29 this.remove = function (id) { // ok 30 var params = { itemId: id }; 31 this.request('POST', wsUrls.removeItem, params); 32 jQuery.notify(removeItemToCart, 'success'); // -> javascrit.php -> site_it.php 33 }; 34 this.removeCarnet = function (id) { // ok 35 var params = { carnetId: id }; 36 this.request('POST', wsUrls.removeCarnet, params); 37 jQuery.notify(removeItemToCart, 'success'); // -> javascrit.php -> site_it.php 38 }; 39 this.empty = function () { // ok 40 this.request('GET', wsUrls.free, {}); 41 jQuery.notify(cartEmpty, 'info'); // -> javascrit.php -> site_it.php 42 }; 43 this.request = function (method, action, params) { 44 var self = this; 45 jQuery.ajax({ 46 method: method, 47 url: action, 48 data: params 49 }).done(function () { 50 self.sync(); 51 }); 52 }; 53 this.bind = function () { 54 var self = this; 55 jQuery(document).on('click', '.cart-remove', function () { // ok 56 if (confirm("Procedere con la cancellazione dal carrello di questo articolo?")) { 57 let row = jQuery(this).closest('.cart-item'); 58 if (row.attr('carnet-id') == undefined) { 59 let id = row.attr('id'); 60 self.remove(id); 61 } 62 else { 63 let carnetId = row.attr('carnet-id'); 64 self.removeCarnet(carnetId); 65 } 66 if (jQuery('#mini-cart').length > 0) { 67 jQuery('span.mini-cart-num-items').html(jQuery('header input#nTot').val()); 68 } 69 } else { 70 return false; 71 } 72 }); 73 jQuery(document).on('click', '.cart-empty', function () { // ok 74 self.empty(); 75 if (jQuery('#mini-cart').length > 0) { 76 jQuery('span.mini-cart-num-items').html(jQuery('header input#nTot').val()); 77 } 78 }); 79 }; 80 this.sync = function () { 81 var self = this; 82 jQuery.ajax({ 83 method: 'GET', 84 url: wsUrls.showMini 85 }).done(function (html) { 86 87 if (jQuery('#mini-cart').length > 0) { // show mini-cart 88 jQuery('#mini-cart').html(html); 89 let nItems = jQuery('#nTot').val(); 90 91 jQuery('span.mini-cart-num-items').html(nItems); 92 if (jQuery('#cart').length > 0 || jQuery('#static-cart').length > 0) { 93 94 if (jQuery('header div#mini-cart').length > 0) { // show mini-cart 95 jQuery('header div#mini-cart').html(html); 96 jQuery('span.mini-cart-num-items').html(jQuery('header input#nTot').val()); 97 } 98 if (jQuery('div#spt_mobile_footer div#mini-cart').length > 0) { // show mini-cart mobile 99 jQuery('div#spt_mobile_footer div#mini-cart').html(html); 100 } 101 if (jQuery('#static-cart').length > 0) { 102 jQuery('#static-cart').load(wsUrls.showStatic);
103 /*if (parseInt(jQuery('#nTot').val()) == 0) { 104 jQuery('#container_frame').hide(); 105 jQuery('.container #subtitle').hide(); 106 jQuery('.container #title').hide(); 107 jQuery('#container_void_cart_proposal').show(); 108 }*/ 109 } 110 111 /*if (jQuery('#cart').length > 0) { 112 jQuery('#cart').load(wsUrls.show); 113 }*/ 114 if (nItems === 0) { 115 window.location.reload(); 116 } 117 } 118 } 119 if (jQuery('#mini-cart').length > 0) { // show mini-cart mobile 120 jQuery('#mini-cart').html(html); 121 } 122 123 }); 124 if (jQuery('#cart').length > 0) { // show cart 125 jQuery('#cart').load(wsUrls.show); 126 } 127 }; 128}; 129/* init e load cart */ 130 131jQuery(document).ready(function () { 132 var cart = new Cart(); 133 cart.init(); 134 cart.bind(); 135}); 136 137 138/* Stripe */ 139jQuery(document).on('click', '.pay-button', function () { 140 141 var payButton = jQuery(this); 142 var responseContainer = payButton.closest('.stripe-button-container').find('.payment-response'); 143 var boId = payButton.attr('payment-group'); 144 var paymentType = payButton.attr('payment-type'); 145 146 jQuery.ajax({ 147 method: 'GET', 148 url: '/cart/' + boId + '/validate' 149 }).done(function (resp) { 150 if (resp == 'OK') { 151 152 jQuery.LoadingOverlay("show", { 153 backgroundClass: "loadingoverlay", 154 imageColor: "#006f67", 155 maxSize: 50 156 }); 157 158 if (paymentType == 'STRIPE') { 159 160 // sessione per il checkout relativo al payment group 161 var createCheckoutSession = function (stripe) { 162 return fetch('/' + lang + '/stripe/checkout?paymentGroup=' + boId, { 163 method: 'POST', 164 headers: { 165 'Content-Type': 'application/json', 166 }, 167 body: JSON.stringify({ 168 checkoutSession: 1 // attributo della request 169 }), 170 }).then(function (result) { 171 return result.json(); 172 }); 173 }; 174 175 jQuery.get('/' + lang + '/stripe/public-key-from-backoffice', { paymentGroup: boId }, function (stripeKey) { 176 177 payButton.disabled = true; 178 179 let stripe = Stripe(stripeKey); 180 181 createCheckoutSession().then(function (data) { 182 if (data.sessionId) { 183 stripe.redirectToCheckout({ 184 sessionId: data.sessionId, 185 }).then(handleResult); 186 } else { 187 handleResult(data); 188 } 189 }); 190 191 // errori provenienti dala action checkout 192 var handleResult = function (result) { 193 if (result.error) { 194 jQuery(responseContainer).html('<p>' + result.error.message + '</p>'); 195 } 196 payButton.disabled = false; 197 }; 198 }); 199 } else { 200 window.location.href = wsUrls['paymentMethodsUrls'][paymentType] + '?paymentGroup=' + boId; 201 } 202 203 //jQuery.LoadingOverlay('hide'); 204 205 } else { 206 jQuery('#validate-cart-report-' + boId).removeClass('d-none'); 207 jQuery('#validate-cart-report-' + boId).html(resp); 208 $('html, body').animate({ 209 scrollTop: $('#static-cart').offset().top - 200 210 }, 300); 211 } 212 }); 213}); 214 215 216jQuery(document).on('click', '[show-conditions-modal]', function () { 217 let boId = jQuery(this).attr('boId');
218 let conditionType = jQuery(this).attr('conditionType'); 219 var conditionModal = new bootstrap.Modal('#conditions-modal'); 220 221 jQuery.get(wsUrls.showConditionsModal + '?boId=' + boId + '&conditionType=' + conditionType) 222 .done(function (documentPartial) { 223 jQuery('div#conditions-content').html(documentPartial); 224 conditionModal.show(); 225 }).fail(function () { 226 alert('[ webservice error ]'); 227 }); 228}); 229 230jQuery(document).on('click', '[check-conditions]', function () { 231 let disableButton = false; 232 jQuery(this).parent().parent().find('[check-conditions]').each(function (i,v) { 233 if (jQuery(v).prop('checked') == false){ 234 disableButton = true; 235 } 236 }); 237 238 if (disableButton == false){ 239 jQuery(this).parent().parent().parent().parent().find('.pay-button').prop("disabled", false); 240 }else{ 241 jQuery(this).parent().parent().parent().parent().find('.pay-button').prop("disabled", true); 242 } 243}); 244 245 246 247function registrationFormSender(attrFormButton, reCaptchaKey = '', reCaptchaFormLabel = '') { 248 jQuery(document).on('click', '[' + attrFormButton + "]", function () { 249 console.log("registrationFormSender"); 250 251 let form = jQuery(this).parents('form:first'); 252 console.log(form); 253 254 if (jQuery(this).prop('tagName') == 'BUTTON') { 255 jQuery(this).prop('disabled', true); 256 } 257 if (form.parsley().isValid()) { 258 registrationForm(attrFormButton, reCaptchaKey, reCaptchaFormLabel); 259 } else { 260 form.parsley().validate(); 261 if (jQuery(this).prop('tagName') == 'BUTTON') { 262 jQuery(this).prop('disabled', false); 263 } 264 } 265 }) 266} 267 268function registrationForm(attrFormButton, reCaptchaKey = '', reCaptchaFormLabel = '') { 269 270 if (jQuery('[' + attrFormButton + ']').length > 0) { 271 let form = jQuery('[' + attrFormButton + ']').parents('form:first'); 272 273 if (reCaptchaKey.length > 0) { 274 grecaptcha.ready(function () { 275 grecaptcha.execute(reCaptchaKey, { 276 action: reCaptchaFormLabel 277 }).then(function (token) { 278 279 if (jQuery('#reCaptchaToken').length) { 280 jQuery('#reCaptchaToken').remove(); 281 } 282 if (jQuery('#reCaptchaFormLabel').length) { 283 jQuery('#reCaptchaFormLabel').remove(); 284 } 285 286 //let form = jQuery('#' + formName); 287 form.prepend('<input type="hidden" id="reCaptchaToken" name="reCaptchaToken" value="' + token + '" />'); 288 form.prepend('<input type="hidden" id="reCaptchaFormLabel" name="reCaptchaFormLabel" value="' + reCaptchaFormLabel + '" />'); 289 290 form.submit(); 291 });; 292 }); 293 } else { 294 form.submit(); 295 } 296 } 297}
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.