PageSourceSearch

https://evolvcollection.com/wp-content/plugins/evolv-atreemo/assets/js/init.js?debug=1790243770

js evolvcollection.com collected 2026-09-24 11:54:01 UTC 6,115 bytes, 149 lines download raw bytes

1const atreemoFormSubmission = () => {
2
3	const atreemoSubmit = document.querySelector('#atreemo-submit');
4
5   if (typeof(atreemoSubmit) != 'undefined' && atreemoSubmit != null) {
6
7        atreemoSubmit.addEventListener('click', (e) => {
8
9        	e.preventDefault();
10
11        	grecaptcha.ready(function() {
12                console.log('Recaptcha Ready');
13                //grecaptcha.execute('6LekTT0nAAAAAOVsKfRRAStG1Woe3lO_DJHeMpSo', {action: 'mailchimp'}).then(function(recaptchaToken) {
14				grecaptcha.execute('6Lda1q4rAAAAANGYOS1WwoLzLO4My3PWYgefK8eD', {action: 'atreemo'}).then(function(recaptchaToken) { // Test recaptcha key
15
16                    const emailAddress = document.querySelector('[name="atreemoEmail"]').value;
17                	const firstName = document.querySelector('[name="atreemoFname"]').value;
18					const birthday = document.querySelector('[name="atreemoBirthday"]').value;
19					const multi_brand_ids = document.querySelector('[name="multi_brand_ids"]').value;
20					let emailAddressError = true;
21					let firstNameError = true;
22					let privacyError = true;
23					let subscriptionError = true;
24					let brandIdsError = false;
25
26					atreemo_site_id = '';
27					if (document.querySelector('[name="atreemo_site_id"]') && document.querySelector('[name="atreemo_site_id"]').value) {
28						atreemo_site_id = document.querySelector('[name="atreemo_site_id"]').value;
29					}
30
31            		if (emailAddress == '' || emailAddress == null) {
32                		emailAddressError = true;
33                		document.querySelector('.email-error').classList.remove('hidden');
34              		} else {
35                		emailAddressError = false;
36                        document.querySelector('.email-error').classList.add('hidden');
37              		}
38
39              		if (firstName == '' || firstName == null) {
40                		firstNameError = true;
41                		document.querySelector('.fname-error').classList.remove('hidden');
42              		} else {
43                		firstNameError = false;
44                        document.querySelector('.fname-error').classList.add('hidden');
45              		}
46
47              		if (document.querySelector('[name="accept-privacy"]').checked) {
48              			privacyError = false;
49              		} else {
50              			privacyError = true;
51                        alert('Please accept our privacy policy');
52              		}
53
54              		if (document.querySelector('[name="accept-subscription"]').checked) {
55              			subscriptionError = false;
56              		} else {
57              			subscriptionError = true;
58                        alert('Please agree to receive newsletters');
59              		}
60
61              		//validate brand IDs if multi_brand_ids is true
62              		if(multi_brand_ids == 'true') {
63              			const checkedBrandIds = document.querySelectorAll('[name="brand_ids[]"]:checked');
64              			if(checkedBrandIds.length === 0) {
65              				brandIdsError = true;
66              				alert('Please select at least one location');
67              			} else {
68              				brandIdsError = false;
69              			}
70              		}
71
72               		if(emailAddressError == false && firstNameError == false && privacyError == false && subscriptionError == false && brandIdsError == false) {
73
74               			const formData = new FormData();
75                        formData.append('recaptchaToken', recaptchaToken);
76                        formData.append('emailAddress', emailAddress);
77                        formData.append('firstName', firstName);
78						formData.append('birthday', birthday);
79
80						if(atreemo_site_id != '') {
81							formData.append('atreemo_site_id', atreemo_site_id);
82						}
83
84						if(multi_brand_ids == 'true') {
85							const checkedBrandIds = document.querySelectorAll('[name="brand_ids[]"]:checked');
86							checkedBrandIds.forEach(brand_id => {
87								formData.append('brand_ids[]', brand_id.value);
88								console.log(brand_id.value);
89							});
90						}
91
92						formData.append('multi_brand_ids', multi_brand_ids);
93						formData.append('action', 'send_atreemo_submission');
94
95                        const atreemoData = new URLSearchParams(formData);
96
97                        fetch(mainJsVars.ajaxurl, {
98                            method: 'POST',
99                            credentials: 'same-origin',
100                            headers: {
101                                'Content-Type': 'application/x-www-form-urlencoded',
102                                'Cache-Control': 'no-cache',
103                            },
104                            body: atreemoData
105                        })
106                        .then((response) => response.text())
107                        .then((data) => {
108
109                        	console.log(data);
110
111                        	const response = JSON.parse(data);
112
113                        	if(response.status == 'error') {
114
115								//see token repsonse for generation of this error type of error message
116								error_message = 'Error: ' + response.message;
117								error_message += '\n\n' + response.error_description;
118
119                        		alert(error_message);
120								return false;
121                        	}
122
123							if(atreemo_site_id != '') {
124								document.getElementById('atreemo-signup').innerHTML = "<h4 class='text-center f__headline-h4 mb-4'>Thanks for signing up</h4>\
125								<p class='text-center f__paragraph-regular'>Don't forget to check your email and add us to your safe list</p>";
126
127								window.dataLayer.push({
128									'event': 'newsletter_signup'
129								});
130							}
131
132                            document.querySelector('.evolv-atreemo-signup').classList.add('form-submitted');
133              				
134                        })
135                        .catch((error) => {
136                            console.error(error);
137                        });  
138                    }else{
139						document.querySelector('.form-error').classList.add('active');
140					}
141                });
142            });
143        });
144    }
145}
146
147document.addEventListener("DOMContentLoaded", () => {
148    atreemoFormSubmission();
149});

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.