Health & Wellness Subscription Cost Analyzer

Add Your Subscriptions

Your Subscription List

Name Category Cost Cycle Monthly Est. ($) Annual Est. ($) Action

Your Spending Summary

Total Monthly Cost
$0.00
Total Annual Cost
$0.00
Total Subscriptions
0

Spending by Category (Monthly Est.)

Category# SubsTotal Monthly ($)Total Annual ($)

No spending to chart (all subscriptions might be $0).

'; } else { categoryChartDiv.innerHTML = '

Add subscriptions to see category spending.

'; } window.hwsca_pdfData = { subscriptions, totalMonthly, totalAnnual, categoryAnalysis }; }; window.hwsca_generatePdf = function() { const pdfElement = document.getElementById('hwsca-pdfOutput'); if (typeof html2pdf === 'undefined') { alert('PDF generation library is not loaded. Please check your internet connection.'); return; } if (!window.hwsca_pdfData) { alert('No data to generate PDF. Please add subscriptions and perform analysis first.'); return; } const data = window.hwsca_pdfData; pdfTotalSubs.textContent = data.subscriptions.length; pdfTotalMonthly.textContent = `$${data.totalMonthly.toFixed(2)}`; pdfTotalAnnual.textContent = `$${data.totalAnnual.toFixed(2)}`; pdfSubscriptionListBody.innerHTML = ''; if (data.subscriptions.length > 0) { data.subscriptions.forEach(sub => { const row = pdfSubscriptionListBody.insertRow(); row.insertCell().textContent = sub.name; row.insertCell().textContent = sub.category; row.insertCell().textContent = `$${sub.cost.toFixed(2)}`; row.insertCell().textContent = sub.cycle; row.insertCell().textContent = `$${sub.monthlyEquivalent.toFixed(2)}`; row.insertCell().textContent = `$${sub.annualEquivalent.toFixed(2)}`; }); } else { const row = pdfSubscriptionListBody.insertRow(); row.insertCell().colSpan = 6; row.cells[0].textContent = "No subscriptions were added."; row.cells[0].style.textAlign = "center"; } pdfCategoryBreakdownBody.innerHTML = ''; const sortedCategories = Object.keys(data.categoryAnalysis).sort((a,b) => data.categoryAnalysis[b].monthly - data.categoryAnalysis[a].monthly); if (sortedCategories.length > 0) { sortedCategories.forEach(category => { const catData = data.categoryAnalysis[category]; const row = pdfCategoryBreakdownBody.insertRow(); row.insertCell().textContent = category; row.insertCell().textContent = catData.count; row.insertCell().textContent = `$${catData.monthly.toFixed(2)}`; row.insertCell().textContent = `$${catData.annual.toFixed(2)}`; }); } else { const row = pdfCategoryBreakdownBody.insertRow(); row.insertCell().colSpan = 4; row.cells[0].textContent = "No category data to display."; row.cells[0].style.textAlign = "center"; } const filename = `Health_Wellness_Subscription_Analysis_${new Date().toISOString().slice(0,10)}.pdf`; const opt = { margin: [0.5, 0.4, 0.8, 0.4], filename: filename, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, letterRendering: true, scrollY: 0 }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfElement).set(opt).save(); }; // --- Tab Logic --- window.hwsca_openTab = function(event, tabId) { const tabContents = document.getElementsByClassName('hwsca-tab-content'); for (let i = 0; i < tabContents.length; i++) { tabContents[i].classList.remove('hwsca-active'); } const tabButtons = document.getElementsByClassName('hwsca-tab-button'); for (let i = 0; i < tabButtons.length; i++) { tabButtons[i].classList.remove('hwsca-active'); } const targetTabContent = document.getElementById(tabId); if (targetTabContent) { targetTabContent.classList.add('hwsca-active'); } else { console.error(`Tab content pane with ID '${tabId}' not found.`); return; } if (event && event.currentTarget) { event.currentTarget.classList.add('hwsca-active'); } else { // Programmatic call (e.g., from navigateToTab or initial setup) for (let i = 0; i < tabButtons.length; i++) { const btn = tabButtons[i]; const onclickAttr = btn.getAttribute('onclick'); if (onclickAttr && onclickAttr.includes(`hwsca_openTab(event, '${tabId}')`)) { btn.classList.add('hwsca-active'); break; } } } }; window.hwsca_navigateToTab = function(tabId) { window.hwsca_openTab(null, tabId); if (tabId === 'hwsca-analysisTab') { window.hwsca_calculateAndDisplayAnalysis(); } }; // --- Initial Render & Setup --- window.hwsca_renderSubscriptionList(); window.hwsca_openTab(null, 'hwsca-manageSubsTab'); });
Scroll to Top