Skip to content

Commit 4422c73

Browse files
Update donation data and other static data sources (#56)
1 parent 4a32944 commit 4422c73

File tree

6 files changed

+281
-160
lines changed

6 files changed

+281
-160
lines changed

src/lib/components/PaymentModal.svelte

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,10 @@
116116
117117
// Force reload iframe if it doesn't load within 5 seconds
118118
const timeout = setTimeout(() => {
119-
try {
120-
// Check if iframe loaded properly
121-
if (!iframe.contentWindow || !iframe.contentDocument ||
122-
!iframe.contentDocument.body ||
123-
iframe.contentDocument.body.innerHTML === "") {
124-
console.log("Payment form might be blocked - showing fallback");
125-
fallbackContainer.style.display = "block";
126-
iframe.style.display = "none";
127-
}
128-
} catch (e) {
129-
// If we get a security error when trying to access iframe contents,
130-
// that indicates a cross-origin issue
131-
console.log("Security error accessing iframe - likely blocked by browser", e);
119+
// We can't reliably check cross-origin iframe content
120+
// Just ensure the iframe is visible and working
121+
if (!iframe.style.height || iframe.style.height === "0px") {
122+
console.log("Payment form might be blocked - showing fallback");
132123
fallbackContainer.style.display = "block";
133124
iframe.style.display = "none";
134125
}
@@ -138,31 +129,17 @@
138129
iframe.onload = () => {
139130
clearTimeout(timeout);
140131
141-
// Additional check after load to verify content is accessible
142-
try {
143-
// If we can access the iframe's location, it loaded successfully
144-
const testAccess = iframe.contentWindow.location.href;
145-
fallbackContainer.style.display = "none";
146-
} catch (e) {
147-
// If we get a security error, the content might have loaded but is
148-
// not accessible due to cross-origin restrictions
149-
console.log("Iframe loaded but content might be restricted", e);
150-
151-
// Set a longer timeout to give time for the actual form to render
152-
// before showing fallback message
153-
setTimeout(() => {
154-
try {
155-
// One final check before showing fallback
156-
if (!iframe.contentWindow.document.body.innerHTML) {
157-
fallbackContainer.style.display = "block";
158-
iframe.style.display = "none";
159-
}
160-
} catch (e) {
161-
fallbackContainer.style.display = "block";
162-
iframe.style.display = "none";
163-
}
164-
}, 1000);
132+
// We should not try to access iframe.contentWindow.location.href
133+
// as it will cause cross-origin errors in most browsers
134+
console.log("Iframe loaded successfully");
135+
136+
// Set a reasonable height for the iframe initially
137+
if (!iframe.style.height || iframe.style.height === "0px") {
138+
iframe.style.height = "600px";
165139
}
140+
141+
// Hide fallback by default - we assume the iframe loaded
142+
fallbackContainer.style.display = "none";
166143
};
167144
}
168145

src/lib/config/data/donate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ projects:
33
slug: spyder
44
image: /assets/media/spyder_splash_bg.webp
55
donationLinkID: Pjm6SyqYNb
6-
pastDonations: 18645.86
6+
pastDonations: 19144
77
- id: 1
88
slug: code-completions
99
image: /assets/media/donations-code_completions.webp

src/routes/donate/+page.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export async function load({ fetch }) {
2626
// Sort deals into their respective projects
2727
hubspotData.pipelineDeals.forEach((deal) => {
2828
content.props.projects.forEach((project) => {
29-
if (deal.properties.dealname.toLowerCase().includes(project.slug.toLowerCase())) {
29+
// Replace hyphens with spaces for comparison
30+
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
31+
if (deal.properties.dealname.toLowerCase().includes(projectNameForComparison)) {
3032
projectDonations[project.slug].deals.push(deal);
3133
projectDonations[project.slug].total +=
3234
parseFloat(deal.properties.amount) || 0;

src/routes/donate/[slug]/+page.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ export async function load({ params, fetch }) {
3838

3939
// Get deals for this project
4040
hubspotData.pipelineDeals.forEach((deal) => {
41+
// Replace hyphens with spaces for comparison
42+
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
4143
if (
4244
deal.properties.dealname.toLowerCase().includes(
43-
project.slug.toLowerCase(),
45+
projectNameForComparison
4446
)
4547
) {
4648
projectDonations.deals.push(deal);

0 commit comments

Comments
 (0)