Poker Hand History Analyzer Input Form

Poker Hand History Analyzer

Hand Analysis

Your hand analysis will appear here.

Go to the "Enter Hand History" tab to paste your hand and begin.

Enter Hand History

Configuration

Add player names to highlight them in the action log. Changes are saved automatically.

Players to Watch

${hand.actions.river.map(highlightPlayer).join('
')}

` : ''}

Summary

Players:

    ${hand.players.map(p => `
  • ${escapeHTML(p.name)} ($${p.stack})
  • `).join('')}
${hand.hero.name ? `

Hero: ${escapeHTML(hand.hero.name)}

` : ''} ${hand.hero.cards ? `

Hero's Cards: ${formatCards(hand.hero.cards)}

` : ''}

${escapeHTML(hand.summary || 'Summary not found.')}

`; dashboardContent.innerHTML = html; pdfDownloadBtn.style.display = 'block'; } function renderConfigList() { if (playersToWatch.length === 0) { configList.innerHTML = '

No players being watched.

'; return; } configList.innerHTML = playersToWatch.map((player, index) => `
${escapeHTML(player)}
`).join(''); } async function downloadPhhaPdf() { if (typeof jspdf === 'undefined' || typeof html2canvas === 'undefined') { alert('PDF libraries are still loading. Please try again.'); return; } const { jsPDF } = jspdf; phhaContainer.classList.add('phha-pdf-view'); try { const canvas = await html2canvas(dashboardContent, { scale: 2, useCORS: true, logging: false }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4'); const contentWidth = pdf.internal.pageSize.getWidth() - 30; const contentHeight = (canvas.height * contentWidth) / canvas.width; pdf.setFont("helvetica", "bold"); pdf.setFontSize(18); pdf.setTextColor(getComputedStyle(document.documentElement).getPropertyValue('--phha-primary-color').trim()); pdf.text("Poker Hand Analysis", 15, 20); pdf.addImage(imgData, 'PNG', 15, 30, contentWidth, contentHeight); pdf.save('poker_hand_analysis.pdf'); } catch (error) { console.error("PHHA PDF Error:", error); alert("An error occurred generating the PDF."); } finally { phhaContainer.classList.remove('phha-pdf-view'); } } function escapeHTML(str) { if (typeof str !== 'string') return ''; return str.replace(/[&<>"']/g, m => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m])); } // --- 4. EVENT BINDING --- tabButtons.forEach((button, index) => button.addEventListener('click', () => showPhhaTab(index))); navNext.addEventListener('click', () => showPhhaTab(currentPhhaTab + 1)); navPrev.addEventListener('click', () => showPhhaTab(currentPhhaTab - 1)); pdfDownloadBtn.addEventListener('click', downloadPhhaPdf); loadSampleBtn.addEventListener('click', () => { handHistoryInput.value = sampleHandHistory; heroNameInput.value = 'Hero'; }); analyzeBtn.addEventListener('click', () => { const text = handHistoryInput.value; if (!text.trim()) { alert("Please paste a hand history first."); return; } const handData = parseHandHistory(text); if (handData) { renderAnalysis(handData); showPhhaTab(0); } }); addPlayerBtn.addEventListener('click', () => { const player = newPlayerInput.value.trim(); if (player && !playersToWatch.includes(player)) { playersToWatch.push(player); newPlayerInput.value = ''; renderConfigList(); } }); configList.addEventListener('click', (e) => { if (e.target.classList.contains('phha-delete-player')) { const index = parseInt(e.target.dataset.index, 10); playersToWatch.splice(index, 1); renderConfigList(); } }); // --- 5. INITIALIZATION --- renderConfigList(); showPhhaTab(0); });
Scroll to Top