| | |
| | function openTab(tabName) { |
| | |
| | const contents = document.querySelectorAll('.tab-content'); |
| | contents.forEach(content => content.classList.remove('active')); |
| |
|
| | |
| | const links = document.querySelectorAll('.tab-link'); |
| | links.forEach(link => link.classList.remove('active')); |
| |
|
| | |
| | document.getElementById(tabName).classList.add('active'); |
| | document.getElementById('link-' + tabName).classList.add('active'); |
| |
|
| | window.scrollTo({ top: 0, behavior: 'smooth' }); |
| | } |
| |
|
| | |
| | function calculateInterest() { |
| | const initial = parseFloat(document.getElementById('initial').value) || 0; |
| | const monthly = parseFloat(document.getElementById('monthly').value) || 0; |
| | const rateAnnual = parseFloat(document.getElementById('rate').value) || 0; |
| | const years = parseFloat(document.getElementById('years').value) || 0; |
| |
|
| | const months = years * 12; |
| | const rateMonthly = (rateAnnual / 100) / 12; |
| |
|
| | |
| | let total = initial * Math.pow(1 + rateMonthly, months); |
| | |
| | if (rateMonthly > 0) { |
| | total += monthly * ((Math.pow(1 + rateMonthly, months) - 1) / rateMonthly); |
| | } else { |
| | total += monthly * months; |
| | } |
| |
|
| | const formatter = new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }); |
| |
|
| | document.getElementById('result-value').innerText = formatter.format(total); |
| | document.getElementById('result-details').innerText = `Projeção baseada em ${months} meses de aportes.`; |
| | document.getElementById('calc-result').style.display = 'block'; |
| | } |
| |
|