SunFusion Solar Calculator

System Requirements

Select Solar Panel

Installation Type

// Add this after your main calculation code // Financing Calculator function calculateFinancing(totalCost) { const interestRates = { '5_year': 0.0499, // 4.99% APR '10_year': 0.0549, // 5.49% APR '15_year': 0.0599, // 5.99% APR '20_year': 0.0649, // 6.49% APR '25_year': 0.0699 // 6.99% APR }; const financingDiv = document.createElement('div'); financingDiv.className = 'result-box financing-section'; financingDiv.style.gridColumn = '1 / -1'; let financingContent = '

Financing Options

'; Object.entries(interestRates).forEach(([term, rate]) => { const years = parseInt(term); const monthlyPayment = calculateMonthlyPayment(totalCost, rate, years); const totalPayment = monthlyPayment * years * 12; financingContent += `
\${years} Year Term
Interest Rate: \${(rate * 100).toFixed(2)}%
Monthly Payment: \$\${monthlyPayment.toFixed(2)}
Total Cost: \$\${totalPayment.toLocaleString()}
`; }); financingContent += '
'; financingDiv.innerHTML = financingContent; document.querySelector('.results-grid').appendChild(financingDiv); } // Monthly Payment Calculator function calculateMonthlyPayment(principal, annualRate, years) { const monthlyRate = annualRate / 12; const numberOfPayments = years * 12; return (principal * monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments)) / (Math.pow(1 + monthlyRate, numberOfPayments) - 1); } // Environmental Impact Calculator function calculateEnvironmentalImpact(annualProduction) { const co2PerKwh = 0.855; // lbs of CO2 per kWh const treesPerTonCo2 = 45; // trees needed to absorb 1 ton of CO2 const milesPerKwh = 2.4; // miles driven per kWh equivalent const homesPowered = annualProduction / 10715; // average home uses 10,715 kWh per year const annualCo2Reduction = (annualProduction * co2PerKwh) / 2000; // Convert to tons const treesEquivalent = Math.round(annualCo2Reduction * treesPerTonCo2); const milesEquivalent = Math.round(annualProduction * milesPerKwh); const environmentalDiv = document.createElement('div'); environmentalDiv.className = 'result-box environmental-section'; environmentalDiv.style.gridColumn = '1 / -1'; environmentalDiv.innerHTML = `

Environmental Impact

🌍
\${annualCo2Reduction.toFixed(1)} tons
Annual COβ‚‚ Reduction
🌳
\${treesEquivalent.toLocaleString()}
Equivalent Trees Planted
πŸš—
\${milesEquivalent.toLocaleString()}
Miles Not Driven
🏠
\${homesPowered.toFixed(1)}
Homes Powered
`; document.querySelector('.results-grid').appendChild(environmentalDiv); } // Add these styles to your existing CSS const additionalStyles = ` .financing-section, .environmental-section { margin-top: 20px; } .financing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 15px; } .financing-option { background: rgba(0, 4, 40, 0.6); border: 1px solid var(--primary-color); border-radius: 8px; padding: 15px; } .financing-option .term { color: var(--primary-color); font-size: 1.2em; margin-bottom: 10px; } .financing-option .details { font-size: 0.9em; } .environmental-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin-top: 15px; text-align: center; } .impact-item { background: rgba(0, 4, 40, 0.6); border: 1px solid var(--primary-color); border-radius: 8px; padding: 15px; } .impact-icon { font-size: 2em; margin-bottom: 10px; } .impact-value { color: var(--primary-color); font-size: 1.4em; margin-bottom: 5px; } .impact-label { font-size: 0.9em; opacity: 0.8; } `; // Add the styles to the document const styleSheet = document.createElement('style'); styleSheet.textContent = additionalStyles; document.head.appendChild(styleSheet); // Update your calculate button event listener to include these calculations document.getElementById('calculateBtn').addEventListener('click', function() { // After your main calculations and results display: calculateFinancing(netCost); calculateEnvironmentalImpact(annualProduction); }); `; // Update the calculate button click handler to include export buttons const originalCalculateHandler = document.getElementById('calculateBtn').onclick; document.getElementById('calculateBtn').onclick = function() { originalCalculateHandler(); addExportButtons(); };