let pmfMultiStepApplyFrameWrapper = document.getElementById('pmfMultiStepApplyFrame'); const { dataset } = pmfMultiStepApplyFrameWrapper; const { termsOfServiceUrl, thankYouPageUrl, organization } = dataset ?? {}; const termsOfConditionQuery = termsOfServiceUrl ? `termsOfServiceUrl=${encodeURIComponent(termsOfServiceUrl)}` : undefined; const thankYouPageQuery = thankYouPageUrl ? `thankYouPageUrl=${encodeURIComponent(thankYouPageUrl)}` : undefined; const organizationValue = organization ? `organization=${encodeURIComponent(organization)}` : undefined; const extraParams = [termsOfConditionQuery, thankYouPageQuery, organizationValue] .filter(Boolean) .join('&'); // Extract referralId from the WordPress page URL const pathParts = window.location.pathname.split('/').filter(Boolean); const knownPrefixes = ['apply-now', 'multi-step-apply-iframe-local.html', 'apply-now-dev-testing']; // Extend if needed let referralId = "youreferralid"; if (!referralId) referralId = new URLSearchParams(window.location.search).get('ref'); if (!referralId && pathParts.length >= 2 && knownPrefixes.includes(pathParts[pathParts.length - 2])) { referralId = pathParts[pathParts.length - 1]; } let iframe = document.createElement('iframe'); iframe.src = `https://apply.myrmapp.com/multi-step-apply${referralId ? '/' + referralId : ''}?mode=iframe&origin=${window.location.href}${extraParams ? '&' + extraParams : ''}`; iframe.width = '100%'; iframe.height = '100%'; iframe.style.border = '0'; iframe.style.borderRadius = '3px'; iframe.name = 'pmfMultiStepApplyFrame'; iframe.allow = 'clipboard-read; clipboard-write' pmfMultiStepApplyFrameWrapper.appendChild(iframe);