Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 14 additions & 37 deletions src/lib/components/PaymentModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,10 @@

// Force reload iframe if it doesn't load within 5 seconds
const timeout = setTimeout(() => {
try {
// Check if iframe loaded properly
if (!iframe.contentWindow || !iframe.contentDocument ||
!iframe.contentDocument.body ||
iframe.contentDocument.body.innerHTML === "") {
console.log("Payment form might be blocked - showing fallback");
fallbackContainer.style.display = "block";
iframe.style.display = "none";
}
} catch (e) {
// If we get a security error when trying to access iframe contents,
// that indicates a cross-origin issue
console.log("Security error accessing iframe - likely blocked by browser", e);
// We can't reliably check cross-origin iframe content
// Just ensure the iframe is visible and working
if (!iframe.style.height || iframe.style.height === "0px") {
console.log("Payment form might be blocked - showing fallback");
fallbackContainer.style.display = "block";
iframe.style.display = "none";
}
Expand All @@ -138,31 +129,17 @@
iframe.onload = () => {
clearTimeout(timeout);

// Additional check after load to verify content is accessible
try {
// If we can access the iframe's location, it loaded successfully
const testAccess = iframe.contentWindow.location.href;
fallbackContainer.style.display = "none";
} catch (e) {
// If we get a security error, the content might have loaded but is
// not accessible due to cross-origin restrictions
console.log("Iframe loaded but content might be restricted", e);

// Set a longer timeout to give time for the actual form to render
// before showing fallback message
setTimeout(() => {
try {
// One final check before showing fallback
if (!iframe.contentWindow.document.body.innerHTML) {
fallbackContainer.style.display = "block";
iframe.style.display = "none";
}
} catch (e) {
fallbackContainer.style.display = "block";
iframe.style.display = "none";
}
}, 1000);
// We should not try to access iframe.contentWindow.location.href
// as it will cause cross-origin errors in most browsers
console.log("Iframe loaded successfully");

// Set a reasonable height for the iframe initially
if (!iframe.style.height || iframe.style.height === "0px") {
iframe.style.height = "600px";
}

// Hide fallback by default - we assume the iframe loaded
fallbackContainer.style.display = "none";
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/config/data/donate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ projects:
slug: spyder
image: /assets/media/spyder_splash_bg.webp
donationLinkID: Pjm6SyqYNb
pastDonations: 18645.86
pastDonations: 19144
- id: 1
slug: code-completions
image: /assets/media/donations-code_completions.webp
Expand Down
4 changes: 3 additions & 1 deletion src/routes/donate/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export async function load({ fetch }) {
// Sort deals into their respective projects
hubspotData.pipelineDeals.forEach((deal) => {
content.props.projects.forEach((project) => {
if (deal.properties.dealname.toLowerCase().includes(project.slug.toLowerCase())) {
// Replace hyphens with spaces for comparison
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
if (deal.properties.dealname.toLowerCase().includes(projectNameForComparison)) {
projectDonations[project.slug].deals.push(deal);
projectDonations[project.slug].total +=
parseFloat(deal.properties.amount) || 0;
Expand Down
4 changes: 3 additions & 1 deletion src/routes/donate/[slug]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export async function load({ params, fetch }) {

// Get deals for this project
hubspotData.pipelineDeals.forEach((deal) => {
// Replace hyphens with spaces for comparison
const projectNameForComparison = project.slug.toLowerCase().replace(/-/g, ' ');
if (
deal.properties.dealname.toLowerCase().includes(
project.slug.toLowerCase(),
projectNameForComparison
)
) {
projectDonations.deals.push(deal);
Expand Down
Loading