Psychological Pricing Strategy Tool

Psychological Pricing Strategy Tool

Discover pricing models that appeal to customer psychology.

For: ${analysisResult.productName}

Base Price: ${formatCurrency(analysisResult.basePrice)} | Generated:

Base Price for Analysis

${formatCurrency(analysisResult.basePrice)}

Product: ${analysisResult.productName}

${strategiesHtml}
`; document.getElementById('download-pdf-btn').addEventListener('click', generatePdf); }; const renderDataConfig = () => { const configContent = document.getElementById('content-data-config'); if (!configContent) return; configContent.innerHTML = `

Configure Your Product

$
`; document.getElementById('apply-btn').addEventListener('click', handleDataUpdate); }; const handleDataUpdate = () => { appData.productName = document.getElementById('product-name').value || "Unnamed Product"; appData.basePrice = parseFloat(document.getElementById('base-price').value) || 0; renderDashboard(); lucide.createIcons(); switchTab(0); }; const generatePdf = () => { loadingOverlay.style.display = 'flex'; const { jsPDF } = window.jspdf; const pdfContent = document.getElementById('pdf-content-area'); const pdfHeader = document.getElementById('pdf-header'); document.getElementById('pdf-generated-date').textContent = new Date().toLocaleDateString('en-US'); pdfHeader.classList.remove('hidden'); // Temporarily convert grid to flex column for better stacking in PDF document.getElementById('strategies-grid').classList.replace('grid', 'flex'); document.getElementById('strategies-grid').classList.add('flex-col'); html2canvas(pdfContent, { scale: 2, useCORS: true, logging: false, windowWidth: 1200 }) .then(canvas => { // Restore original classes pdfHeader.classList.add('hidden'); document.getElementById('strategies-grid').classList.replace('flex', 'grid'); document.getElementById('strategies-grid').classList.remove('flex-col'); const imgData = canvas.toDataURL('image/jpeg', 0.95); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'JPEG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft > 0) { position = -heightLeft; pdf.addPage(); pdf.addImage(imgData, 'JPEG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; } pdf.save(`Pricing-Strategies-${appData.productName.replace(/ /g, '_')}.pdf`); loadingOverlay.style.display = 'none'; }).catch(err => { console.error("PDF generation failed:", err); // Restore original classes in case of error pdfHeader.classList.add('hidden'); document.getElementById('strategies-grid').classList.replace('flex', 'grid'); document.getElementById('strategies-grid').classList.remove('flex-col'); loadingOverlay.style.display = 'none'; alert('An error occurred generating the PDF.'); }); }; // --- TAB NAVIGATION & INITIALIZATION --- const switchTab = (tabIndex) => { activeTabIndex = tabIndex; document.querySelectorAll('.tab-btn').forEach((btn, i) => btn.classList.toggle('active', i === tabIndex)); document.querySelectorAll('.tab-content').forEach((content, i) => content.classList.toggle('hidden', i !== tabIndex)); updateNavButtons(); }; const updateNavButtons = () => { prevTabBtn.disabled = activeTabIndex === 0; nextTabBtn.disabled = activeTabIndex === tabIdentifiers.length - 1; }; const initializeUI = () => { const tabs = [ { name: 'Pricing Dashboard', id: 'dashboard' }, { name: 'Data Configuration', id: 'data-config' } ]; tabIdentifiers = tabs.map(t => t.id); tabsContainer.innerHTML = tabs.map(tab => ``).join(''); mainContent.innerHTML = tabs.map(tab => `
`).join(''); tabs.forEach((tab, index) => { document.getElementById(`tab-${tab.id}`).addEventListener('click', () => switchTab(index)); }); renderDashboard(); renderDataConfig(); switchTab(0); lucide.createIcons(); }; initializeUI(); prevTabBtn.addEventListener('click', () => { if (activeTabIndex > 0) switchTab(activeTabIndex - 1); }); nextTabBtn.addEventListener('click', () => { if (activeTabIndex < tabIdentifiers.length - 1) switchTab(activeTabIndex + 1); }); });
Scroll to Top