PageSourceSearch

https://www.blacklionhotelrichmond.co.uk/wp-content/plugins/punchp…/mailinglist/js/cx-mailinglist.js?ver=1.0.6

js blacklionhotelrichmond.co.uk collected 2026-10-05 04:43:32 UTC 3,935 bytes, 111 lines download raw bytes

1/**
2 * Submit a formbuilder form via AJAX
3 */
4
5jQuery(function($){ // use jQuery code inside this to avoid "$ is not defined" error
6
7	/**
8	 * Things that should get returned
9	 * 
10	 * post_id
11	 * post_name
12	 * 
13	 */
14
15	jQuery('form.mailinglist').on('submit', function (e) {
16
17	    e.preventDefault();
18
19	    var $theForm = jQuery(this);
20	    var $feedbackContainer = jQuery(this).next('.form-feedback');
21	    
22	    var form_data 					= new FormData();
23	    var outletID 					= $theForm.data( 'outlet-id' );
24	    var customer_email 				= $theForm.find('[data-field-name="custemail"]').val();
25	    var customer_firstname 			= $theForm.find('[data-field-name="first_name"]').val();
26	    var customer_lastname 			= $theForm.find('[data-field-name="last_name"]').val();
27	    var customer_birthday 			= $theForm.find('[data-field-name="birthday"]').val();
28	    var customer_mobile_phone 		= $theForm.find('[data-field-name="mobile_phone"]').val();
29	    var mailing_list_provider 		= $theForm.data('mailing-list-provider');
30	    var mailing_list_redirect_url 	= $theForm.data('redirect-url');
31	    var extra_tag 					= $theForm.data('extra-tag');
32	    var atreemo_fields = [];
33
34		$theForm.find('[data-atreemo-field]').each(function () {
35			var $field = $(this);
36
37			atreemo_fields.push({
38				name: $field.attr('name'),
39				value: $field.val()
40			});
41		});
42
43    	form_data.append('action', 'mailinglist_ajax_handler');
44    	form_data.append('outlet_id', outletID);
45    	form_data.append('customer_email', customer_email);
46    	form_data.append('customer_firstname', customer_firstname);
47    	form_data.append('customer_lastname', customer_lastname);
48    	form_data.append('customer_birthday', customer_birthday);
49    	form_data.append('customer_mobile_phone', customer_mobile_phone);
50    	form_data.append('mailing_list_provider', mailing_list_provider);
51    	form_data.append('mailing_list_redirect_url', mailing_list_redirect_url);
52    	form_data.append('extra_tag', extra_tag);
53		form_data.append('atreemo_fields', JSON.stringify(atreemo_fields));
54
55		$.ajax({
56        	url: ajax_url,
57        	type: 'post',
58        	contentType: false,
59        	processData: false,
60        	data: form_data,
61        	success: function (response) {
62
63        		// console.log(response);
64
65        		let responseData = response.data || {};
66        		let feedbackMessage = 'Something went wrong. Please try again later.';
67
68        		if (typeof responseData === 'string') {
69        			feedbackMessage = responseData;
70        		} else if (responseData.message) {
71        			feedbackMessage = responseData.message;
72        		}
73
74        		$theForm.hide();
75        		$feedbackContainer.html(feedbackMessage);
76        		$feedbackContainer.show();
77
78        		// Set a cookie with a 28-day expiration so that the mailing list popup doesn't bother us
79		        var date = new Date();
80		        date.setTime(date.getTime() + (28 * 24 * 60 * 60 * 1000));  // 14 days in milliseconds
81		        var expires = "expires=" + date.toUTCString();
82		        document.cookie = "dismissSignupPopup=yes; " + expires + "; path=/";
83		        // console.log('Cookie set: dismissSignupPopup=yes; ' + expires);
84	
85        	  if (responseData.code == 3) {
86
87        	  	$feedbackContainer.append('<h2 style="text-align:left;font-family:sans-serif;">Submitted data for debugging</h2>');
88        	  	$feedbackContainer.append(createHtmlList(responseData.debug));
89        	  	// console.log(response.data.debug);
90	
91        	  }
92        	  
93        	},  
94        	error: function (response) {
95			    console.log('AJAX error:', response);
96
97			    let feedbackMessage = 'Something went wrong. Please try again later.';
98
99			    if (response.responseJSON && response.responseJSON.data && response.responseJSON.data.message) {
100			        feedbackMessage = response.responseJSON.data.message;
101			    }
102
103			    $theForm.hide();
104			    $feedbackContainer.html(feedbackMessage).show();
105			}
106
107		});
108
109	});
110
111});

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.