Calculators Financial Score Compare Blog Contact
FREE No signup required

Master Your Money with Smart Calculators

Plan your financial future, track your progress, and reach your goals faster with our suite of powerful, free tools.

20+
Free Tools
100%
Private
0
Ads
๐Ÿ“ˆ
Compound Interest
Watch your investments grow exponentially
$
%
๐Ÿ“…
$
โœจ
Future Value
Contributions: $0
Interest: $0
๐Ÿ“Š
50/30/20 Budget
The smart way to allocate your income
$
๐Ÿ“‹
Your Monthly Budget
๐Ÿ 
Needs (50%)
๐ŸŽ‰
Wants (30%)
๐Ÿ’ฐ
Savings (20%)
๐Ÿ’ณ
Debt Payoff
Find your path to debt freedom
$
%
$
๐ŸŽฏ
Debt-Free In
๐Ÿ“‰
Total Interest
๐Ÿ’ต
Total Amount Paid
๐ŸŽฏ
Savings Goal
Break big goals into small steps
$
$
๐Ÿ“…
๐Ÿ’ก
Save Each Month
๐Ÿ“†
Weekly Target
โ˜€๏ธ
Daily Target
๐Ÿ›ก๏ธ
Emergency Fund
Build your financial safety net
$
๐Ÿ“…
๐Ÿฆ
Recommended Fund
โšก
Minimum (3 months)
โœ…
Recommended (6 months)
๐Ÿ†
Secure (12 months)
โš–๏ธ
Net Worth
Track your total wealth
$
$
๐Ÿ’Ž
Your Net Worth
๐Ÿ“Š
Assets to Liabilities Ratio
๐Ÿ 
Mortgage Calculator
Calculate your monthly mortgage payment with taxes and insurance
$
%
%
๐Ÿ“…
๐Ÿ 
Monthly Payment
๐Ÿ’ฐ
Principal & Interest
๐Ÿ“Š
Loan Amount
๐Ÿ’ต
Total Interest Paid
๐Ÿš—
Car Payment Calculator
Calculate your monthly auto loan payment
$
$
%
๐Ÿ“…
๐Ÿš—
Monthly Payment
๐Ÿ’ฐ
Loan Amount
๐Ÿ’ต
Total Interest
๐Ÿ“Š
Total Cost
๐Ÿ–๏ธ
Retirement Calculator
See how much you'll have for retirement
๐Ÿ‘ค
๐ŸŽฏ
$
$
%
๐Ÿ–๏ธ
Retirement Savings
๐Ÿ“…
Years Until Retirement
๐Ÿ’ฐ
Total Contributions
๐Ÿ“ˆ
Interest Earned
๐Ÿ’ณ
Loan Calculator
Calculate payments for any type of loan
$
%
๐Ÿ“…
๐Ÿ’ณ
Monthly Payment
๐Ÿ’ต
Total Interest
๐Ÿ“Š
Total Amount Paid
๐Ÿ’ผ
Salary Calculator
Convert between hourly, monthly, and annual salary
$
๐Ÿ“…
โฐ
๐Ÿ’ผ
Salary Breakdown
โฐ
Hourly
๐Ÿ“…
Weekly
๐Ÿ“†
Monthly
๐Ÿ“Š
Annual
๐Ÿงพ
Income Tax Calculator
Estimate your federal income tax (US 2026)
$
๐Ÿ“‹
$
๐Ÿงพ
Estimated Federal Tax
๐Ÿ“Š
Effective Tax Rate
๐Ÿ’ฐ
Taxable Income
๐Ÿ’ต
Take-Home (After Tax)
๐Ÿ“‰
Inflation Calculator
See how inflation erodes your purchasing power over time
$
%
๐Ÿ“…
๐Ÿ“‰
Future Purchasing Power
๐Ÿ’ธ
Purchasing Power Lost
๐Ÿ“Š
Equivalent Today Needs
๐Ÿ”ฅ
FIRE Calculator
Calculate your path to Financial Independence, Retire Early
$
$
$
%
๐Ÿ”ฅ
Your FIRE Number
๐Ÿ“…
Years to FIRE
๐Ÿ’ฐ
Monthly Income (4% Rule)
๐Ÿ“Š
Current Progress
๐Ÿ’ต
Paycheck Calculator
Calculate your take-home pay after taxes and deductions
$
๐Ÿ“…
๐Ÿ“‹
๐Ÿ›๏ธ
๐Ÿ’ต
Take-Home Pay
๐Ÿ›๏ธ
Federal Tax
๐Ÿ 
State Tax
๐Ÿ›ก๏ธ
FICA (SS + Medicare)
๐Ÿ“‹
Amortization Calculator
See your complete loan payment schedule
$
%
๐Ÿ“…
$
๐Ÿ“‹
Monthly Payment
๐Ÿ’ฐ
Total Interest
๐Ÿ“Š
Total Cost
๐Ÿ“…
Payoff Date
๐ŸŒฑ
Roth IRA Calculator
Calculate tax-free retirement growth
๐Ÿ‘ค
๐ŸŽฏ
$
$
%
๐ŸŒฑ
Roth IRA at Retirement
๐Ÿ’ฐ
Total Contributions
๐Ÿ“ˆ
Tax-Free Growth
๐Ÿ’ต
Monthly Income (4% Rule)
๐Ÿ›๏ธ
Social Security Calculator
Compare benefits at different claiming ages
๐Ÿ“…
$
๐Ÿ‘ค
๐Ÿ›๏ธ
Optimal Claiming Age
๐Ÿ”ป
Claim at 62
โžก๏ธ
Claim at 67 (FRA)
๐Ÿ”บ
Claim at 70
๐ŸŽ“
Student Loan Calculator
Plan your student loan payoff strategy
$
%
$
๐Ÿ“…
๐ŸŽ“
Payoff Summary
๐Ÿ’ฐ
Total Interest
๐Ÿ“Š
Total Paid
๐Ÿ“…
Months to Payoff
๐Ÿก
Down Payment Calculator
Plan your home buying savings goal
$
%
$
$
๐Ÿก
Down Payment Needed
๐Ÿ’ฐ
Amount Still Needed
๐Ÿ“…
Months to Goal
๐Ÿ 
PMI Required?
๐Ÿ’น
401(k) Calculator
Calculate your retirement savings with employer match
๐Ÿ‘ค
๐ŸŽฏ
$
%
%
%
$
%
๐Ÿ’น
401(k) at Retirement
๐Ÿ’ฐ
Your Contributions
๐ŸŽ
Employer Match
๐Ÿ“ˆ
Investment Growth
๐Ÿ’ต
Monthly Income (4% Rule)
๐Ÿ“Š
Investment Calculator
Project your investment returns over time
$
$
%
๐Ÿ“…
๐Ÿ“Š
Future Value
Total Invested: $0
Returns: $0
๐Ÿ“‹
Debt-to-Income Calculator
Check if you qualify for a mortgage or loan
$
$
$
$
$
$
๐Ÿ“‹
Your DTI Ratio
๐Ÿ 
Front-End DTI (Housing)
๐Ÿ“Š
Back-End DTI (Total)
โœ…
Loan Eligibility
๐Ÿ’ณ
Credit Utilization Calculator
Optimize your credit score by managing utilization
$
$
๐Ÿ’ณ
Credit Utilization
๐Ÿ“Š
Credit Score Impact
๐ŸŽฏ
Optimal Balance (30%)
โญ
Ideal Balance (10%)
๐Ÿ’ฟ
CD Calculator
Calculate certificate of deposit returns
$
%
๐Ÿ“…
๐Ÿ”„
๐Ÿ’ฟ CD At Maturity
๐Ÿ’ฐ
Interest Earned
๐Ÿ“ˆ
Effective APY
๐Ÿ“Š
APY Calculator
Convert interest rate to annual percentage yield
%
๐Ÿ”„
๐Ÿ“Š Annual Percentage Yield
๐Ÿ’ต
Extra Earned per $10,000
๐Ÿ“ˆ
APY vs APR Difference
๐Ÿš™
Auto Loan Calculator
Calculate your car loan payment
$
$
$
%
๐Ÿ“…
๐Ÿš™ Monthly Payment
๐Ÿ’ณ
Loan Amount
๐Ÿ’ฐ
Total Interest
๐Ÿ“Š
Total Cost
๐Ÿก
Home Affordability
How much house can you afford?
$
$
$
%
%
$
๐Ÿก Maximum Home Price
๐Ÿ’ต
Max Monthly Payment
๐Ÿ“‹
DTI Ratio Used
๐Ÿ’ณ
Loan Amount
๐Ÿ”’
100% Private
All calculations happen in your browser. We never store or transmit your financial data.
โšก
Instant Results
Get accurate calculations in milliseconds with our optimized algorithms.
๐Ÿ“ฑ
Works Everywhere
Use on any deviceโ€”desktop, tablet, or phone. No app download required.
๐ŸŽ
Always Free
No subscriptions, no hidden fees, no catch. Just helpful tools for everyone.
// Compound Interest Calculator function calculateCompound(btn) { setButtonLoading(btn, true); setTimeout(() => { const principal = parseFloat(document.getElementById('ci-principal').value) || 0; const rate = parseFloat(document.getElementById('ci-rate').value) / 100; const years = parseFloat(document.getElementById('ci-years').value) || 0; const monthly = parseFloat(document.getElementById('ci-monthly').value) || 0; const n = 12; const t = years; const fvPrincipal = principal * Math.pow(1 + rate / n, n * t); const fvContributions = monthly * (Math.pow(1 + rate / n, n * t) - 1) / (rate / n); const futureValue = fvPrincipal + fvContributions; const totalContributions = principal + (monthly * 12 * years); const totalInterest = futureValue - totalContributions; const contributionsPercent = (totalContributions / futureValue) * 100; const interestPercent = (totalInterest / futureValue) * 100; document.getElementById('ci-future').textContent = formatCurrency(futureValue); document.getElementById('ci-contributions-legend').textContent = formatCurrency(totalContributions); document.getElementById('ci-interest-legend').textContent = formatCurrency(totalInterest); // Animate chart setTimeout(() => { document.getElementById('ci-chart-principal').style.width = contributionsPercent + '%'; document.getElementById('ci-chart-interest').style.width = interestPercent + '%'; }, 100); document.getElementById('ci-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Budget Calculator function calculateBudget(btn) { setButtonLoading(btn, true); setTimeout(() => { const income = parseFloat(document.getElementById('budget-income').value) || 0; const needs = income * 0.50; const wants = income * 0.30; const savings = income * 0.20; document.getElementById('budget-needs').textContent = formatCurrency(needs); document.getElementById('budget-wants').textContent = formatCurrency(wants); document.getElementById('budget-savings').textContent = formatCurrency(savings); document.getElementById('budget-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Debt Payoff Calculator function calculateDebt(btn) { setButtonLoading(btn, true); setTimeout(() => { const amount = parseFloat(document.getElementById('debt-amount').value) || 0; const rate = parseFloat(document.getElementById('debt-rate').value) / 100 / 12; const payment = parseFloat(document.getElementById('debt-payment').value) || 0; if (payment <= amount * rate) { document.getElementById('debt-months').textContent = "Payment too low! ๐Ÿ˜ฐ"; document.getElementById('debt-interest').textContent = "N/A"; document.getElementById('debt-total').textContent = "N/A"; document.getElementById('debt-result').classList.add('show'); setButtonLoading(btn, false); return; } const months = Math.ceil(-Math.log(1 - (amount * rate / payment)) / Math.log(1 + rate)); const totalPaid = months * payment; const totalInterest = totalPaid - amount; const yearsCalc = Math.floor(months / 12); const monthsRemaining = months % 12; let timeString = months + ' months'; if (yearsCalc > 0) { timeString = yearsCalc + ' yr ' + monthsRemaining + ' mo'; } document.getElementById('debt-months').textContent = timeString; document.getElementById('debt-interest').textContent = formatCurrency(totalInterest); document.getElementById('debt-total').textContent = formatCurrency(totalPaid); document.getElementById('debt-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Savings Goal Calculator function calculateSavingsGoal(btn) { setButtonLoading(btn, true); setTimeout(() => { const goal = parseFloat(document.getElementById('goal-amount').value) || 0; const current = parseFloat(document.getElementById('goal-current').value) || 0; const months = parseFloat(document.getElementById('goal-months').value) || 1; const remaining = goal - current; const monthly = remaining / months; const weekly = monthly / 4.33; const daily = monthly / 30; document.getElementById('goal-monthly').textContent = formatCurrency(monthly); document.getElementById('goal-weekly').textContent = formatCurrency(weekly); document.getElementById('goal-daily').textContent = formatCurrency(daily); document.getElementById('goal-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Emergency Fund Calculator function calculateEmergency(btn) { setButtonLoading(btn, true); setTimeout(() => { const expenses = parseFloat(document.getElementById('ef-expenses').value) || 0; const months = parseFloat(document.getElementById('ef-months').value) || 6; const target = expenses * months; document.getElementById('ef-target').textContent = formatCurrency(target); document.getElementById('ef-3mo').textContent = formatCurrency(expenses * 3); document.getElementById('ef-6mo').textContent = formatCurrency(expenses * 6); document.getElementById('ef-12mo').textContent = formatCurrency(expenses * 12); document.getElementById('ef-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Net Worth Calculator function calculateNetWorth(btn) { setButtonLoading(btn, true); setTimeout(() => { const assets = parseFloat(document.getElementById('nw-assets').value) || 0; const liabilities = parseFloat(document.getElementById('nw-liabilities').value) || 0; const netWorth = assets - liabilities; const ratio = liabilities > 0 ? (assets / liabilities).toFixed(2) : "โˆž"; const assetPercent = assets > 0 && liabilities > 0 ? (assets / (assets + liabilities)) * 100 : 100; document.getElementById('nw-total').textContent = formatCurrency(netWorth); document.getElementById('nw-ratio').textContent = ratio + " : 1"; // Animate chart setTimeout(() => { document.getElementById('nw-chart-assets').style.width = assetPercent + '%'; }, 100); document.getElementById('nw-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Mortgage Calculator function calculateMortgage(btn) { setButtonLoading(btn, true); setTimeout(() => { const price = parseFloat(document.getElementById('mort-price').value) || 0; const downPercent = parseFloat(document.getElementById('mort-down').value) || 0; const rate = parseFloat(document.getElementById('mort-rate').value) || 0; const years = parseFloat(document.getElementById('mort-years').value) || 30; const downPayment = price * (downPercent / 100); const loanAmount = price - downPayment; const monthlyRate = rate / 100 / 12; const numPayments = years * 12; let monthlyPayment; if (monthlyRate === 0) { monthlyPayment = loanAmount / numPayments; } else { monthlyPayment = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, numPayments)) / (Math.pow(1 + monthlyRate, numPayments) - 1); } const totalPaid = monthlyPayment * numPayments; const totalInterest = totalPaid - loanAmount; document.getElementById('mort-payment').textContent = formatCurrency(monthlyPayment); document.getElementById('mort-pi').textContent = formatCurrency(monthlyPayment); document.getElementById('mort-loan').textContent = formatCurrency(loanAmount); document.getElementById('mort-total-interest').textContent = formatCurrency(totalInterest); document.getElementById('mort-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Car Payment Calculator function calculateCar(btn) { setButtonLoading(btn, true); setTimeout(() => { const price = parseFloat(document.getElementById('car-price').value) || 0; const down = parseFloat(document.getElementById('car-down').value) || 0; const rate = parseFloat(document.getElementById('car-rate').value) || 0; const months = parseFloat(document.getElementById('car-months').value) || 60; const loanAmount = price - down; const monthlyRate = rate / 100 / 12; let monthlyPayment; if (monthlyRate === 0) { monthlyPayment = loanAmount / months; } else { monthlyPayment = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, months)) / (Math.pow(1 + monthlyRate, months) - 1); } const totalPaid = monthlyPayment * months; const totalInterest = totalPaid - loanAmount; document.getElementById('car-payment').textContent = formatCurrency(monthlyPayment); document.getElementById('car-loan').textContent = formatCurrency(loanAmount); document.getElementById('car-interest').textContent = formatCurrency(totalInterest); document.getElementById('car-total').textContent = formatCurrency(totalPaid + down); document.getElementById('car-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Retirement Calculator function calculateRetirement(btn) { setButtonLoading(btn, true); setTimeout(() => { const currentAge = parseFloat(document.getElementById('ret-age').value) || 30; const retireAge = parseFloat(document.getElementById('ret-retire-age').value) || 65; const currentSavings = parseFloat(document.getElementById('ret-current').value) || 0; const monthlyContrib = parseFloat(document.getElementById('ret-monthly').value) || 0; const annualReturn = parseFloat(document.getElementById('ret-return').value) || 7; const years = retireAge - currentAge; const monthlyRate = annualReturn / 100 / 12; const months = years * 12; // Future value of current savings const fvCurrent = currentSavings * Math.pow(1 + monthlyRate, months); // Future value of monthly contributions let fvContributions; if (monthlyRate === 0) { fvContributions = monthlyContrib * months; } else { fvContributions = monthlyContrib * ((Math.pow(1 + monthlyRate, months) - 1) / monthlyRate); } const totalSavings = fvCurrent + fvContributions; const totalContributions = currentSavings + (monthlyContrib * months); const interestEarned = totalSavings - totalContributions; document.getElementById('ret-total').textContent = formatCurrency(totalSavings); document.getElementById('ret-years').textContent = years + ' years'; document.getElementById('ret-contributions').textContent = formatCurrency(totalContributions); document.getElementById('ret-interest').textContent = formatCurrency(interestEarned); document.getElementById('ret-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Loan Calculator function calculateLoan(btn) { setButtonLoading(btn, true); setTimeout(() => { const amount = parseFloat(document.getElementById('loan-amount').value) || 0; const rate = parseFloat(document.getElementById('loan-rate').value) || 0; const years = parseFloat(document.getElementById('loan-years').value) || 5; const monthlyRate = rate / 100 / 12; const months = years * 12; let monthlyPayment; if (monthlyRate === 0) { monthlyPayment = amount / months; } else { monthlyPayment = amount * (monthlyRate * Math.pow(1 + monthlyRate, months)) / (Math.pow(1 + monthlyRate, months) - 1); } const totalPaid = monthlyPayment * months; const totalInterest = totalPaid - amount; document.getElementById('loan-payment').textContent = formatCurrency(monthlyPayment); document.getElementById('loan-interest').textContent = formatCurrency(totalInterest); document.getElementById('loan-total').textContent = formatCurrency(totalPaid); document.getElementById('loan-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Salary Calculator function calculateSalary(btn) { setButtonLoading(btn, true); setTimeout(() => { const amount = parseFloat(document.getElementById('sal-amount').value) || 0; const period = document.getElementById('sal-period').value; const hoursPerWeek = parseFloat(document.getElementById('sal-hours').value) || 40; let annual; const weeksPerYear = 52; switch (period) { case 'hourly': annual = amount * hoursPerWeek * weeksPerYear; break; case 'weekly': annual = amount * weeksPerYear; break; case 'biweekly': annual = amount * 26; break; case 'monthly': annual = amount * 12; break; case 'annual': default: annual = amount; } const hourly = annual / (hoursPerWeek * weeksPerYear); const weekly = annual / weeksPerYear; const monthly = annual / 12; document.getElementById('sal-hourly').textContent = formatCurrency(hourly); document.getElementById('sal-weekly').textContent = formatCurrency(weekly); document.getElementById('sal-monthly').textContent = formatCurrency(monthly); document.getElementById('sal-annual').textContent = formatCurrency(annual); document.getElementById('sal-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Tax Calculator (US 2026 Brackets) function calculateTax(btn) { setButtonLoading(btn, true); setTimeout(() => { const income = parseFloat(document.getElementById('tax-income').value) || 0; const status = document.getElementById('tax-status').value; const deductions = parseFloat(document.getElementById('tax-deductions').value) || 0; const taxableIncome = Math.max(0, income - deductions); // 2026 Tax Brackets const brackets = { single: [ { max: 11600, rate: 0.10 }, { max: 47150, rate: 0.12 }, { max: 100525, rate: 0.22 }, { max: 191950, rate: 0.24 }, { max: 243725, rate: 0.32 }, { max: 609350, rate: 0.35 }, { max: Infinity, rate: 0.37 } ], married: [ { max: 23200, rate: 0.10 }, { max: 94300, rate: 0.12 }, { max: 201050, rate: 0.22 }, { max: 383900, rate: 0.24 }, { max: 487450, rate: 0.32 }, { max: 731200, rate: 0.35 }, { max: Infinity, rate: 0.37 } ], head: [ { max: 16550, rate: 0.10 }, { max: 63100, rate: 0.12 }, { max: 100500, rate: 0.22 }, { max: 191950, rate: 0.24 }, { max: 243700, rate: 0.32 }, { max: 609350, rate: 0.35 }, { max: Infinity, rate: 0.37 } ] }; const selectedBrackets = brackets[status] || brackets.single; let tax = 0; let previousMax = 0; for (const bracket of selectedBrackets) { if (taxableIncome <= previousMax) break; const taxableInBracket = Math.min(taxableIncome, bracket.max) - previousMax; tax += taxableInBracket * bracket.rate; previousMax = bracket.max; } const effectiveRate = income > 0 ? (tax / income * 100).toFixed(1) : 0; const takeHome = income - tax; document.getElementById('tax-total').textContent = formatCurrency(tax); document.getElementById('tax-rate').textContent = effectiveRate + '%'; document.getElementById('tax-taxable').textContent = formatCurrency(taxableIncome); document.getElementById('tax-takehome').textContent = formatCurrency(takeHome); document.getElementById('tax-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Inflation Calculator function calculateInflation(btn) { setButtonLoading(btn, true); setTimeout(() => { const amount = parseFloat(document.getElementById('inf-amount').value) || 10000; const rate = parseFloat(document.getElementById('inf-rate').value) || 3; const years = parseFloat(document.getElementById('inf-years').value) || 10; // Calculate future purchasing power (what today's money will buy in the future) const futureValue = amount / Math.pow(1 + rate / 100, years); const purchasingPowerLost = amount - futureValue; // What you'd need in the future to have the same purchasing power as today const equivalentNeeded = amount * Math.pow(1 + rate / 100, years); document.getElementById('inf-future').textContent = formatCurrency(futureValue); document.getElementById('inf-lost').textContent = formatCurrency(purchasingPowerLost); document.getElementById('inf-equivalent').textContent = formatCurrency(equivalentNeeded); document.getElementById('inf-result').classList.add('show'); setButtonLoading(btn, false); // Save to history if (typeof CalculatorHistory !== 'undefined') { CalculatorHistory.add('inflation', { amount, rate, years }, { futureValue: Math.round(futureValue), lost: Math.round(purchasingPowerLost) } ); } }, 500); } // FIRE (Financial Independence, Retire Early) Calculator function calculateFIRE(btn) { setButtonLoading(btn, true); setTimeout(() => { const annualExpenses = parseFloat(document.getElementById('fire-expenses').value) || 50000; const currentSavings = parseFloat(document.getElementById('fire-current').value) || 100000; const monthlySavings = parseFloat(document.getElementById('fire-monthly').value) || 2000; const expectedReturn = parseFloat(document.getElementById('fire-return').value) || 7; // FIRE Number = Annual Expenses ร— 25 (4% rule) const fireNumber = annualExpenses * 25; // Monthly income at FIRE (4% withdrawal rate) const monthlyIncome = fireNumber * 0.04 / 12; // Current progress percentage const progress = (currentSavings / fireNumber) * 100; // Calculate years to FIRE using compound interest formula // We need to solve for time when FV = fireNumber // FV = PV(1+r)^n + PMT * ((1+r)^n - 1) / r const monthlyRate = expectedReturn / 100 / 12; let years = 0; let balance = currentSavings; if (balance < fireNumber) { // Iterate month by month until we reach FIRE number let months = 0; const maxMonths = 100 * 12; // Cap at 100 years while (balance < fireNumber && months < maxMonths) { balance = balance * (1 + monthlyRate) + monthlySavings; months++; } years = months / 12; } document.getElementById('fire-number').textContent = formatCurrency(fireNumber); document.getElementById('fire-years').textContent = years === 0 ? '๐ŸŽ‰ Already there!' : (years >= 100 ? '100+ years' : years.toFixed(1) + ' years'); document.getElementById('fire-income').textContent = formatCurrency(monthlyIncome); document.getElementById('fire-progress').textContent = progress.toFixed(1) + '%'; document.getElementById('fire-result').classList.add('show'); setButtonLoading(btn, false); // Save to history if (typeof CalculatorHistory !== 'undefined') { CalculatorHistory.add('fire', { annualExpenses, currentSavings, monthlySavings, expectedReturn }, { fireNumber: Math.round(fireNumber), yearsToFire: years.toFixed(1) } ); } }, 500); } // Paycheck/Take-Home Pay Calculator function calculatePaycheck(btn) { setButtonLoading(btn, true); setTimeout(() => { const grossSalary = parseFloat(document.getElementById('pay-gross').value) || 75000; const frequency = document.getElementById('pay-frequency').value; const status = document.getElementById('pay-status').value; const stateTaxRate = parseFloat(document.getElementById('pay-state').value) || 5; // Calculate periods per year const periods = { 'weekly': 52, 'biweekly': 26, 'semimonthly': 24, 'monthly': 12 }; const periodsPerYear = periods[frequency] || 26; const grossPerPeriod = grossSalary / periodsPerYear; // FICA taxes (2026 rates) const socialSecurityRate = 0.062; const medicareRate = 0.0145; const ficaPerPeriod = grossPerPeriod * (socialSecurityRate + medicareRate); // Simplified federal tax estimate (effective rate based on brackets) let federalRate; if (grossSalary <= 11600) federalRate = 0.10; else if (grossSalary <= 47150) federalRate = 0.12; else if (grossSalary <= 100525) federalRate = 0.15; else if (grossSalary <= 191950) federalRate = 0.18; else federalRate = 0.22; // Married adjustment if (status === 'married') federalRate *= 0.85; const federalPerPeriod = grossPerPeriod * federalRate; const statePerPeriod = grossPerPeriod * (stateTaxRate / 100); const netPerPeriod = grossPerPeriod - federalPerPeriod - statePerPeriod - ficaPerPeriod; document.getElementById('pay-net').textContent = formatCurrency(netPerPeriod) + '/paycheck'; document.getElementById('pay-federal').textContent = formatCurrency(federalPerPeriod); document.getElementById('pay-state-tax').textContent = formatCurrency(statePerPeriod); document.getElementById('pay-fica').textContent = formatCurrency(ficaPerPeriod); document.getElementById('pay-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Amortization Calculator function calculateAmortization(btn) { setButtonLoading(btn, true); setTimeout(() => { const loanAmount = parseFloat(document.getElementById('amort-amount').value) || 250000; const rate = parseFloat(document.getElementById('amort-rate').value) || 6.5; const years = parseFloat(document.getElementById('amort-years').value) || 30; const extraPayment = parseFloat(document.getElementById('amort-extra').value) || 0; const monthlyRate = rate / 100 / 12; const totalMonths = years * 12; // Standard monthly payment let monthlyPayment; if (monthlyRate === 0) { monthlyPayment = loanAmount / totalMonths; } else { monthlyPayment = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, totalMonths)) / (Math.pow(1 + monthlyRate, totalMonths) - 1); } // Calculate with extra payments let balance = loanAmount; let totalInterest = 0; let months = 0; const maxMonths = totalMonths; while (balance > 0.01 && months < maxMonths * 2) { const interestPayment = balance * monthlyRate; let principalPayment = monthlyPayment - interestPayment + extraPayment; if (principalPayment > balance) { principalPayment = balance; } balance -= principalPayment; totalInterest += interestPayment; months++; } const totalCost = loanAmount + totalInterest; const payoffDate = new Date(); payoffDate.setMonth(payoffDate.getMonth() + months); document.getElementById('amort-payment').textContent = formatCurrency(monthlyPayment + extraPayment); document.getElementById('amort-interest').textContent = formatCurrency(totalInterest); document.getElementById('amort-total').textContent = formatCurrency(totalCost); document.getElementById('amort-payoff').textContent = payoffDate.toLocaleDateString('en-US', { month: 'short', year: 'numeric' }); document.getElementById('amort-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Roth IRA Calculator function calculateRothIRA(btn) { setButtonLoading(btn, true); setTimeout(() => { const currentAge = parseFloat(document.getElementById('roth-age').value) || 30; const retireAge = parseFloat(document.getElementById('roth-retire').value) || 65; const annualContrib = parseFloat(document.getElementById('roth-contrib').value) || 7000; const currentBalance = parseFloat(document.getElementById('roth-balance').value) || 25000; const expectedReturn = parseFloat(document.getElementById('roth-return').value) || 7; const years = retireAge - currentAge; const monthlyRate = expectedReturn / 100 / 12; const months = years * 12; const monthlyContrib = annualContrib / 12; // Future value of current balance const fvBalance = currentBalance * Math.pow(1 + monthlyRate, months); // Future value of contributions let fvContribs; if (monthlyRate === 0) { fvContribs = monthlyContrib * months; } else { fvContribs = monthlyContrib * ((Math.pow(1 + monthlyRate, months) - 1) / monthlyRate); } const totalValue = fvBalance + fvContribs; const totalContributions = currentBalance + (annualContrib * years); const taxFreeGrowth = totalValue - totalContributions; const monthlyIncome = totalValue * 0.04 / 12; document.getElementById('roth-total').textContent = formatCurrency(totalValue); document.getElementById('roth-contributions').textContent = formatCurrency(totalContributions); document.getElementById('roth-growth').textContent = formatCurrency(taxFreeGrowth); document.getElementById('roth-income').textContent = formatCurrency(monthlyIncome); document.getElementById('roth-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Social Security Calculator function calculateSocialSecurity(btn) { setButtonLoading(btn, true); setTimeout(() => { const birthYear = parseFloat(document.getElementById('ss-birth').value) || 1970; const benefitAt67 = parseFloat(document.getElementById('ss-benefit').value) || 2500; const lifeExpectancy = parseFloat(document.getElementById('ss-life').value) || 85; // Calculate benefits at different ages // Claim at 62: 70% of FRA benefit // Claim at 67: 100% (Full Retirement Age) // Claim at 70: 124% of FRA benefit const benefit62 = benefitAt67 * 0.70; const benefit67 = benefitAt67; const benefit70 = benefitAt67 * 1.24; // Calculate lifetime benefits const months62 = (lifeExpectancy - 62) * 12; const months67 = (lifeExpectancy - 67) * 12; const months70 = (lifeExpectancy - 70) * 12; const lifetime62 = benefit62 * months62; const lifetime67 = benefit67 * months67; const lifetime70 = benefit70 * months70; // Determine optimal age let optimal = '62'; let maxLifetime = lifetime62; if (lifetime67 > maxLifetime) { optimal = '67'; maxLifetime = lifetime67; } if (lifetime70 > maxLifetime) { optimal = '70'; maxLifetime = lifetime70; } document.getElementById('ss-optimal').textContent = 'Age ' + optimal + ' (Best Value)'; document.getElementById('ss-62').textContent = formatCurrency(benefit62) + '/mo'; document.getElementById('ss-67').textContent = formatCurrency(benefit67) + '/mo'; document.getElementById('ss-70').textContent = formatCurrency(benefit70) + '/mo'; document.getElementById('ss-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Student Loan Calculator function calculateStudentLoan(btn) { setButtonLoading(btn, true); setTimeout(() => { const balance = parseFloat(document.getElementById('student-balance').value) || 35000; const rate = parseFloat(document.getElementById('student-rate').value) || 5.5; const payment = parseFloat(document.getElementById('student-payment').value) || 400; const term = parseFloat(document.getElementById('student-term').value) || 10; const monthlyRate = rate / 100 / 12; // Calculate months to payoff with given payment let currentBalance = balance; let totalInterest = 0; let months = 0; const maxMonths = term * 12 * 2; while (currentBalance > 0.01 && months < maxMonths) { const interestPayment = currentBalance * monthlyRate; const principalPayment = payment - interestPayment; if (principalPayment <= 0) { // Payment too low months = Infinity; break; } currentBalance -= principalPayment; totalInterest += interestPayment; months++; } const totalPaid = balance + totalInterest; const payoffDate = new Date(); payoffDate.setMonth(payoffDate.getMonth() + months); document.getElementById('student-payoff-date').textContent = months === Infinity ? 'Payment too low!' : payoffDate.toLocaleDateString('en-US', { month: 'short', year: 'numeric' }); document.getElementById('student-interest').textContent = formatCurrency(totalInterest); document.getElementById('student-total').textContent = formatCurrency(totalPaid); document.getElementById('student-months').textContent = months === Infinity ? 'N/A' : months + ' months'; document.getElementById('student-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Down Payment Calculator function calculateDownPayment(btn) { setButtonLoading(btn, true); setTimeout(() => { const homePrice = parseFloat(document.getElementById('dp-price').value) || 400000; const downPercent = parseFloat(document.getElementById('dp-percent').value) || 20; const currentSavings = parseFloat(document.getElementById('dp-savings').value) || 20000; const monthlySavings = parseFloat(document.getElementById('dp-monthly').value) || 1500; const downPaymentNeeded = homePrice * (downPercent / 100); const amountNeeded = Math.max(0, downPaymentNeeded - currentSavings); const monthsToGoal = monthlySavings > 0 ? Math.ceil(amountNeeded / monthlySavings) : Infinity; const pmiRequired = downPercent < 20; document.getElementById('dp-amount').textContent = formatCurrency(downPaymentNeeded); document.getElementById('dp-needed').textContent = amountNeeded > 0 ? formatCurrency(amountNeeded) : 'โœ… Already saved!'; document.getElementById('dp-months').textContent = amountNeeded <= 0 ? '0' : (monthsToGoal === Infinity ? 'N/A' : monthsToGoal + ' months'); document.getElementById('dp-pmi').textContent = pmiRequired ? 'โš ๏ธ Yes (under 20%)' : 'โœ… No'; document.getElementById('dp-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // 401(k) Calculator function calculate401k(btn) { setButtonLoading(btn, true); setTimeout(() => { const currentAge = parseFloat(document.getElementById('k401-age').value) || 30; const retireAge = parseFloat(document.getElementById('k401-retire').value) || 65; const salary = parseFloat(document.getElementById('k401-salary').value) || 75000; const contribPercent = parseFloat(document.getElementById('k401-contrib').value) || 10; const matchPercent = parseFloat(document.getElementById('k401-match').value) || 50; const matchLimit = parseFloat(document.getElementById('k401-limit').value) || 6; const currentBalance = parseFloat(document.getElementById('k401-balance').value) || 50000; const expectedReturn = parseFloat(document.getElementById('k401-return').value) || 7; const years = retireAge - currentAge; const monthlyRate = expectedReturn / 100 / 12; const months = years * 12; // Annual contributions const yourAnnualContrib = salary * (contribPercent / 100); // Employer match (match % of your contribution, up to match limit % of salary) const matchableAmount = Math.min(yourAnnualContrib, salary * (matchLimit / 100)); const employerAnnualMatch = matchableAmount * (matchPercent / 100); const totalAnnualContrib = yourAnnualContrib + employerAnnualMatch; const monthlyContrib = totalAnnualContrib / 12; // Future value of current balance const fvBalance = currentBalance * Math.pow(1 + monthlyRate, months); // Future value of contributions let fvContribs; if (monthlyRate === 0) { fvContribs = monthlyContrib * months; } else { fvContribs = monthlyContrib * ((Math.pow(1 + monthlyRate, months) - 1) / monthlyRate); } const totalAtRetirement = fvBalance + fvContribs; const totalYourContribs = yourAnnualContrib * years; const totalEmployerMatch = employerAnnualMatch * years; const investmentGrowth = totalAtRetirement - currentBalance - totalYourContribs - totalEmployerMatch; const monthlyIncome = totalAtRetirement * 0.04 / 12; document.getElementById('k401-total').textContent = formatCurrency(totalAtRetirement); document.getElementById('k401-your-contrib').textContent = formatCurrency(totalYourContribs); document.getElementById('k401-employer').textContent = formatCurrency(totalEmployerMatch); document.getElementById('k401-growth').textContent = formatCurrency(investmentGrowth); document.getElementById('k401-income').textContent = formatCurrency(monthlyIncome) + '/mo'; document.getElementById('k401-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Investment Return Calculator function calculateInvestment(btn) { setButtonLoading(btn, true); setTimeout(() => { const initial = parseFloat(document.getElementById('inv-initial').value) || 10000; const monthly = parseFloat(document.getElementById('inv-monthly').value) || 500; const annualReturn = parseFloat(document.getElementById('inv-return').value) || 8; const years = parseFloat(document.getElementById('inv-years').value) || 20; const monthlyRate = annualReturn / 100 / 12; const months = years * 12; // Future value of initial investment const fvInitial = initial * Math.pow(1 + monthlyRate, months); // Future value of monthly contributions let fvContribs; if (monthlyRate === 0) { fvContribs = monthly * months; } else { fvContribs = monthly * ((Math.pow(1 + monthlyRate, months) - 1) / monthlyRate); } const futureValue = fvInitial + fvContribs; const totalInvested = initial + (monthly * months); const totalReturns = futureValue - totalInvested; // Chart percentages const principalPercent = (totalInvested / futureValue) * 100; const returnsPercent = (totalReturns / futureValue) * 100; document.getElementById('inv-future').textContent = formatCurrency(futureValue); document.getElementById('inv-invested').textContent = formatCurrency(totalInvested); document.getElementById('inv-returns').textContent = formatCurrency(totalReturns); document.getElementById('inv-chart-principal').style.width = principalPercent + '%'; document.getElementById('inv-chart-returns').style.width = returnsPercent + '%'; document.getElementById('inv-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Debt-to-Income Ratio Calculator function calculateDTI(btn) { setButtonLoading(btn, true); setTimeout(() => { const income = parseFloat(document.getElementById('dti-income').value) || 6000; const housing = parseFloat(document.getElementById('dti-housing').value) || 1500; const car = parseFloat(document.getElementById('dti-car').value) || 400; const credit = parseFloat(document.getElementById('dti-credit').value) || 200; const student = parseFloat(document.getElementById('dti-student').value) || 300; const other = parseFloat(document.getElementById('dti-other').value) || 0; const totalDebt = housing + car + credit + student + other; const frontEndDTI = (housing / income) * 100; const backEndDTI = (totalDebt / income) * 100; // Determine loan eligibility let status = ''; if (backEndDTI <= 36) { status = 'โœ… Excellent'; } else if (backEndDTI <= 43) { status = 'โœ… Good'; } else if (backEndDTI <= 50) { status = 'โš ๏ธ May qualify'; } else { status = 'โŒ High risk'; } document.getElementById('dti-ratio').textContent = backEndDTI.toFixed(1) + '%'; document.getElementById('dti-frontend').textContent = frontEndDTI.toFixed(1) + '%'; document.getElementById('dti-backend').textContent = backEndDTI.toFixed(1) + '%'; document.getElementById('dti-status').textContent = status; document.getElementById('dti-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Credit Utilization Calculator function calculateCreditUtil(btn) { setButtonLoading(btn, true); setTimeout(() => { const balance = parseFloat(document.getElementById('cu-balance').value) || 3000; const limit = parseFloat(document.getElementById('cu-limit').value) || 15000; const utilization = limit > 0 ? (balance / limit) * 100 : 0; const optimalBalance = limit * 0.30; const idealBalance = limit * 0.10; // Credit score impact let impact = ''; if (utilization <= 10) { impact = 'โญ Excellent'; } else if (utilization <= 30) { impact = 'โœ… Good'; } else if (utilization <= 50) { impact = 'โš ๏ธ Fair'; } else if (utilization <= 75) { impact = '๐Ÿ”ป Poor'; } else { impact = 'โŒ Very Poor'; } document.getElementById('cu-percent').textContent = utilization.toFixed(1) + '%'; document.getElementById('cu-impact').textContent = impact; document.getElementById('cu-optimal').textContent = formatCurrency(optimalBalance); document.getElementById('cu-ideal').textContent = formatCurrency(idealBalance); document.getElementById('cu-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // CD Calculator function calculateCD(btn) { setButtonLoading(btn, true); setTimeout(() => { const deposit = parseFloat(document.getElementById('cd-deposit').value) || 10000; const apy = parseFloat(document.getElementById('cd-apy').value) || 5; const termMonths = parseFloat(document.getElementById('cd-term').value) || 12; const compound = parseFloat(document.getElementById('cd-compound').value) || 365; const rate = apy / 100; const years = termMonths / 12; // Calculate maturity value const maturityValue = deposit * Math.pow(1 + rate / compound, compound * years); const interestEarned = maturityValue - deposit; // Calculate effective APY const effectiveAPY = (Math.pow(maturityValue / deposit, 1 / years) - 1) * 100; document.getElementById('cd-total').textContent = formatCurrency(maturityValue); document.getElementById('cd-interest').textContent = formatCurrency(interestEarned); document.getElementById('cd-effective-apy').textContent = effectiveAPY.toFixed(2) + '%'; document.getElementById('cd-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // APY Calculator function calculateAPY(btn) { setButtonLoading(btn, true); setTimeout(() => { const rate = parseFloat(document.getElementById('apy-rate').value) || 5; const compound = parseFloat(document.getElementById('apy-compound').value) || 12; // APY = (1 + r/n)^n - 1 const apr = rate / 100; const apy = (Math.pow(1 + apr / compound, compound) - 1) * 100; // Extra earned per $10,000 const simpleInterest = 10000 * (rate / 100); const compoundInterest = 10000 * (apy / 100); const extra = compoundInterest - simpleInterest; const diff = apy - rate; document.getElementById('apy-value').textContent = apy.toFixed(3) + '%'; document.getElementById('apy-extra').textContent = formatCurrency(extra); document.getElementById('apy-diff').textContent = '+' + diff.toFixed(3) + '%'; document.getElementById('apy-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Auto Loan Calculator function calculateAutoLoan(btn) { setButtonLoading(btn, true); setTimeout(() => { const price = parseFloat(document.getElementById('auto-price').value) || 35000; const down = parseFloat(document.getElementById('auto-down').value) || 5000; const trade = parseFloat(document.getElementById('auto-trade').value) || 0; const rate = parseFloat(document.getElementById('auto-rate').value) || 6.5; const term = parseFloat(document.getElementById('auto-term').value) || 60; const loanAmount = price - down - trade; const monthlyRate = rate / 100 / 12; let monthlyPayment; if (monthlyRate === 0) { monthlyPayment = loanAmount / term; } else { monthlyPayment = loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, term)) / (Math.pow(1 + monthlyRate, term) - 1); } const totalPaid = monthlyPayment * term; const totalInterest = totalPaid - loanAmount; const totalCost = price + totalInterest; document.getElementById('auto-payment').textContent = formatCurrency(monthlyPayment); document.getElementById('auto-loan-amount').textContent = formatCurrency(loanAmount); document.getElementById('auto-interest').textContent = formatCurrency(totalInterest); document.getElementById('auto-total').textContent = formatCurrency(totalCost); document.getElementById('auto-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Home Affordability Calculator function calculateAffordability(btn) { setButtonLoading(btn, true); setTimeout(() => { const income = parseFloat(document.getElementById('afford-income').value) || 100000; const debts = parseFloat(document.getElementById('afford-debts').value) || 500; const down = parseFloat(document.getElementById('afford-down').value) || 60000; const rate = parseFloat(document.getElementById('afford-rate').value) || 6.5; const taxRate = parseFloat(document.getElementById('afford-tax').value) || 1.2; const insurance = parseFloat(document.getElementById('afford-insurance').value) || 1500; const monthlyIncome = income / 12; const maxDTI = 0.36; // Conservative 36% DTI // Max total housing payment (including existing debts) const maxTotalPayment = monthlyIncome * maxDTI; const maxHousingPayment = maxTotalPayment - debts; // Work backwards to find max home price const monthlyRate = rate / 100 / 12; const months = 30 * 12; // 30-year mortgage // Start with max housing payment and subtract taxes/insurance // Then calculate the loan amount that fits within this // We'll iterate to find the right price let homePrice = 0; for (let price = 50000; price <= 2000000; price += 5000) { const loanAmount = price - down; const monthlyPrincipalInterest = monthlyRate === 0 ? loanAmount / months : loanAmount * (monthlyRate * Math.pow(1 + monthlyRate, months)) / (Math.pow(1 + monthlyRate, months) - 1); const monthlyTax = (price * taxRate / 100) / 12; const monthlyInsurance = insurance / 12; const totalMonthly = monthlyPrincipalInterest + monthlyTax + monthlyInsurance; if (totalMonthly <= maxHousingPayment) { homePrice = price; } else { break; } } const loanAmount = homePrice - down; const usedDTI = ((maxHousingPayment + debts) / monthlyIncome * 100).toFixed(0); document.getElementById('afford-max').textContent = formatCurrency(homePrice); document.getElementById('afford-payment').textContent = formatCurrency(maxHousingPayment); document.getElementById('afford-dti').textContent = usedDTI + '%'; document.getElementById('afford-loan').textContent = formatCurrency(loanAmount); document.getElementById('afford-result').classList.add('show'); setButtonLoading(btn, false); }, 500); } // Debounce utility for real-time calculation function debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } // Real-time auto-calculation on input change function setupAutoCalculation() { const calculatorMap = { 'ci-': 'calculateCompound', 'budget-': 'calculateBudget', 'debt-': 'calculateDebt', 'goal-': 'calculateSavingsGoal', 'ef-': 'calculateEmergency', 'nw-': 'calculateNetWorth', 'mort-': 'calculateMortgage', 'car-': 'calculateCar', 'ret-': 'calculateRetirement', 'loan-': 'calculateLoan', 'sal-': 'calculateSalary', 'tax-': 'calculateTax', 'inf-': 'calculateInflation', 'fire-': 'calculateFIRE', 'pay-': 'calculatePaycheck', 'amort-': 'calculateAmortization', 'roth-': 'calculateRothIRA', 'ss-': 'calculateSocialSecurity', 'student-': 'calculateStudentLoan', 'dp-': 'calculateDownPayment', 'k401-': 'calculate401k', 'inv-': 'calculateInvestment', 'dti-': 'calculateDTI', 'cu-': 'calculateCreditUtil', 'cd-': 'calculateCD', 'apy-': 'calculateAPY', 'auto-': 'calculateAutoLoan', 'afford-': 'calculateAffordability' }; document.querySelectorAll('.tool-card input, .tool-card select').forEach(input => { input.addEventListener('input', debounce(() => { const inputId = input.id || ''; for (const [prefix, funcName] of Object.entries(calculatorMap)) { if (inputId.startsWith(prefix)) { const btn = input.closest('.tool-card').querySelector('.btn'); if (btn && typeof window[funcName] === 'function') { window[funcName](btn); } break; } } }, 500)); }); } // Initialize auto-calculation document.addEventListener('DOMContentLoaded', setupAutoCalculation); // Smooth scroll for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth' }); } }); }); // Email Form Handler - ConvertKit Integration // NOTE: Replace FORM_ID with your actual ConvertKit form ID // Get it from: Kit Dashboard โ†’ Forms โ†’ Select form โ†’ Settings โ†’ Form ID const CONVERTKIT_API_KEY = 'kit_fc61b39b4a6fd5c2857d6f11704ae411'; const CONVERTKIT_FORM_ID = 'YOUR_FORM_ID'; // โ† REPLACE THIS async function handleEmailSubmit(e) { e.preventDefault(); const email = document.getElementById('email-input').value; const btn = document.querySelector('.email-btn'); const originalText = btn.innerHTML; // Show loading state btn.innerHTML = 'Sending...'; btn.disabled = true; try { // ConvertKit API call const response = await fetch(`https://api.convertkit.com/v3/forms/${CONVERTKIT_FORM_ID}/subscribe`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ api_key: CONVERTKIT_API_KEY, email: email, }), }); if (response.ok) { btn.innerHTML = 'โœ“ Success! Check your email'; btn.style.background = 'var(--secondary)'; document.getElementById('email-input').value = ''; // Track conversion console.log('Email signup success:', email); // gtag('event', 'signup', { method: 'email_capture' }); } else { throw new Error('Subscription failed'); } } catch (error) { console.error('Email signup error:', error); btn.innerHTML = 'โš  Error - Try again'; btn.style.background = '#ef4444'; } // Reset button after delay setTimeout(() => { btn.innerHTML = originalText; btn.style.background = 'white'; btn.disabled = false; }, 3000); } // Animate elements on scroll const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, { threshold: 0.1 }); document.querySelectorAll('.animate-on-scroll').forEach(el => { observer.observe(el); }); // Track affiliate clicks document.querySelectorAll('.recommended-card').forEach(card => { card.addEventListener('click', function () { const affiliate = this.dataset.affiliate; console.log('Affiliate click:', affiliate); // gtag('event', 'affiliate_click', { affiliate_program: affiliate }); // Track to backend fetch('/api/track/affiliate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ affiliate, page: window.location.pathname }) }).catch(() => { }); }); }); // ============================================ // ANALYTICS TRACKING (connects to backend) // ============================================ const ANALYTICS_API = window.location.origin + '/api'; // Track page view on load function trackPageView() { fetch(ANALYTICS_API + '/track/pageview', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ page: window.location.pathname, referrer: document.referrer }) }).catch(() => { }); // Silently fail if backend not running } // Track calculator usage (override existing functions) function trackCalculator(name) { fetch(ANALYTICS_API + '/track/calculator', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ calculator: name }) }).catch(() => { }); } // Wrap calculator functions to add tracking const originalCalculateCompound = calculateCompound; calculateCompound = function (btn) { trackCalculator('compound-interest'); originalCalculateCompound(btn); }; const originalCalculateBudget = calculateBudget; calculateBudget = function (btn) { trackCalculator('50-30-20-budget'); originalCalculateBudget(btn); }; const originalCalculateDebt = calculateDebt; calculateDebt = function (btn) { trackCalculator('debt-payoff'); originalCalculateDebt(btn); }; const originalCalculateSavings = calculateSavings; calculateSavings = function (btn) { trackCalculator('savings-goal'); originalCalculateSavings(btn); }; const originalCalculateEmergency = calculateEmergency; calculateEmergency = function (btn) { trackCalculator('emergency-fund'); originalCalculateEmergency(btn); }; const originalCalculateNetWorth = calculateNetWorth; calculateNetWorth = function (btn) { trackCalculator('net-worth'); originalCalculateNetWorth(btn); }; const originalCalculateMortgage = calculateMortgage; calculateMortgage = function (btn) { trackCalculator('mortgage'); originalCalculateMortgage(btn); }; const originalCalculateCar = calculateCar; calculateCar = function (btn) { trackCalculator('car-payment'); originalCalculateCar(btn); }; const originalCalculateRetirement = calculateRetirement; calculateRetirement = function (btn) { trackCalculator('retirement'); originalCalculateRetirement(btn); }; const originalCalculateLoan = calculateLoan; calculateLoan = function (btn) { trackCalculator('loan'); originalCalculateLoan(btn); }; const originalCalculateSalary = calculateSalary; calculateSalary = function (btn) { trackCalculator('salary'); originalCalculateSalary(btn); }; const originalCalculateTax = calculateTax; calculateTax = function (btn) { trackCalculator('tax'); originalCalculateTax(btn); }; // Track page view on load trackPageView(); // ============================================ // PRINT / SHARE / COPY FUNCTIONALITY // ============================================ // Add action buttons to all result sections function addResultActionButtons() { document.querySelectorAll('.result').forEach(result => { // Only add if not already added if (!result.querySelector('.result-actions')) { const actionsDiv = document.createElement('div'); actionsDiv.className = 'result-actions'; actionsDiv.innerHTML = ` `; result.appendChild(actionsDiv); } }); } // Copy result to clipboard function copyResult(btn) { const result = btn.closest('.result'); const resultValue = result.querySelector('.result-value')?.textContent || ''; const resultLabel = result.querySelector('.result-label')?.textContent || ''; const toolCard = result.closest('.tool-card'); const toolName = toolCard?.querySelector('.tool-title')?.textContent || 'Calculator'; let text = `${toolName} Result:\n${resultLabel}: ${resultValue}`; // Add breakdown if exists const breakdown = result.querySelectorAll('.result-row'); if (breakdown.length > 0) { text += '\n\nBreakdown:'; breakdown.forEach(row => { const label = row.querySelector('.result-row-label span')?.textContent || ''; const value = row.querySelector('.result-row-value')?.textContent || ''; text += `\nโ€ข ${label}: ${value}`; }); } text += '\n\nโ€” Calculated with SmartMoney Tools (smartmoneytools.com)'; navigator.clipboard.writeText(text).then(() => { btn.classList.add('success'); btn.innerHTML = 'โœ… Copied!'; setTimeout(() => { btn.classList.remove('success'); btn.innerHTML = '๐Ÿ“‹ Copy'; }, 2000); }).catch(() => { alert('Copy failed. Please select and copy manually.'); }); } // Print result function printResult(btn) { const result = btn.closest('.result'); const toolCard = result.closest('.tool-card'); // Clone the tool card for printing const printContent = toolCard.cloneNode(true); printContent.classList.add('print-section'); // Remove action buttons from print printContent.querySelectorAll('.result-actions').forEach(el => el.remove()); // Create print window const printWindow = window.open('', '_blank'); printWindow.document.write(` SmartMoney Tools - Calculator Result ${printContent.outerHTML} `); printWindow.document.close(); printWindow.print(); } // Share result (Web Share API or copy link) function shareResult(btn) { const result = btn.closest('.result'); const resultValue = result.querySelector('.result-value')?.textContent || ''; const toolCard = result.closest('.tool-card'); const toolName = toolCard?.querySelector('.tool-title')?.textContent || 'Calculator'; const shareData = { title: `${toolName} Result - SmartMoney Tools`, text: `I just calculated my ${toolName.toLowerCase()}: ${resultValue}\n\nTry it yourself!`, url: window.location.href }; if (navigator.share) { navigator.share(shareData).catch(() => { // Fallback to copy copyShareLink(btn, shareData); }); } else { copyShareLink(btn, shareData); } } function copyShareLink(btn, data) { const text = `${data.text}\n${data.url}`; navigator.clipboard.writeText(text).then(() => { btn.classList.add('success'); btn.innerHTML = 'โœ… Link Copied!'; setTimeout(() => { btn.classList.remove('success'); btn.innerHTML = '๐Ÿ“ค Share'; }, 2000); }); } // Add buttons after results are shown const originalClassListAdd = Element.prototype.classList.add; document.querySelectorAll('.result').forEach(result => { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.target.classList.contains('show')) { addResultActionButtons(); } }); }); observer.observe(result, { attributes: true, attributeFilter: ['class'] }); }); // Register PWA Service Worker if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').catch(() => { // Service worker registration failed (fine for dev) }); } /* Cache bust: Wed Dec 17 05:04:57 PM EST 2025 */