From 107fd2d25ffcd9d8da46612265ed3e5a17e8e39c Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 17 Jan 2026 17:55:06 -0700 Subject: [PATCH] Add ?a= parameter to give page for preset custom amounts --- static/give/afac26.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/static/give/afac26.html b/static/give/afac26.html index d5edd37..2c5acc9 100644 --- a/static/give/afac26.html +++ b/static/give/afac26.html @@ -149,7 +149,18 @@ history.replaceState({}, '', location.pathname); } + const amountParam = params.get('a'); let selectedDonation = 10; + if (amountParam) { + const amount = parseFloat(amountParam); + if (amount > 0) { + document.getElementById('custom-amount').value = amount % 1 === 0 ? amount : amount.toFixed(2); + const group = document.getElementById('donation-group'); + group.querySelectorAll('wa-button').forEach(b => b.classList.remove('selected')); + group.querySelector('wa-button[data-value="custom"]').classList.add('selected'); + selectedDonation = 'custom'; + } + } function setupButtonGroup(groupId, onChange) { const group = document.getElementById(groupId); @@ -178,7 +189,7 @@ donateBtn.addEventListener('click', async () => { let donationCents = 0; if (selectedDonation === 'custom') { - donationCents = (parseInt(document.getElementById('custom-amount').value) || 0) * 100; + donationCents = Math.round((parseFloat(document.getElementById('custom-amount').value) || 0) * 100); } else { donationCents = selectedDonation * 100; }