1// Pricing Calculator Logic 2import '../modules/cookie-consent.js' 3 4let calculatorInitialized = false 5 6function formatNumber(num) { 7 return num.toLocaleString() 8} 9 10function formatCurrency(num) { 11 return '$' + num.toLocaleString() 12} 13 14function getTierInfo(leads) { 15 // Updated to match actual pricing boxes 16 const tiers = [ 17 { name: 'Starter', leads: 750, price: 1997 }, 18 { name: 'Growth', leads: 1500, price: 3750 }, 19 { name: 'Professional', leads: 3000, price: 4950 }, 20 ] 21 22 if (leads <= 750) { 23 return tiers[0] 24 } else if (leads <= 1500) { 25 return tiers[1] 26 } else if (leads <= 3000) { 27 return tiers[2] 28 } else { 29 return { name: 'Enterprise', leads: leads, price: 0 } 30 } 31} 32 33function getCostForLeads(leads) { 34 // Updated to match actual pricing boxes: 35 // Starter: 750 leads = $1,997 36 // Growth: 1,500 leads = $3,750 37 // Professional: 3,000 leads = $4,950 38 // Enterprise: Above 3,000 = custom pricing (approximately $1.65/lead above 3,000) 39 40 if (leads <= 750) { 41 return 1997 42 } else if (leads <= 1500) { 43 return 3750 44 } else if (leads <= 3000) { 45 return 4950 46 } else { 47 // Enterprise custom pricing: starts at $4,950 for 3,000 leads 48 // For higher volumes, calculate a discounted rate (approximately $1.65/lead above 3,000) 49 const baseLeads = 3000 50 const basePrice = 4950 51 const ratePerLead = 1.65 52 return Math.round(basePrice + (leads - baseLeads) * ratePerLead) 53 } 54} 55 56function calculateROI() { 57 const leads = parseInt(document.getElementById('leads-slider')?.value || 2500) 58 const profitPerLead = parseInt( 59 document.getElementById('profit-slider')?.value || 100 60 ) 61 const closeRate = parseInt( 62 document.getElementById('close-rate-slider')?.value || 10 63 ) 64 65 // Update display values 66 document.getElementById('leads-value').textContent = formatNumber(leads) 67 document.getElementById('profit-display').textContent = profitPerLead 68 document.getElementById('close-rate-display').textContent = closeRate 69 70 // Calculate results 71 const dealsClosed = Math.round(leads * (closeRate / 100)) 72 const revenue = dealsClosed * profitPerLead 73 const cost = getCostForLeads(leads) 74 const roi = cost > 0 ? Math.round(((revenue - cost) / cost) * 100) : 0 75 76 // Update results display 77 document.getElementById('result-leads').textContent = formatNumber(leads) 78 document.getElementById('result-deals').textContent = 79 formatNumber(dealsClosed) 80 document.getElementById('result-revenue').textContent = 81 formatCurrency(revenue) 82 document.getElementById('result-cost').textContent = formatCurrency(cost) 83 document.getElementById('result-roi').textContent = formatNumber(roi) + '%' 84 85 // Update cost color to purple 86 const costElement = document.getElementById('result-cost') 87 costElement.className = 'text-xl font-bold text-purple-400' 88 89 // Update recommended package 90 const tier = getTierInfo(leads) 91 if (leads > 3000) { 92 document.getElementById('recommended-package').textContent = 93 'Enterprise Custom: ' + formatNumber(leads) + ' Leads' 94 document.getElementById('package-price').textContent = 'Custom Quote' 95 } else { 96 document.getElementById('recommended-package').textContent = 97 tier.name + ' Plan: ' + formatNumber(tier.leads) + ' Leads' 98 document.getElementById('package-price').textContent = formatNumber(cost) 99 } 100 101 // Color the ROI based on value 102 const roiElement = document.getElementById('result-roi') 103 if (roi > 500) { 104 roiElement.className = 105 'text-5xl lg:text-6xl font-bold bg-gradient-to-r from-green-400 to-emerald-400 bg-clip-text text-transparent' 106 } else if (roi > 100) { 107 roiElement.className = 108 'text-5xl lg:text-6xl font-bold bg-gradient-to-r from-purple-400 to-blue-400 bg-clip-text text-transparent' 109 } else { 110 roiElement.className = 111 'text-5xl lg:text-6xl font-bold bg-gradient-to-r from-purple-400 to-blue-400 bg-clip-text text-transparent' 112 } 113} 114 115function initCalculator() { 116 if (calculatorInitialized) return 117 calculatorInitialized = true 118 119 const leadsSlider = document.getElementById('leads-slider') 120 const profitSlider = document.getElementById('profit-slider') 121 const closeRateSlider = document.getElementById('close-rate-slider') 122 123 if (leadsSlider) { 124 leadsSlider.addEventListener('input', calculateROI) 125 } 126 if (profitSlider) { 127 profitSlider.addEventListener('input', calculateROI) 128 } 129 if (closeRateSlider) { 130 closeRateSlider.addEventListener('input', calculateROI) 131 } 132 133 // Initial calculation 134 calculateROI() 135} 136
137function init() { 138 // Small delay to ensure DOM is ready 139 setTimeout(initCalculator, 100) 140} 141 142function teardown() { 143 calculatorInitialized = false 144} 145 146export { init, teardown }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.