Writing Tone & Style Checker

Writing Tone & Style Checker

Get AI-powered feedback to improve your writing's impact and clarity.

Suggestion: ${item.suggestion}

`).join(''); } else { suggestionsPane.innerHTML = `

No specific style suggestions. The writing is clear and effective!

`; } analysisContent.style.display = 'block'; setActiveTab(0); }; const setActiveTab = (index) => { tabButtons.forEach((btn, i) => btn.classList.toggle('active', i === index)); tabPanes.forEach((pane, i) => pane.classList.toggle('active', i === index)); }; const showError = (message) => { apiErrorMessage.textContent = message; apiErrorMessage.style.display = 'block'; resultsContainer.style.display = 'none'; }; const hideError = () => { apiErrorMessage.style.display = 'none'; }; // --- PDF Generation --- async function generatePdf() { const { text, overallAnalysis, styleSuggestions } = lastResult; if (!text) return; const suggestionsHtml = styleSuggestions.length > 0 ? styleSuggestions.map(item => `
"${item.snippet}"

Suggestion: ${item.suggestion}

`).join('') : `

No specific style suggestions were provided.

`; pdfContentArea.innerHTML = `

Writing Tone & Style Report

Overall Analysis

${overallAnalysis}

Suggestions for Improvement

${suggestionsHtml} `; pdfContentArea.style.display = 'block'; pdfContentArea.style.position = 'absolute'; pdfContentArea.style.left = '-9999px'; pdfContentArea.style.width = '800px'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgHeight = canvas.height * pdfWidth / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight); pdf.save(`Writing-Analysis-Report.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("Could not generate PDF."); } finally { pdfContentArea.style.display = 'none'; } } // --- Event Listeners --- analyzeBtn.addEventListener('click', getAnalysis); tabButtons.forEach((btn, i) => btn.addEventListener('click', () => setActiveTab(i))); downloadPdfBtn.addEventListener('click', generatePdf); // --- Initial State --- textInput.value = "Each manager should submit his report by Friday. We need to make sure all manpower is allocated efficiently. This is a great opportunity for mankind to advance."; });
Scroll to Top