PageSourceSearch

https://www.pratt.org/assets/js/newslatter.js

js pratt.org collected 2026-10-03 22:37:30 UTC 9,008 bytes, 230 lines download raw bytes

1(function($) {
2    $(document).ready(function() {
3    
4        $('#new-quick-contact-form').on('submit', function(e) {
5            e.preventDefault(); // Prevent the default form submission
6    
7            var formData = $(this).serialize(); // Serialize the form data
8    
9            $.ajax({
10                url: '/admin/quick-contact', 
11                type: 'POST',
12                data: formData,
13                headers: {
14                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') // Adding CSRF token to the headers
15                },
16                beforeSend: function() {
17                    // Show the loading spinner
18                    $('.form-process').fadeIn();
19                },
20                success: function(response) {
21                    // Hide the loading spinner
22                    $('.form-process').fadeOut();
23                    
24                    // Check if the response indicates success
25                    if (response.success) {
26                        // Hide the form
27                        document.getElementById("new-quick-contact-form").reset();
28                        $('#quick-contact-form').fadeOut();
29                        
30                        // Show the thank you message
31                        $('.thankyou').fadeIn();
32                    } else {
33                        // Handle the error
34                        alert('There was an error submitting the form. Please try again.');
35                    }
36                },
37                error: function(xhr, status, error) {
38                    // Hide the loading spinner
39                    $('.form-process').fadeOut();
40                    
41                    // Handle the error
42                    alert('There was an error submitting the form. Please try again.');
43                }
44            });
45        });
46    
47        $('#new-quick-contact-form-recaptcha').on('submit', function(e) {
48            e.preventDefault(); // Prevent the default form submission
49    
50            // Serialize the form data
51            var formData = $(this).serialize();
52    
53            // Add reCAPTCHA response to the serialized data
54            var recaptchaResponse = grecaptcha.getResponse();
55            if (recaptchaResponse.length === 0) {
56                alert('Please complete the reCAPTCHA');
57                return;
58            }
59            formData += '&g-recaptcha-response=' + recaptchaResponse;
60    
61            $.ajax({
62                url: '/admin/quick-contact-recaptcha', 
63                type: 'POST',
64                data: formData,
65                headers: {
66                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 
67                },
68                beforeSend: function() {
69                    // Show the loading spinner
70                    $('.form-process').fadeIn();
71                },
72                success: function(response) {
73                    // Hide the loading spinner
74                    $('.form-process').fadeOut();
75                    
76                    if (response.success) {
77                        document.getElementById("new-quick-contact-form-recaptcha").reset();
78                        grecaptcha.reset(); // Reset the reCAPTCHA widget
79                        $('#quick-contact-form').fadeOut();
80                        $('.thankyou').fadeIn();
81                    } else {
82                        alert(response.message || 'There was an error submitting the form. Please try again.');
83                    }
84                },
85                error: function(xhr, status, error) {
86                    // Hide the loading spinner
87                    $('.form-process').fadeOut();
88                    
89                    alert('There was an error submitting the form. Please try again.');
90            }
91            });
92        });
93
94        $('#quick-contact-form').on('submit', function(event) {
95            var formData = $('#quick-contact-form').serialize();
96
97            event.preventDefault();
98            $.ajax({
99                url: "/admin/quick-contact",
100                type: "POST",
101                headers: {
102                    'Accept': 'application/json',
103                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
104                },
105                data: formData,
106                success: function(response) {
107                    if (response.success == true) {
108                        document.getElementById("quick-contact-form").reset();
109                        $(".form-process").css("display", "none");
110                        $(".thankyou").css("display", "block");                    
111                        setTimeout(function() {
112                            $(".thankyou").css("display", "none");
113                        }, 5000)
114                    }
115
116                },
117            });
118        });
119
120        $('#contactForm').on('submit', function(event) {
121            event.preventDefault();
122
123            let email = $('#email').val();
124
125            $.ajax({
126                url: "/admin/contact-form",
127                type: "POST",
128                headers: {
129                    'Accept': 'application/json',
130                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
131                },
132                data: {
133                    email: email,
134                },
135                success: function(response) {
136                    $('#email').val('');
137
138                },
139            });
140        });
141        $('#footercontactForm').on('submit', function(event) {
142            event.preventDefault();
143
144            let email = $('#footer_email').val();
145            $.ajax({
146                url: "/admin/contact-form",
147                type: "POST",
148                headers: {
149                    'Accept': 'application/json',
150                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
151                },
152                data: {
153                    email: email,
154                },
155                success: function(response) {
156                    $('#footer_email').val('');
157                    $(".icon-line-loader").addClass("icon-email2");
158                    $(".icon-line-loader").removeClass("icon-spin");
159                    $(".icon-line-loader").removeClass("icon-line-loader");
160                },
161            });
162        });
163
164        $('#sms-form-submit').on('click', function(e) {
165            e.preventDefault(); // Prevent the default form submission
166
167            var formData = $("#sms-form").serialize(); // Serialize the form data
168            
169            var isCheckboxChecked = $('#sms-reminders').is(':checked');
170            var phoneValue = $('#sms-form-phone').val().trim();
171            $('#phone-error').hide().text('');
172            $('#checkbox-error').hide().text('');
173
174            if (!isCheckboxChecked) {
175                $('#checkbox-error').text('You must agree to receive SMS reminders.').show();
176                return;
177            }
178            
179            if (phoneValue === "") {
180                $('#phone-error').text('Phone number is required.').show();
181                $('#sms-form-phone').focus();
182                return; // Stop the form submission
183            }
184
185            $.ajax({
186                url: '/admin/submit-sms-form',
187                type: 'POST',
188                data: formData,
189                headers: {
190                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') // Adding CSRF token to the headers
191                },
192                beforeSend: function() {
193                    // Show the loading spinner
194                    $('.form-process').fadeIn();
195                },
196                success: function(response) {
197                    // Hide the loading spinner
198                    $('.form-process').fadeOut();
199                    
200                    if (response.success) {
201                        document.getElementById("sms-form").reset();
202                        $('.thankyou').fadeIn();
203                        setTimeout(function() {
204                            $('.thankyou').fadeOut();
205                        }, 5000)
206                    } else {
207                        // Handle the error
208                        Swal.fire({
209                            icon: 'error',
210                            title: 'Oops...',
211                            text: response.message || 'There was an error submitting the form. Please try again.'
212                        });
213                    }
214                },
215                error: function(xhr, status, error) {
216                    // Hide the loading spinner
217                    $('.form-process').fadeOut();
218
219                    // Handle the error
220                    Swal.fire({
221                        icon: 'error',
222                        title: 'Oops...',
223                        text: 'There was an error submitting the form. Please try again.'
224                    });
225                }
226            });
227        });
228    });
229    "use strict";
230})(window.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.