1var gaiDonations = (function($){ 2 var t = {}; 3 4 t.busy = false; 5 t.mode = 'donation'; 6 7 t.AddDonationToCart = function(myForm = null) { 8 var parent = $('#content'); 9 var params; 10 11 // Dedicated donation page 12 if (!myForm) { 13 debug_log("Using donation page elements."); 14 params = { 15 don: $('input[name="program"]:checked').val(), //Program 16 fieldAmt: $('input[name=donation_amount]', parent).val().replace(/,/g, ""), //Donation Amount 17 }; 18 19 if ($('textarea[name=donation_message]').val()) { 20 params.donation_message = base64UrlEncode($('textarea[name=donation_message]').val()); 21 } 22 } 23 else { 24 debug_log("Using donation form/module elements."); 25 // print_donate_form() names the amount input either `fieldAmt` 26 // (when a fund_id is supplied) or `donation_amount` (default). 27 var amt = $('input[name=fieldAmt]', myForm).val(); 28 if (typeof amt === 'undefined') { 29 amt = $('input[name=donation_amount]', myForm).val(); 30 } 31 params = { 32 don: $('input[name="don"]',myForm).val(), //Program 33 fieldAmt: (amt || '').replace(/,/g, ""), //Donation Amount 34 }; 35 } 36 37 var url = Tession.SSURL() + ($('.mode-anchor').length ? 'donate/contribute1?' : 'donate/contribute2?'); 38 //var url = Tession.SSURL() + ($('.mode-anchor').length ? 'donate/contribute1?' : 'donate/contribute2?isLocal=1&'); 39 40 url += $.param(params); 41 debug_log(url); 42 Tession.goToTNEW(url); 43 }; 44 45 t.AddAnchorToCart = function() { 46 $('.sideblock .error-msg').empty(); 47 let params = { 48 don: $('.donate-form-input select[name=fund]').val(), //Program 49 fieldAmt: $('#ts-anchor-amount').val().replace(/,/g, "") || 0, //Donation Amount 50 anchor: 1, 51 }, 52 err = false; 53 54 if (!params.don) { 55 $('.sideblock .error-msg').append("<span>No fund selected.<br></span>"); 56 err = true; 57 } 58 59 if (parseInt(params.fieldAmt) < 750) { 60 $('.sideblock .error-msg').append("<span>Amount must be $750 or more.<br></span>"); 61 err = true; 62 } 63 64 if (err) { $('.loader-wrapper').addClass('is-hidden'); t.busy = false; return false; } 65 66 let sess = Tession.assertSessionKey( 67 false, // if true, session must already exist to be valid 68 function(d,s){ 69 // This executes if a session exists or has been established. 70 //console.log("Assertion success, executing callback..."); 71 var url = Tession.SSURL() + 'donate/contribute1?' + $.param(params); 72 73 //alert("Passed."); 74 Tession.goToTNEW(url); 75 return true; 76 }, 77 function(d,s){ 78 // Error trying to assert the session. 79 pushException('addDonation-noSessAssert'); 80 console.log("Couldn't assert session to use for donation"); 81 $('.loader-wrapper').addClass('is-hidden'); 82 $('.sideblock error-msg').text('We are experiencing some issues with connecting you to the donation portal. If you would like to complete your donation to Georgia Aquarium, please contact our team directly at (404) 581-4000.'); 83 t.busy = false; 84 return false; 85 } 86 ); 87 88 89 90 }; 91 92 t.checkAnchorValid = function() { 93 let amt = parseInt(t.anchor.val().replace(/,/g, "")) || 0, //Donation Amount 94 fund = parseInt($('.donate-form-input select[name=fund]').val()) || 0, 95 err = false; 96 97 console.log("Amt",amt); 98 console.log("Fund",fund); 99 if (amt < 750) { 100 $('input[name=donation_amount]').addClass('invalid'); 101 err = true; 102 } 103 else { 104 $('input[name=donation_amount]').removeClass('invalid'); 105 } 106 107 if (fund < 1) { 108 $('.donate-form-input select[name=fund]').addClass('invalid'); 109 err = true; 110 } 111 else { 112 $('.donate-form-input select[name=fund]').removeClass('invalid'); 113 } 114 115 if (!err) { 116 $('.sideblock .error-msg').empty(); 117 } 118 119 return err; 120 121 } 122 123 t.submitDonation = function(myForm = null) { 124 $('.error-msg').empty(); 125 126 let sess = Tession.assertSessionKey( 127 false, // if true, session must already exist to be valid 128 function(d,s){ 129 // This executes if a session exists or has been established.
130 //console.log("Assertion success, executing callback..."); 131 t.AddDonationToCart(myForm); 132 }, 133 function(d,s){ 134 // Error trying to assert the session. 135 pushException('addDonation-noSessAssert'); 136 console.log("Couldn't assert session to use for donation"); 137 $('.loader-wrapper').addClass('is-hidden'); 138 t.busy = false; 139 $('.error-msg').text('We are experiencing some issues with connecting you to the donation portal. If you would like to complete your donation to Georgia Aquarium, please contact our team directly at (404) 581-4000.'); 140 $('.loader-wrapper').addClass('is-hidden'); 141 } 142 ); 143 } 144 145 t.handleRecaptcha = function(token) { 146 $('.error-msg').empty(); 147 $('.loader-wrapper').removeClass('is-hidden'); 148 if (t.busy) { 149 return false; 150 } else { 151 t.busy = true; 152 } 153 154 $.ajax({ 155 type: "POST", 156 url: apiBaseURI + 'handleRecaptcha', 157 contentType: 'application/json', 158 data: JSON.stringify({ 159 token: token 160 }), 161 timeout: 30000, // 30 seconds 162 dataType: 'json', 163 success: function (data, status) { 164 165 console.log("Recaptcha response:",data); 166 if (data.status === 'success') { 167 if (t.anchor.length) { 168 t.AddAnchorToCart(); 169 } 170 else { 171 t.submitDonation(); 172 } 173 174 } else { 175 pushException('donationRecaptcha-errorResponse'); 176 // Show an error. 177 $('.error-msg').text('We are experiencing some issues with connecting you to the donation portal. If you would like to complete your donation to Georgia Aquarium, please contact our team directly at (404) 581-4000.'); 178 $('.loader-wrapper').addClass('is-hidden'); 179 } 180 }, 181 error: function (jqXHR, status, errorThrown) { 182 pushException('donationRecaptcha-badResponse'); 183 // Show an error. 184 $('.error-msg').text('We are experiencing some issues with connecting you to the donation portal. If you would like to complete your donation to Georgia Aquarium, please contact our team directly at (404) 581-4000.'); 185 $('.loader-wrapper').addClass('is-hidden'); 186 }, 187 complete: function (jqXHR, status) { 188 t.busy = false; 189 } 190 }); 191 192 } 193 194 t.checkDonationValid = function() { 195 let val = $('#donation_amount').val().replace(/,/g, ""); 196 debug_log("Checking donation amount ", val); 197 if (val !== '' && parseInt(val) > 0 && $('input[name="program"]:checked').length) { 198 $('#ts-donations-contact .form-actions button').removeClass('disabled'); 199 } 200 else { 201 $('#ts-donations-contact .form-actions button').addClass('disabled'); 202 } 203 } 204 205 t.init = function() { 206 t.container = $('#ts-donations-amount, .donate-form'); 207 t.anchor = $('#ts-anchor-amount'); 208 t.anchor_fund = $('select[name="fund"]'); 209 210 if (t.container.length) { 211 debug_log("Donation routine active"); 212 213 //If we came here from a quick donate submit, prepopulate. 214 if (urlParam('donation_amount')) { 215 let amt = parseInt(urlParam('donation_amount')); 216 console.log(urlParam('donation_amount'),'parses to ',amt); 217 218 } 219 220 t.container.on('click', 'label.amt-button', function (e) { 221 $('#donation_amount').val($(this).find('input').val()); 222 $('.form-input-radio-buttons label', t.container).removeClass('is-active'); 223 $(this).addClass('is-active'); 224 225 }); 226 227 $('#ts-donations-program').on('click', 'label.program-button', function (e) { 228 $('#ts-donations-program .form-input-radio-buttons label').removeClass('is-active'); 229 $(this).addClass('is-active'); 230 //$('input[name="program"]').removeAttr('checked'); 231 //$(this).find('input').attr('checked', 'checked'); 232 //console.log("Program value: ",$('input[name="program"]:checked').val()); 233 234 t.checkDonationValid(); 235 }); 236 237 $('#donation_amount').on('change keyup blur', function (e) { 238 t.checkDonationValid(); 239 }); 240 241 $('#ts-donations-contact .form-actions button').on('click', function (e) { 242 e.preventDefault(); 243 if ($(this).hasClass('disabled')) { 244 return false;
245 } 246 247 if (false && typeof grecaptcha !== 'undefined') { 248 grecaptcha.ready(function() { 249 console.log("Running ready handler on ts-donations-contact",'6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV'); 250 grecaptcha.execute('6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV').then(t.handleRecaptcha); 251 }); 252 } 253 else { 254 if (t.anchor.length) { 255 t.AddAnchorToCart(); 256 } 257 else { 258 t.submitDonation(); 259 } 260 } 261 }); 262 263 $('form.donate-form .donate-form-submit a, form.donate-form .donate-form-submit button').on('click', function (e) { 264 e.preventDefault(); 265 if (false && typeof grecaptcha !== 'undefined') { 266 grecaptcha.ready(function() { 267 console.log("Running ready handler on donate-form",'6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV'); 268 grecaptcha.execute('6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV').then(t.handleRecaptcha); 269 }); 270 } 271 else { 272 t.submitDonation($(this).eq(0).closest('.donate-form')); 273 } 274 }); 275 276 // a11y: keyboard users pressing Enter inside the amount input should 277 // route through the same submitDonation() codepath as a click on the 278 // submit button. Without this, native form submission would POST to 279 // the action URL and bypass recaptcha / anchor-cart logic. 280 $('form.donate-form').on('submit', function (e) { 281 e.preventDefault(); 282 t.submitDonation($(this)); 283 }); 284 285 } 286 287 // This is for the sidebar donation mechanism. 288 if (t.anchor.length) { 289 console.log("Anchor"); 290 291 $('.donate-form-input button').on('click',function(e){ 292 let err = t.checkAnchorValid(); 293 e.preventDefault(); 294 if (t.anchor_fund.hasClass('invalid')) { 295 $('.sideblock .error-msg').append("<span>No fund selected.<br></span>"); 296 } 297 console.log("Is amount invalid",t.anchor.hasClass('invalid')); 298 if (t.anchor.hasClass('invalid')) { 299 $('.sideblock .error-msg').append("<span>Amount must be $750 or more.<br></span>"); 300 } 301 302 303 if (!err) { 304 console.log("Are we running ready handler?"); 305 t.AddAnchorToCart(); 306 /* 307 grecaptcha.ready(function() { 308 console.log("Running ready handler on donate-form-input button",'6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV'); 309 grecaptcha.execute('6LfAC6QrAAAAADOVQfdg6L_T23xFk-UYGFYvB8OV').then(t.handleRecaptcha); 310 }); 311 */ 312 } 313 314 }); 315 316 t.anchor.on('change keyup blur',t.checkAnchorValid); 317 t.anchor_fund.on('change blur',t.checkAnchorValid); 318 319 } 320 }; 321 322 return t; 323})(jQuery); 324 325jQuery(function(){ 326 gaiDonations.init(); 327}); 328 329
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.