PageSourceSearch

https://europeansleeper.eu/js/index/partial/newsletter.js?v=1790263700

js europeansleeper.eu collected 2026-09-24 18:04:45 UTC 3,477 bytes, 158 lines download raw bytes

1function addInvalid($element){
2    $element
3        .removeClass('valid')
4        .addClass('invalid');
5}
6
7function addValid($element){
8    $element
9        .removeClass('invalid')
10        .addClass('valid');
11}
12
13function addValidation($element){
14    if ($element.val() === '') {
15        addInvalid($element);
16    } else {
17        addValid($element);
18    }
19}
20
21function isValidEmail(valid){
22    if (!validateEmail($email)) {
23        addInvalid($email);
24
25        valid = false;
26    }
27
28    return valid;
29}
30
31function isValidRequired(valid){
32    $required.each(function(){
33        var $input = $(this)
34          , $inputType = $input.attr('type');
35
36        if ($inputType === 'checkbox' && !$input.is(':checked')) {
37            $input.addClass('invalid');
38
39            valid = false;
40        }
41
42        if (($inputType === 'email' || $inputType === 'text') && $input.val() === '') {
43            $input.addClass('invalid');
44
45            valid = false;
46        }
47
48        if ($input.is('textarea') && $input.val() === '') {
49            $input.addClass('invalid');
50
51            valid = false;
52        }
53    });
54
55    return valid;
56}
57
58function validateEmail($element){
59    var $isEmail = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test($element.val());
60
61    if ($isEmail) {
62        $.ajax({
63            async: false,
64            data: {email: $element.val()},
65            dataType: 'json',
66            success: function(result){
67                if (result === 'error') {
68                    checkValidEmail = false;
69                } else {
70                    checkValidEmail = true;
71                }
72            },
73            type: 'POST',
74            url: '/check-valid-email'
75        });
76
77        return checkValidEmail;
78    }
79
80    return $isEmail;
81}
82
83var $email = $('#form-newsletter #email')
84  , $newsletter = $('#form-newsletter')
85  , $required = $('#form-newsletter .required');
86
87$('#form-newsletter .njs').val('1');
88
89$newsletter.submit(function(event){
90    var valid = true;
91
92    valid = isValidRequired(valid);
93    valid = isValidEmail(valid);
94
95    if (!valid) {
96        var $firstInvalid = $('.invalid:first');
97
98        $firstInvalid.focus();
99
100        $('html, body').animate({
101            scrollTop: $firstInvalid.offset().top - 150
102        }, 2000);
103
104        event.preventDefault();
105    }
106
107    if (valid) {
108        $('#form-newsletter button[type="submit"]').prop('disabled', true);
109        $load.show();
110
111        $.ajax({
112            data: $newsletter.serialize(),
113            success: function(data){
114                $load.hide();
115
116                if (getWidth() < 1024){
117                    $('html, body').animate({
118                        scrollTop: $newsletter.offset().top - 150
119                    }, 2000);
120                }
121
122                $newsletter.html(data);
123
124                if (typeof window.cioSetUserId === 'function') {
125                    window.cioSetUserId($email.val());
126                }
127            },
128            type: 'POST',
129            url: '/newsletter'
130        });
131    }
132
133    return false;
134});
135
136$email.blur(function(){
137    if (validateEmail($email)) {
138        addValid($email);
139    } else {
140        addInvalid($email);
141    }
142});
143
144$email.keyup(function(){
145    if (validateEmail($email)) {
146        addValid($email);
147    } else {
148        addInvalid($email);
149    }
150});
151
152$required.blur(function(){
153    addValidation($(this));
154});
155
156$required.mousedown(function(){
157    $(this).removeClass('invalid');
158});

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.