PageSourceSearch

https://theuniqueposter.com/modules/ets_advancedcaptcha/views/js/front.js

js theuniqueposter.com collected 2026-10-04 08:39:32 UTC 15,769 bytes, 305 lines download raw bytes

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 v3_render_clientID = {};
24var func_pa = {
25    addNotificationCustom: function (productId, productAttributeId) {
26        // to keep backward compatibility
27        if (typeof productId === 'undefined') {
28            var ids = $('div.js-mailalert > input[type=hidden]');
29            productId = ids.eq(0).val();
30            productIdAttribute = ids.eq(1).val();
31        }
32        var captchaParams = '';
33        if ($('div.js-mailalert textarea[name=g-recaptcha-response]').length > 0) {
34            captchaParams += '&g-recaptcha-response=' + $('div.js-mailalert textarea[name=g-recaptcha-response]').val();
35        } else if ($('div.js-mailalert input[name=pa_captcha]').length > 0) {
36            captchaParams += '&pa_captcha=' + $('div.js-mailalert input[name=pa_captcha]').val();
37        }
38        if ($('div.js-mailalert input[name=posTo]').length > 0) {
39            captchaParams += '&posTo=' + $('div.js-mailalert input[name=posTo]').val();
40        }
41        $.ajax({
42            type: 'POST',
43            url: $('div.js-mailalert').data('url'),
44            data: 'id_product=' + productId + '&id_product_attribute=' + productAttributeId + '&customer_email=' + $('div.js-mailalert > input[type=email]').val() + (captchaParams ? captchaParams : ''),
45            success: function (resp) {
46                resp = JSON.parse(resp);
47
48                $('.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();
49                if (!resp.error) {
50                    $('div.js-mailalert > .js-mailalert-add, div.js-mailalert > input[type=email], div.js-mailalert .gdpr_consent_wrapper').hide();
51                }
52            }
53        });
54        if ($('div.js-mailalert img.pa_captcha_img_data').length > 0) {
55            func_pa.refreshCaptcha($('div.js-mailalert img.pa_captcha_img_data').removeClass('loaded'));
56        } else {
57            func_pa.resetReCaptcha();
58        }
59        return false;
60    },
61    addNotification: function () {
62        var ids = $('div.js-mailalert > input[type=hidden]');
63        var captchaParams = '';
64        if ($('div.js-mailalert textarea[name=g-recaptcha-response]').length > 0) {
65            captchaParams += '&g-recaptcha-response=' + $('div.js-mailalert textarea[name=g-recaptcha-response]').val();
66        } else if ($('div.js-mailalert input[name=pa_captcha]').length > 0) {
67            captchaParams += '&pa_captcha=' + $('div.js-mailalert input[name=pa_captcha]').val();
68        }
69        if ($('div.js-mailalert input[name=posTo]').length > 0) {
70            captchaParams += '&posTo=' + $('div.js-mailalert input[name=posTo]').val();
71        }
72        $.ajax({
73            type: 'POST',
74            url: $('div.js-mailalert').data('url'),
75            data: 'id_product=' + ids[0].value + '&id_product_attribute=' + ids[1].value + '&customer_email=' + $('div.js-mailalert > input[type=email]').val() + (captchaParams ? captchaParams : ''),
76            success: function (resp) {
77                resp = JSON.parse(resp);
78                $('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();
79                if (!resp.error) {
80                    $('div.js-mailalert > button').hide();
81                    $('div.js-mailalert > input[type=email]').hide();
82                    $('div.js-mailalert > #gdpr_consent').hide();
83                    $('div.js-mailalert > .captcha_out_of_stock').hide();
84                }
85                if ($('div.js-mailalert input[name=pa_captcha]').length > 0) {
86                    $('div.js-mailalert input[name=pa_captcha]').val('');
87                }
88            }
89        });
90        if ($('div.js-mailalert img.pa_captcha_img_data').length > 0) {
91            func_pa.refreshCaptcha($('div.js-mailalert img.pa_captcha_img_data').removeClass('loaded'));
92        } else {
93            func_pa.resetReCaptcha();
94        }
95        return false;
96    },
97    addNotification16: function () {
98        if ($('#oosHook .gdpr_hook.receive').length > 0 && !$('.pa_notify input[name=gdpr_accept]').is(':checked')) {
99            $('#pa_mailalert_link').prop('disabled', true);
100            return false;
101        }
102        if ($('#pa_oos_customer_email').val() == mailalerts_placeholder || (typeof mailalerts_url_add == 'undefined')) {
103            return false;
104        }
105        var captchaParams = '';
106        if ($('.pa_notify textarea[name=g-recaptcha-response]').length > 0) {
107            captchaParams += '&g-recaptcha-response=' + $('.pa_notify textarea[name=g-recaptcha-response]').val();
108        } else if ($('.pa_notify input[name=pa_captcha]').length > 0) {
109            captchaParams += '&pa_captcha=' + $('.pa_notify input[name=pa_captcha]').val();
110        }
111        if ($('.pa_notify input[name=posTo]').length > 0) {
112            captchaParams += '&posTo=' + $('.pa_notify input[name=posTo]').val();
113        }
114        $.ajax({
115            type: 'POST',
116            url: mailalerts_url_add,
117            data: 'id_product=' + id_product + '&id_product_attribute=' + $('#idCombination').val() + '&customer_email=' + $('#pa_oos_customer_email').val() + (captchaParams ? captchaParams : ''),
118            success: function (json) {
119                if (json == '-1') {
120                    $('#pa_oos_customer_email_result').html(mailalerts_captcha_error);
121                    $('#pa_oos_customer_email_result').css('color', 'red').show();
122                } else if (json == '1') {
123                    $('#pa_mailalert_link, #pa_oos_customer_email, .pa_notify .page_product').hide();
124                    $('#oosHook').find('#gdpr_consent').hide();
125                    $('#pa_oos_customer_email_result').html(mailalerts_registered);
126                    $('#pa_oos_customer_email_result').css('color', 'green').show();
127                } else if (json == '2') {
128                    $('#pa_oos_customer_email_result').html(mailalerts_already);
129                    $('#pa_oos_customer_email_result').css('color', 'red').show();
130                } else {
131                    $('#pa_oos_customer_email_result').html(mailalerts_invalid);
132                    $('#pa_oos_customer_email_result').css('color', 'red').show();
133                }
134                if ($('.pa_notify input[name=pa_captcha]').length > 0) {
135                    $('.pa_notify input[name=pa_captcha]').val('');
136                }
137            }
138        });
139        if ($('.pa_notify img.pa_captcha_img_data').length > 0) {
140            func_pa.refreshCaptcha($('.pa_notify img.pa_captcha_img_data').removeClass('loaded'));
141        } else {
142            func_pa.resetReCaptcha();
143        }
144        return false;
145    },
146    refreshCaptcha: function (img) {
147        if (img.length && !img.hasClass('loaded')) {
148            var orgLink = img.attr('src');
149            var orgCode = img.attr('data-rand');
150            var rand = Math.random();
151            img.attr('src', orgLink.replace(orgCode, rand));
152            img.attr('data-rand', rand);
153            if (!img.hasClass('loaded')) {
154                img.addClass('loaded');
155            }
156        }
157    },
158    resetReCaptcha: function () {
159        if (typeof recaptchaWidgets !== "undefined" && typeof grecaptcha !== "undefined") {
160            for (var i = 0; i < recaptchaWidgets.length; i++) {
161                grecaptcha.reset(recaptchaWidgets[i]);
162            }
163        }
164    },
165    loadCaptcha: function () {
166        var img = $('.pa_captcha_img_data:not(.loaded)').first();
167        if (img.length > 0) {
168            img.load(function () {
169                if (!img.hasClass('loaded')) {
170                    func_pa.refreshCaptcha(img);
171                }
172                if (img[0].complete && img.hasClass('loaded')) {
173                    func_pa.loadCaptcha();
174                }
175            }).filter(function () {
176                return this.complete;
177            }).load();
178        }
179    },
180    loadReCaptchaV3: function (form) {
181        if ($('form:not(.g-loaded)').length <= 0 || !PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
182            return false;
183        }
184        var g_captcha = form.find('[id*=g-recaptcha-response-]');
185        if (g_captcha.length > 0 && $('body').attr('id')) {
186            grecaptcha.ready(function () {
187                var renderClientId = grecaptcha.render(g_captcha[0].id, {
188                    'sitekey': PA_GOOGLE_V3_CAPTCHA_SITE_KEY,
189                    'badge': PA_GOOGLE_V3_POSITION,
190                    'size': 'invisible',
191                    'theme': PA_GOOGLE_CAPTCHA_THEME,
192                });
193                console.log('renderClientId: ', renderClientId)
194                v3_render_clientID[g_captcha[0].id] = renderClientId;
195
196                grecaptcha.execute(renderClientId, {action: $('body').attr('id').replace(/(?=[^A-Za-z\_])([^A-Za-z\_])/g, '_')}).then(function (token) {
197                    if (token) {
198                        if (g_captcha.find('input[name=g-recaptcha-response]').length > 0) {
199                            g_captcha.find('input[name=g-recaptcha-response]').val(token);
200                        } else {
201                            g_captcha.append('<input type="hidden" name="g-recaptcha-response" value="' + token + '"/>');
202                        }
203                        g_captcha.find('textarea#g-recaptcha-response').remove();
204                        form.addClass('g-loaded');
205                        func_pa.getAllFormNeedAddCaptcha();
206                    }
207                });
208            });
209        }
210    },
211    getAllFormNeedAddCaptcha() {
212        var forms = $('form:not(.g-loaded)');
213        if (forms.length) {
214            forms.each(function () {
215                func_pa.loadReCaptchaV3($(this));
216            })
217        }
218    }
219};
220$(document).ready(function () {
221    if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
222        func_pa.getAllFormNeedAddCaptcha();
223    }
224    $('.pa_captcha_img_data.loaded').removeClass('loaded');
225    const mailAlertSubmitButtonClass = '.js-mailalert-add-custom';
226    $(document).on('click', mailAlertSubmitButtonClass, function (e) {
227        e.preventDefault();
228
229        func_pa.addNotificationCustom($(this).data('product'), $(this).data('product-attribute'));
230    });
231    $(document).on('click', '#pa_captcha_refesh', function (e) {
232        e.preventDefault();
233        func_pa.refreshCaptcha($(this).parents('.pa_captcha_img').find('.pa_captcha_img_data').removeClass('loaded'));
234        $(this).parents('.pa-captcha-inf').find('input[name=pa_captcha]').val('');
235    });
236    $(document).on('keypress', '#pa_oos_customer_email', function (e) {
237        if (e.keyCode == 13) {
238            e.preventDefault();
239            func_pa.addNotification16();
240        }
241    });
242});
243document.addEventListener("DOMContentLoaded", function (event) {
244    if ($('.forgot-password').length > 0 && $('.login.page_order').length > 0 && $('#login-form .login.page_order').length <= 0) {
245        $('.forgot-password').before($('.login.page_order').clone(true).addClass('copy'));
246        $('.login.page_order:not(.copy)').detach();
247    } else if ($('.cart-grid-right .login.page_order').length > 0) {
248        $('.cart-grid-right .login.page_order').detach();
249    }
250    if ($('.pa_captcha_img_data').length > 1) {
251        func_pa.loadCaptcha();
252    }
253});
254$(document).ajaxComplete(function (event, xhr, options) {
255    if ($('.quickview').length > 0 && typeof ets_captcha_load !== "undefined") {
256        ets_captcha_load($('.quickview'));
257    } else if ($('body#authentication').length > 0 && typeof options.data !== "undefined" && (typeof options.data === 'string' || Array.isArray(options.data)) && options.data.indexOf('SubmitCreate') != -1) {
258        var time_secs = 0, sec = 150;
259        var intervalSet = setInterval(function () {
260            time_secs += sec;
261            if ($('#account-creation_form.g-loaded').length <= 0) {
262                if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
263                    func_pa.loadReCaptchaV3($('form:not(.g-loaded)'));
264                } else if (typeof ets_captcha_load !== "undefined") {
265                    ets_captcha_load($('#account-creation_form').addClass('g-loaded'));
266                }
267            } else if (time_secs > sec * 10) {
268                clearInterval(intervalSet);
269            }
270        }, sec);
271    } else if (($('body#order-opc').length > 0 || $('body#orderopc').length > 0) && $('[name=g-recaptcha-response]').length > 0 && typeof options.data !== "undefined" && (typeof options.data === 'string' || Array.isArray(options.data)) && options.data.indexOf('submitAccount') != -1) {
272        if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
273            func_pa.loadReCaptchaV3($('form#new_account_form').removeClass('g-loaded'));
274        } else if (typeof grecaptcha !== "undefined") {
275            grecaptcha.reset();
276        }
277    } else if ((typeof options.data === 'string' || Array.isArray(options.data)) && options.data.indexOf('g-recaptcha-response') != -1 && options.url.indexOf('subscription') != -1) {
278        var form = $("form[action*=EmailSubscription]");
279        if (form) {
280            if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
281                var g_captcha = form.find('[id*=g-recaptcha-response-]');
282                grecaptcha.reset(v3_render_clientID[g_captcha[0].id]);
283                grecaptcha.execute(v3_render_clientID[g_captcha[0].id], {action: $('body').attr('id').replace(/(?=[^A-Za-z\_])([^A-Za-z\_])/g, '_')}).then(function (token) {
284                    if (token) {
285                        if (g_captcha.find('input[name=g-recaptcha-response]').length > 0) {
286                            g_captcha.find('input[name=g-recaptcha-response]').val(token);
287                        } else {
288                            g_captcha.append('<input type="hidden" name="g-recaptcha-response" value="' + token + '"/>');
289                        }
290                        form.addClass('g-loaded');
291                    }
292                });
293            } else if (typeof grecaptcha !== "undefined") {
294                grecaptcha.reset();
295            }
296        }
297    }
298});
299$(document).ready(function () {
300    if ($('input[name="captcha"]').closest('.form-group').length && $('.captcha_register').length) {
301        var div_clone = $('input[name="captcha"]').closest('.form-group').clone();
302        $('input[name="captcha"]').closest('.form-group').hide();
303        $('.captcha_register.register').after(div_clone);
304    }
305});

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.