PageSourceSearch

https://www.upwind.io/wp-content/plugins/form-filtering-plugin/assets/app.js?ver=1790240727

js upwind.io collected 2026-09-24 09:23:57 UTC 5,948 bytes, 180 lines download raw bytes

1(function ($) {
2
3	if($('.elementor-editor-active').length >=0 ) return;
4    if($('form').length <= 0) return;
5    if($('[type="email"]').length <= 0) return;
6
7    let formType = $('form').find('.gform-body').length > 0 ? 'gforms' : null;
8    let errorMessages;
9    let nameObj = { first_name: '', last_name: '', first_name_element};
10    let vowels = [
11        "a",
12        "e",
13        "i",
14        "o",
15        "u"
16    ];
17    let blacklist = [ "test.com", "10minutemail.com", "10minutemail.net" ];
18    let errorArray = []
19
20    const _init = async function() {
21        response = await fetch(formFilter.list)
22        blacklist = await response.json();
23        errorMessages = JSON.parse(formFilter.errors)
24    }
25
26    const add_error = function(error, el) {        
27        if(formType == 'gforms'){
28            if(el.parent().find('.ee-ff-validation').length <= 0 && errorArray[el.attr('id')] !== false){
29                el.parent().addClass('ee-ff-error')
30                errorArray[el.attr('id')] = error;
31                el.after(`<div class="ee-ff-validation">${error}</div>`)
32            }
33        }
34    }
35
36    const remove_error = function(el) {
37        if(formType == 'gforms'){
38            if(errorArray[el.attr('id')]) {
39                errorArray[el.attr('id')] = null;
40            }
41            el.parent().removeClass('ee-ff-error')
42            el.parent().find('.ee-ff-validation').remove();
43        }
44    }
45
46    const handle_email_input_blur = function() {
47        
48        // Clear old error messages.
49        remove_error($(this));
50        
51        let email = $(this).val();
52
53        // Add error if email is empty and required.
54        if(email == '' && $(this).attr('aria-required') == 'true'){
55            add_error(errorMessages['not-email'], $(this));
56        }
57
58        // Add error if email doesn't contain an @ character.
59        if(!email.includes('@')){
60            add_error(errorMessages['not-email'], $(this));
61        }
62
63        // Add error if email is a disposable email.
64        // let domain = email.split('@')[1].toLowerCase()
65        // if ( blacklist.includes(domain)) {
66        //     add_error(errorMessages['disposable'], $(this));
67        // }
68    };
69    
70    const handle_name_input_blur = function(){
71        
72        // Clear old error messages.
73        remove_error($(this));
74
75        var value = $(this).val();
76        var label = $("label[for='" + $(this).attr('id') + "']");
77        var first = '';
78        var last = '';
79        var first_bool = label.text().toLowerCase().includes('first');
80        var name_bool = label.text().toLowerCase().includes('your name');
81        var last_bool = label.text().toLowerCase().includes('last');
82
83        if (
84            !first_bool &&
85            !name_bool &&
86            !last_bool
87        ) {
88            return;
89        }
90
91        if( first_bool || name_bool ) {
92            first = value.toLowerCase();
93            nameObj.first_name = first;
94            nameObj.first_name_element = $(this);
95        }
96
97        if( last_bool ){
98            last = value.toLowerCase();
99            nameObj.first_name = last;
100        }
101
102        if ( first_bool || name_bool ){
103
104            let chars = first.trim();
105
106            // If the first name is only 1 character long, add an error.
107            if (chars.length == 1){
108                add_error( errorMessages['one-char'], $(this))
109            }
110
111            // If the first name is only 2 characters long, check if they are the same or both vowels.
112            if (chars.length == 2 && (chars[0].toString() == chars[1].toString() || ( vowels.includes(chars[0]) && vowels.includes(chars[1]) ) )){
113                add_error( errorMessages['two-char'], $(this))
114            }
115
116            // If the first name contains a number, add an error.
117            if( containsNumber(first) ){
118                add_error( errorMessages['name-number'], $(this))
119            }
120
121            // If the first name is 'first', add an error.
122            if( first == 'first' ){ 
123                add_error( errorMessages['first-last'], $(this))
124            }
125        }
126
127        if( last_bool ){
128
129            // If the last name contains a number, add an error.
130            if(containsNumber(last) ) {
131                add_error( errorMessages['name-number'], $(this))
132            }
133
134            // If the last name is 'last', add an error.
135            if( last == 'last' ){ 
136                add_error( errorMessages['first-last'], $(this))
137            } 
138        }
139
140    }
141
142    const containsNumber = function(str) {
143        return /[0-9]/.test(str);
144    }
145
146    const can_submit_form = function(e) {
147
148        // Add error if first name and last name are the same.
149        if ( nameObj.first_name == nameObj.last_name && nameObj.first_name_element != null ) {
150            add_error( errorMessages['first-last'], nameObj.first_name_element);
151        }
152
153        let errors = Object.values(errorArray).filter(el => {
154            return el !== false && el !== null
155        });
156
157        if(errors.length > 0) {
158            e.preventDefault();
159            window["gf_submitting_"+$(this).data("formid")] = false;
160            if($("form[data-formid='"+$(this).data("formid")+"']").parent().find('.ee-submit-notice').length <= 0) {
161                $(this).closest('form').after('<div class="ee-submit-notice ee-ff-validation">Please fix the errors notated above to be able to submit the form.</div>')
162            }
163
164            return false;
165        }
166
167        $("form[data-formid='"+$(this).data("formid")+"']").parent().find('.ee-submit-notice').remove();
168        return true;
169    }
170
171    // events
172    $(document).ready(_init)
173    $('body').on('blur', '[type="email"]', handle_email_input_blur);
174    $('body').on('blur', '[type="text"]', handle_name_input_blur);
175    $('form').on('submit', can_submit_form);
176    // jQuery(document).on('gform_post_render', function(){
177    //     $('form').on('submit', can_submit_form)
178    // }); 
179
180})(jQuery);

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.