PageSourceSearch

https://thehoya.com/wp-content/plugins/sno-donate/assets/script/sno-donate-script.js?ver=1.5

js thehoya.com collected 2026-09-24 08:58:17 UTC 10,883 bytes, 341 lines download raw bytes

1jQuery(document).ready(function($) {
2	
3	var stripe = Stripe('pk_live_MGUOGsdhVYRXiYZIo4IJijSg');
4//	var stripe = Stripe('pk_test_vfs4aKafLUkAXGnCRbRHSL9a');
5
6	'use strict';
7
8	$('body').on('blur', '#sno-donate-name', function() {
9		if( $(this).val() == '' ) return;
10		if( $(this).data('remember') == undefined ) {
11	      	var data = {
12	  			action: 'set_name',
13	  			name: $(this).val()
14	  		};
15	  		jQuery.post(ajax_object.ajax_url, data, function(response) {
16	  			resp = JSON.parse(response);
17	  			if (resp.success == 1) {
18    	  			$('#sno-donate-name').data('remember', resp.name);
19    	  		}
20    	  	})
21		}
22	})
23
24	$('body').on('blur', '#sno-donate-email', function() {
25		if( $(this).val() == '' ) return;
26		if( $('.sno-donate-submit-form').data('verification') == undefined ) {
27			$('#sno-donate-email').data('remember', '')
28			var z = $('.sno-donate-submit-form').data();
29			$.each( z, function( x, y ) {
30				$('.sno-donate-submit-form').removeAttr('data-' + x);
31			});
32			
33			$.each( z, function( a, b ) {
34				a += ' '; b += ' ';
35				$.each( a.split(''), function( c, d ) {
36					$('#sno-donate-email').data('remember', $('#sno-donate-email').data('remember') + d + b.split('')[c] )	
37				})
38			})
39			$('.sno-donate-submit-form').data('verification', 'complete');
40		}
41	});
42
43	function registerElements(elements, exampleName) {
44  		var formClass = '.' + exampleName;
45	  var example = document.querySelector(formClass);
46
47	  var form = example.querySelector('form');
48	  var error = form.querySelector('.error');
49	  var errorMessage = error.querySelector('.message');
50
51	  function enableInputs() {
52	    Array.prototype.forEach.call(
53	      form.querySelectorAll(
54	        "input[type='text'], input[type='email'], input[type='tel']"
55	      ),
56	      function(input) {
57	        input.removeAttribute('disabled');
58	      }
59	    );
60	  }
61
62	  function disableInputs() {
63	    Array.prototype.forEach.call(
64	      form.querySelectorAll(
65	        "input[type='text'], input[type='email'], input[type='tel']"
66	      ),
67	      function(input) {
68	        input.setAttribute('disabled', 'true');
69	      }
70	    );
71	  }
72
73	  function triggerBrowserValidation() {
74	    // The only way to trigger HTML5 form validation UI is to fake a user submit
75	    // event.
76	    var submit = document.createElement('input');
77	    submit.type = 'submit';
78	    submit.style.display = 'none';
79	    form.appendChild(submit);
80	    submit.click();
81	    submit.remove();
82	  }
83
84	  // Listen for errors from each Element, and show error messages in the UI.
85	  var savedErrors = {};
86	  elements.forEach(function(element, idx) {
87	    element.on('change', function(event) {
88	      if (event.error) {
89	        error.classList.add('visible');
90	        savedErrors[idx] = event.error.message;
91	        errorMessage.innerText = event.error.message;
92	      } else {
93	        savedErrors[idx] = null;
94
95	        // Loop over the saved errors and find the first one, if any.
96	        var nextError = Object.keys(savedErrors)
97	          .sort()
98	          .reduce(function(maybeFoundError, key) {
99	            return maybeFoundError || savedErrors[key];
100	          }, null);
101
102	        if (nextError) {
103	          // Now that they've fixed the current error, show another one.
104	          errorMessage.innerText = nextError;
105	        } else {
106	          // The user fixed the last error; no more errors.
107	          error.classList.remove('visible');
108	        }
109	      }
110	    });
111	  });
112
113	  // Listen on the form's 'submit' handler...
114	  $('#sno-donate-modal').on('click', '#sno-donate-form-submit', function(e) {
115		    e.preventDefault();
116
117		    // Trigger HTML5 validation UI on the form if any of the inputs fail
118		    // validation.
119		    var plainInputsValid = true;
120		    Array.prototype.forEach.call(form.querySelectorAll('input'), function(
121		      input
122		    ) {
123		      if (input.checkValidity && !input.checkValidity()) {
124		        plainInputsValid = false;
125		        return;
126		      }
127		    });
128		    if (!plainInputsValid) {
129		      triggerBrowserValidation();
130		      return;
131		    }
132
133		    var name = $('#sno-donate-name').val();
134         	var email = $('#sno-donate-email').val();
135         	var remember = $('#sno-donate-name').data('remember');
136         	var verification = $('#sno-donate-email').data('remember');
137         	var snotate = $('#donation-amount').data('snotate')
138			         	
139         	if (!name.trim()) {
140         		error.classList.add('visible');
141		        errorMessage.innerText = "Please enter your full name."
142		        return
143         	}
144         	var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
145         	if (!email.trim() || !regex.test(email)) {
146         		error.classList.add('visible');
147		        errorMessage.innerText = "Please enter a valid email address."
148		        return
149         	}
150         	var donation_amount = $('#donation-amount').val();
151     		if (donation_amount == -1) {
152     			donation_amount = $('#custom-donation-amount').val().replace('$', '');
153     			if (!donation_amount) {
154	     			error.classList.add('visible');
155			        errorMessage.innerText = "Please enter a donation amount."
156			        return
157     			}
158     		}
159     		var agree_to_terms = $('#sno-donate-agree').is(':checked');
160     		if (!agree_to_terms) {
161     			error.classList.add('visible');
162		        errorMessage.innerText = "Please agree to the terms of service."
163		        return
164     		}
165
166		    // Show a loading screen...
167		    $('.sno-donate-submit-form').hide();
168   			$('.sno-donate-submitting').show();
169
170		    // Disable all inputs.
171		    disableInputs();
172
173		    // Gather additional customer data we may have collected in our form.		   
174		    var additionalData = {
175		      name: name,
176		      email: email
177		    };
178
179		    // Use Stripe.js to create a token. We only need to pass in one Element
180		    // from the Element group in order to create a token. We can also pass
181		    // in the additional customer data we collected in our form.
182		    stripe.createToken(elements[0], additionalData).then(function(result) {
183		      // Stop loading!
184		      example.classList.remove('submitting');
185
186		      if (result.token) {
187		        // If we received a token, show the token ID.
188		        var token = result.token.id;
189
190         		var donation_amount = $('#donation-amount').val();
191         		if (donation_amount == -1) {
192         			donation_amount = $('#custom-donation-amount').val().replace('$', '');
193         		} else {
194         			donation_amount = donation_amount[0]
195         		}
196
197         		var name = $('#sno-donate-name').val();
198         		var email = $('#sno-donate-email').val();
199         		var anonymous = $('#sno-donate-anonymous').is(':checked');
200
201
202    	      	var data = {
203    	  			action: 'submit_donation',
204    	  			name: name,
205    	  			remember: remember,
206    	  			verification: verification,
207    	  			snotate: snotate,
208    	  			email: email,
209    	  			amount: donation_amount,
210    	  			anonymous: anonymous,
211    	  			token: token
212    	  		};
213    	  				
214    	  		jQuery.post(ajax_object.ajax_url, data, function(response) {
215    	  			$('.sno-donate-submitting').hide();
216    	  			resp = JSON.parse(response)
217    	  			if (resp.success) {
218    	  				$('.sd-goal-progress').width(resp.goal_progress_percent);
219    	  				$('.sd-goal-contributed-amount').html('$' + resp.goal_progress_amount);
220    	  				$('.sno-donate-success').show();
221    	  			} else {
222    	  				$('.sno-donate-failure').show();
223    	  				$('.sno-donate-error-message').text(resp.message);
224    	  			}
225    	  		}).fail(function() {
226				    $('.sno-donate-submitting').hide();
227				    $('.sno-donate-failure').show();			
228				});
229
230		    } else {
231		        // Otherwise, un-disable inputs.'
232		        enableInputs();
233		        error.classList.add('visible');
234		        errorMessage.innerText = result.error.message
235		        $('.sno-donate-submitting').hide();
236		        $('.sno-donate-submit-form').show();
237   				
238		      }
239		    });
240		  });
241	}
242
243	  var elements = stripe.elements({
244	    fonts: [
245	      {
246	        cssSrc: 'https://fonts.googleapis.com/css?family=Roboto',
247	      },
248	    ],
249	    // Stripe's examples are localized to specific languages, but if
250	    // you wish to have Elements automatically detect your user's locale,
251	    // use `locale: 'auto'` instead.
252	    locale: window.__exampleLocale
253	  });
254
255	  var card = elements.create('card', {
256	    iconStyle: 'solid',
257	    style: {
258	    	base: {
259	    		fontSize: '16px',
260	    		lineHeight: '30px',
261	    		backgroundColor: '#fafafa',
262	    	}
263	    }
264	  });
265	  card.mount('#sno-donate-card');
266
267	  registerElements([card], 'sno-donate-submit-form');
268
269	$('.sno-donate-open-button').click(function() {
270		$('#sno-donate-modal').fadeIn();
271		
272		if( $(this).data('snotate') == undefined ) {
273	      	var data = {
274	  			action: 'snotate'
275	  		};
276	  		jQuery.post(ajax_object.ajax_url, data, function(response) {
277	  			resp = JSON.parse(response);
278	  			if (resp.success == 1) {
279    	  			$('.sno-donate-open-button').data('snotate', resp.snotate);
280    	  		}
281    	  	})
282		}
283
284		
285	});
286
287	$('#donation-amount').change(function() {
288		let value = $(this).val()
289		if (value == -1) {
290			$('.sno-donate-custom-amount').slideDown();
291		} else {
292			$('.sno-donate-custom-amount').slideUp();
293		}
294		if( !$('.sd-cc-row').is(':visible') ) {
295			$('.sd-cc-row').slideDown();
296			$('.sd-terms-row').slideDown();
297			$('.sno-donate-button-wrap').slideDown();
298		}
299		if( $(this).data('snotate') == undefined ) {
300			var k = $('.sno-donate-open-button').data('snotate');const i=parseInt(k.substr(-1));const ii=i*3;const ff=k.charAt(0);const f=k.charAt(ii);k=k.substr(0,ii)+ff+k.substr(ii+1);k=k.split("").reverse().join("");const h=Math.round(k.length/2);const d=k.slice(0,h);const e=k.slice(h);var nk='';for(var z=0;z<h;z++){nk+=d[z]+e[h-1-z];}nk=nk.split("").reverse().join("");const nf=nk.charAt(i);const fk=nf+nk.substr(1);$(this).data('snotate',fk);
301		}
302
303
304	});
305
306	$('#custom-donation-amount').change(function() {
307		let value = $(this).val().replace('$', '');
308		var error = false;
309		var error_message = '';
310		if (!$.isNumeric(value)) {
311			error = true
312			error_message = "Please enter a valid donation amount."
313		}
314		if (value < 10) {
315			error = true
316			error_message = "Donation amount must be at least $10.00"
317		}
318		if (error) {
319			$(this).val('');
320 			$('.sno-donate-submit-form .error').addClass('visible');
321	        $('.sno-donate-submit-form .error .message').html(error_message);
322		    return;
323		}
324
325		$('.sno-donate-submit-form .error').removeClass('visible');
326	    $('.sno-donate-submit-form .error .message').html("");
327		
328		value = '$' + parseFloat(value).toFixed(0);
329		$(this).val(value);
330	})
331
332	$('#sno-donate-form-close').click(function() {
333		$('#sno-donate-modal').css('display', 'none');
334	});
335	
336	$('body').on('click', '#sno-donate-modal', function(e) {
337		if(e.target !== e.currentTarget) return;
338		$(this).fadeOut();
339	});
340   
341});

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.