Add ?a= parameter to give page for preset custom amounts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user