1/** 2 * Copyright ETS Software Technology Co., Ltd 3 * 4 * NOTICE OF LICENSE 5 * 6 * This file is not open source! Each license that you purchased is only available for 1 website only. 7 * If you want to use this file on more websites (or projects), you need to purchase additional licenses. 8 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. 9 * 10 * DISCLAIMER 11 * 12 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 13 * versions in the future. 14 * 15 * @author ETS Software Technology Co., Ltd 16 * @copyright ETS Software Technology Co., Ltd 17 * @license Valid for 1 website (or project) for each purchase of license 18 */ 19var PA_GOOGLE_V3_CAPTCHA_SITE_KEY = PA_GOOGLE_V3_CAPTCHA_SITE_KEY || false; 20var PA_GOOGLE_V3_POSITION = PA_GOOGLE_V3_POSITION || 'bottomright'; 21var PA_GOOGLE_CAPTCHA_THEME = PA_GOOGLE_CAPTCHA_THEME || 'light'; 22 23var func_pa = { 24 addNotificationCustom: function (productId, productAttributeId) { 25 // to keep backward compatibility 26 if (typeof productId === 'undefined') { 27 var ids = $('div.js-mailalert > input[type=hidden]'); 28 productId = ids.eq(0).val(); 29 productIdAttribute = ids.eq(1).val(); 30 } 31 var captchaParams = ''; 32 if ($('div.js-mailalert textarea[name=g-recaptcha-response]').length > 0) { 33 captchaParams += '&g-recaptcha-response=' + $('div.js-mailalert textarea[name=g-recaptcha-response]').val(); 34 } else if ($('div.js-mailalert input[name=pa_captcha]').length > 0) { 35 captchaParams += '&pa_captcha=' + $('div.js-mailalert input[name=pa_captcha]').val(); 36 } 37 if ($('div.js-mailalert input[name=posTo]').length > 0) { 38 captchaParams += '&posTo=' + $('div.js-mailalert input[name=posTo]').val(); 39 } 40 $.ajax({
41 type: 'POST', 42 url: $('div.js-mailalert').data('url'), 43 data: 'id_product=' + productId + '&id_product_attribute=' + productAttributeId + '&customer_email=' + $('div.js-mailalert > input[type=email]').val() + (captchaParams ? captchaParams : ''), 44 success: function (resp) { 45 resp = JSON.parse(resp); 46 47 $('.js-mailalert-alerts').html('<article class="mt-1 alert alert-' + (resp.error ? 'danger' : 'success') + '" role="alert" data-alert="' + (resp.error ? 'error' : 'success') + '">' + resp.message + '</article>').show(); 48 if (!resp.error) { 49 $('div.js-mailalert > .js-mailalert-add, div.js-mailalert > input[type=email], div.js-mailalert .gdpr_consent_wrapper').hide(); 50 } 51 } 52 }); 53 if ($('div.js-mailalert img.pa_captcha_img_data').length > 0) { 54 func_pa.refreshCaptcha($('div.js-mailalert img.pa_captcha_img_data').removeClass('loaded')); 55 } else { 56 func_pa.resetReCaptcha(); 57 } 58 return false; 59 }, 60 addNotification: function () { 61 var ids = $('div.js-mailalert > input[type=hidden]'); 62 var captchaParams = ''; 63 if ($('div.js-mailalert textarea[name=g-recaptcha-response]').length > 0) { 64 captchaParams += '&g-recaptcha-response=' + $('div.js-mailalert textarea[name=g-recaptcha-response]').val(); 65 } else if ($('div.js-mailalert input[name=pa_captcha]').length > 0) { 66 captchaParams += '&pa_captcha=' + $('div.js-mailalert input[name=pa_captcha]').val(); 67 } 68 if ($('div.js-mailalert input[name=posTo]').length > 0) { 69 captchaParams += '&posTo=' + $('div.js-mailalert input[name=posTo]').val(); 70 } 71 $.ajax({
72 type: 'POST', 73 url: $('div.js-mailalert').data('url'), 74 data: 'id_product=' + ids[0].value + '&id_product_attribute=' + ids[1].value + '&customer_email=' + $('div.js-mailalert > input[type=email]').val() + (captchaParams ? captchaParams : ''), 75 success: function (resp) { 76 resp = JSON.parse(resp); 77 $('div.js-mailalert > span').html('<article class="alert alert-' + (resp.error ? 'danger' : 'success') + '" role="alert" data-alert="' + (resp.error ? 'error' : 'success') + '">' + resp.message + '</article>').show(); 78 if (!resp.error) { 79 $('div.js-mailalert > button').hide(); 80 $('div.js-mailalert > input[type=email]').hide(); 81 $('div.js-mailalert > #gdpr_consent').hide(); 82 $('div.js-mailalert > .captcha_out_of_stock').hide(); 83 } 84 if ($('div.js-mailalert input[name=pa_captcha]').length > 0) { 85 $('div.js-mailalert input[name=pa_captcha]').val(''); 86 } 87 } 88 }); 89 if ($('div.js-mailalert img.pa_captcha_img_data').length > 0) { 90 func_pa.refreshCaptcha($('div.js-mailalert img.pa_captcha_img_data').removeClass('loaded')); 91 } else { 92 func_pa.resetReCaptcha(); 93 } 94 return false; 95 }, 96 addNotification16: function () { 97 if ($('#oosHook .gdpr_hook.receive').length > 0 && !$('.pa_notify input[name=gdpr_accept]').is(':checked')) { 98 $('#pa_mailalert_link').prop('disabled', true); 99 return false; 100 } 101 if ($('#pa_oos_customer_email').val() == mailalerts_placeholder || (typeof mailalerts_url_add == 'undefined')) { 102 return false; 103 } 104 var captchaParams = ''; 105 if ($('.pa_notify textarea[name=g-recaptcha-response]').length > 0) { 106 captchaParams += '&g-recaptcha-response=' + $('.pa_notify textarea[name=g-recaptcha-response]').val(); 107 } else if ($('.pa_notify input[name=pa_captcha]').length > 0) { 108 captchaParams += '&pa_captcha=' + $('.pa_notify input[name=pa_captcha]').val(); 109 } 110 if ($('.pa_notify input[name=posTo]').length > 0) { 111 captchaParams += '&posTo=' + $('.pa_notify input[name=posTo]').val(); 112 } 113 $.ajax({
114 type: 'POST', 115 url: mailalerts_url_add, 116 data: 'id_product=' + id_product + '&id_product_attribute=' + $('#idCombination').val() + '&customer_email=' + $('#pa_oos_customer_email').val() + (captchaParams ? captchaParams : ''), 117 success: function (json) { 118 if (json == '-1') { 119 $('#pa_oos_customer_email_result').html(mailalerts_captcha_error); 120 $('#pa_oos_customer_email_result').css('color', 'red').show(); 121 } else if (json == '1') { 122 $('#pa_mailalert_link, #pa_oos_customer_email, .pa_notify .page_product').hide(); 123 $('#oosHook').find('#gdpr_consent').hide(); 124 $('#pa_oos_customer_email_result').html(mailalerts_registered); 125 $('#pa_oos_customer_email_result').css('color', 'green').show(); 126 } else if (json == '2') { 127 $('#pa_oos_customer_email_result').html(mailalerts_already); 128 $('#pa_oos_customer_email_result').css('color', 'red').show(); 129 } else { 130 $('#pa_oos_customer_email_result').html(mailalerts_invalid); 131 $('#pa_oos_customer_email_result').css('color', 'red').show(); 132 } 133 if ($('.pa_notify input[name=pa_captcha]').length > 0) { 134 $('.pa_notify input[name=pa_captcha]').val(''); 135 } 136 } 137 }); 138 if ($('.pa_notify img.pa_captcha_img_data').length > 0) { 139 func_pa.refreshCaptcha($('.pa_notify img.pa_captcha_img_data').removeClass('loaded')); 140 } else { 141 func_pa.resetReCaptcha(); 142 } 143 return false; 144 }, 145 refreshCaptcha: function (img) { 146 if (img.length && !img.hasClass('loaded')) { 147 var orgLink = img.attr('src'); 148 var orgCode = img.attr('data-rand'); 149 var rand = Math.random(); 150 img.attr('src', orgLink.replace(orgCode, rand)); 151 img.attr('data-rand', rand); 152 if (!img.hasClass('loaded')) { 153 img.addClass('loaded'); 154 } 155 } 156 }, 157 resetReCaptcha: function () { 158 if (typeof recaptchaWidgets !== "undefined" && typeof grecaptcha !== "undefined") { 159 for (var i = 0; i < recaptchaWidgets.length; i++) { 160 grecaptcha.reset(recaptchaWidgets[i]); 161 } 162 } 163 }, 164 loadCaptcha: function () { 165 var img = $('.pa_captcha_img_data:not(.loaded)').first(); 166 if (img.length > 0) { 167 img.load(function () { 168 if (!img.hasClass('loaded')) { 169 func_pa.refreshCaptcha(img); 170 } 171 if (img[0].complete && img.hasClass('loaded')) { 172 func_pa.loadCaptcha(); 173 } 174 }).filter(function () { 175 return this.complete; 176 }).load(); 177 } 178 }, 179 loadReCaptchaV3: function (form) { 180 if ($('form:not(.g-loaded)').length <= 0 || !PA_GOOGLE_V3_CAPTCHA_SITE_KEY) { 181 return false; 182 } 183 var g_captcha = form.find('[id*=g-recaptcha-response-]'); 184 if (g_captcha.length > 0 && $('body').attr('id')) { 185 grecaptcha.ready(function () { 186 var renderClientId = grecaptcha.render(g_captcha[0].id, { 187 'sitekey': PA_GOOGLE_V3_CAPTCHA_SITE_KEY, 188 'badge': PA_GOOGLE_V3_POSITION, 189 'size': 'invisible', 190 'theme': PA_GOOGLE_CAPTCHA_THEME, 191 }); 192 grecaptcha.execute(renderClientId, {action: $('body').attr('id').replace(/(?=[^A-Za-z\_])([^A-Za-z\_])/g, '_')}).then(function (token) { 193 if (token) { 194 if (g_captcha.find('input[name=g-recaptcha-response]').length > 0) { 195 g_captcha.find('input[name=g-recaptcha-response]').val(token); 196 } else { 197 g_captcha.append('<input type="hidden" name="g-recaptcha-response" value="' + token + '"/>'); 198 } 199 form.addClass('g-loaded'); 200 func_pa.loadReCaptchaV3($('form:not(.g-loaded)')); 201 } 202 }); 203 }); 204 } 205 } 206}; 207$(document).ready(function () { 208 if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) { 209 func_pa.loadReCaptchaV3($('form:not(.g-loaded)')); 210 } 211 $('.pa_captcha_img_data.loaded').removeClass('loaded'); 212 const mailAlertSubmitButtonClass = '.js-mailalert-add-custom'; 213 $(document).on('click', mailAlertSubmitButtonClass, function (e) { 214 e.preventDefault(); 215 216 func_pa.addNotificationCustom($(this).data('product'), $(this).data('product-attribute')); 217 });
218 $(document).on('click', '#pa_captcha_refesh', function (e) { 219 e.preventDefault(); 220 func_pa.refreshCaptcha($(this).parents('.pa_captcha_img').find('.pa_captcha_img_data').removeClass('loaded')); 221 $(this).parents('.pa-captcha-inf').find('input[name=pa_captcha]').val(''); 222 }); 223 $(document).on('keypress', '#pa_oos_customer_email', function (e) { 224 if (e.keyCode == 13) { 225 e.preventDefault(); 226 func_pa.addNotification16(); 227 } 228 }); 229}); 230document.addEventListener("DOMContentLoaded", function (event) { 231 if ($('.forgot-password').length > 0 && $('.login.page_order').length > 0 && $('#login-form .login.page_order').length <= 0) { 232 $('.forgot-password').before($('.login.page_order').clone(true).addClass('copy')); 233 $('.login.page_order:not(.copy)').detach(); 234 } else if ($('.cart-grid-right .login.page_order').length > 0) { 235 $('.cart-grid-right .login.page_order').detach(); 236 } 237 if ($('.pa_captcha_img_data').length > 1) { 238 func_pa.loadCaptcha(); 239 } 240}); 241$(document).ajaxComplete(function (event, xhr, options) { 242 if ($('.quickview').length > 0 && typeof ets_captcha_load !== "undefined") { 243 ets_captcha_load($('.quickview')); 244 } else if ($('body#authentication').length > 0 && typeof options.data !== "undefined" && options.data.indexOf('SubmitCreate') != -1) { 245 var time_secs = 0, sec = 150; 246 var intervalSet = setInterval(function () { 247 time_secs += sec; 248 if ($('#account-creation_form.g-loaded').length <= 0) { 249 if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) { 250 func_pa.loadReCaptchaV3($('form:not(.g-loaded)')); 251 } else if (typeof ets_captcha_load !== "undefined") { 252 ets_captcha_load($('#account-creation_form').addClass('g-loaded')); 253 } 254 } else if (time_secs > sec * 10) { 255 clearInterval(intervalSet); 256 } 257 }, sec); 258 } else if (($('body#order-opc').length > 0 || $('body#orderopc').length > 0) && $('[name=g-recaptcha-response]').length > 0 && typeof options.data !== "undefined" && options.data.indexOf('submitAccount') != -1) { 259 if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) { 260 func_pa.loadReCaptchaV3($('form#new_account_form').removeClass('g-loaded')); 261 } else if (typeof grecaptcha !== "undefined") { 262 grecaptcha.reset(); 263 } 264 } 265}); 266$(document).ready(function () { 267 if ($('input[name="captcha"]').parent().parent().length && $('.captcha_register').length) { 268 var div_clone = $('input[name="captcha"]').parent().parent().clone(); 269 $('input[name="captcha"]').parent().parent().hide(); 270 $('.captcha_register.register').after(div_clone); 271 } 272});
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.