PCI Compliance Tracker for Online Stores

PCI Compliance Tracker for Online Stores

Perform a self-assessment of your store's PCI DSS compliance status.

${failedCount}

`; renderComplianceChart(categoryScores); document.getElementById('download-pdf-btn').addEventListener('click', generatePdf); }; const renderComplianceChart = (categoryScores) => { const ctx = document.getElementById('compliance-chart').getContext('2d'); if (charts.compliance) charts.compliance.destroy(); charts.compliance = new Chart(ctx, { type: 'radar', data: { labels: appData.checklist.map(c => c.title), datasets: [{ label: 'Compliance Score', data: categoryScores, backgroundColor: 'rgba(37, 99, 235, 0.2)', borderColor: 'rgba(37, 99, 235, 1)', pointBackgroundColor: 'rgba(37, 99, 235, 1)' }] }, options: { responsive: true, maintainAspectRatio: false, scales: { r: { beginAtZero: true, max: 100, suggestedMin: 0 } }, plugins: { legend: { display: false } } } }); }; const renderChecklistTab = (category, tabId) => { const contentEl = document.getElementById(tabId); if (!contentEl) return; const itemsHtml = category.requirements.map(req => `

${req.text}

${['Pass', 'Fail', 'N/A'].map(status => `
`).join('')}
`).join(''); contentEl.innerHTML = `
${itemsHtml}
`; attachChecklistListeners(category); }; const renderDataConfig = () => { const configContent = document.getElementById('content-data-configuration'); if (!configContent) return; const configHtml = appData.checklist.map(category => `
${category.title}
${category.requirements.map(req => ``).join('')}
`).join(''); configContent.innerHTML = `

Customize Checklist Items

${configHtml}
`; attachConfigListeners(); }; // --- EVENT HANDLERS --- const attachChecklistListeners = (category) => { category.requirements.forEach(req => { document.querySelectorAll(`input[name="status-${req.id}"]`).forEach(radio => { radio.addEventListener('change', (e) => { req.status = e.target.value; appData.analysisResults = null; renderDashboard(); }); }); const textarea = document.querySelector(`#content-${category.id} textarea`); if(textarea) { textarea.addEventListener('change', (e) => { req.notes = e.target.value; }); } }); }; const attachConfigListeners = () => { document.querySelectorAll('.config-input').forEach(input => { input.addEventListener('change', e => { const reqId = e.target.dataset.id; appData.checklist.forEach(category => { const req = category.requirements.find(r => r.id === reqId); if(req) req.text = e.target.value; }); // Re-render checklist tabs to show updated text appData.checklist.forEach(cat => renderChecklistTab(cat, `content-${cat.id}`)); }); }); }; const generatePdf = () => { loadingOverlay.style.display = 'flex'; const { jsPDF } = window.jspdf; document.getElementById('pdf-generated-date').textContent = new Date().toLocaleString(); const pdfHeader = document.getElementById('pdf-header'); pdfHeader.classList.remove('hidden'); const fullContent = document.getElementById('pdf-content-area'); html2canvas(fullContent, { scale: 2, useCORS: true, logging: false, windowWidth: 1200 }) .then(canvas => { pdfHeader.classList.add('hidden'); const imgData = canvas.toDataURL('image/jpeg', 0.9); const pdf = new jsPDF({ orientation: 'landscape', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'JPEG', 0, 0, pdfWidth, imgHeight); pdf.save('PCI-Compliance-Report.pdf'); loadingOverlay.style.display = 'none'; }).catch(err => { console.error("PDF generation failed:", err); pdfHeader.classList.add('hidden'); 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: 'Compliance Dashboard', id: 'compliance-dashboard' }, ...appData.checklist.map(cat => ({ name: cat.title, id: cat.id })), { name: 'Data Configuration', id: 'data-configuration' } ]; 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(); appData.checklist.forEach(cat => renderChecklistTab(cat, `content-${cat.id}`)); renderDataConfig(); switchTab(0); }; initializeUI(); prevTabBtn.addEventListener('click', () => { if (activeTabIndex > 0) switchTab(activeTabIndex - 1); }); nextTabBtn.addEventListener('click', () => { if (activeTabIndex < tabIdentifiers.length - 1) switchTab(activeTabIndex + 1); }); });
Scroll to Top