School ICT Self Study
📝 View in Your Language:
📘 A/L ICT Math Note Tool – Sinhala + Boolean Logic

🧮 A/L ICT Math & Boolean Note Tool

Type Sinhala or English notes. Use $...$ for inline math, $$...$$ for display math, and logical symbols like $\overline{X}$ for X̅ (X bar).

📊 Live Preview

Your formatted math and Sinhala text will appear here...

`); printWindow.document.close(); printWindow.print(); }// ✅ FIXED PDF EXPORT - Completely rewritten async function downloadPDF() { try { const preview = document.getElementById('preview'); // Wait for MathJax to render completely if (window.MathJax && MathJax.typesetPromise) { await MathJax.typesetPromise([preview]); await new Promise(resolve => setTimeout(resolve, 1000)); }const { jsPDF } = window.jspdf; const pdf = new jsPDF('p', 'mm', 'a4'); // Create a clean container for PDF export const pdfContainer = document.createElement('div'); pdfContainer.style.width = '190mm'; // A4 width minus margins pdfContainer.style.padding = '20mm'; pdfContainer.style.background = 'white'; pdfContainer.style.fontFamily = '"Nirmala UI", "Iskoola Pota", Arial, sans-serif'; pdfContainer.style.fontSize = '12pt'; pdfContainer.style.lineHeight = '1.6'; pdfContainer.style.position = 'absolute'; pdfContainer.style.left = '-9999px'; pdfContainer.style.top = '0'; // Get clean content let content = tinyMCEEditor.getContent(); // Clean content for PDF content = content .replace(/\\overline\{X\}/g, 'X̅') .replace(/\\overline\{A\}/g, 'A̅') .replace(/\\overline\{B\}/g, 'B̅') .replace(/\\overline\{([^}]*)\}/g, '$1̅') .replace(/\\cdot/g, '·') .replace(/\$\$\\overline\{([^}]*)\}\$\$/g, '$1̅') .replace(/\$\\overline\{([^}]*)\}\$/g, '$1̅') .replace(/\$\$(.*?)\$\$/g, '$1') .replace(/\$(.*?)\$/g, '$1') .replace(/📗|🧩|🧮|📘|📏|📊|🔄|🧹|➕|📄|🧾|📋|🔌|📚|💾|📂|🖨️/g, '') .replace(//g, '
') .replace(/
/g, '') .replace(//g, '');pdfContainer.innerHTML = `

Student Math Notes

Generated on ${new Date().toLocaleDateString()}

${content}
`; document.body.appendChild(pdfContainer);// Use html2canvas with simple configuration const canvas = await html2canvas(pdfContainer, { scale: 2, useCORS: true, logging: false, backgroundColor: '#ffffff', width: pdfContainer.scrollWidth, height: pdfContainer.scrollHeight });const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); // Calculate image dimensions to fit PDF const imgWidth = pdfWidth; const imgHeight = (canvas.height * pdfWidth) / canvas.width; // Add image to PDF pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight); // Clean up document.body.removeChild(pdfContainer); // Save PDF pdf.save('Student_Math_Note.pdf'); } catch (error) { console.error('PDF generation error:', error); alert('Error generating PDF. Please try again with simpler content.'); } }// ✅ FIXED WORD EXPORT - Simplified and reliable function downloadWord() { let content = tinyMCEEditor.getContent(); // Convert MathJax to Unicode content = content .replace(/\\overline\{X\}/g, 'X̅') .replace(/\\overline\{A\}/g, 'A̅') .replace(/\\overline\{B\}/g, 'B̅') .replace(/\\overline\{([^}]*)\}/g, '$1̅') .replace(/\\cdot/g, '·') .replace(/\$\$\\overline\{([^}]*)\}\$\$/g, '$1̅') .replace(/\$\\overline\{([^}]*)\}\$/g, '$1̅') .replace(/\$\$(.*?)\$\$/g, '$1') .replace(/\$(.*?)\$/g, '$1') .replace(/📗|🧩|🧮|📘|📏|📊|🔄|🧹|➕|📄|🧾|📋|🔌|📚|💾|📂|🖨️/g, '') .replace(//g, '
') .replace(/
/g, '') .replace(//g, '');const htmlContent = `Student Math Notes

Student Math Notes

${content}
`;const blob = new Blob([htmlContent], { type: 'application/msword' }); const link = document.createElement('a'); const url = URL.createObjectURL(blob); link.href = url; link.download = 'Student_Math_Note.doc'; document.body.appendChild(link); link.click(); setTimeout(() => { document.body.removeChild(link); URL.revokeObjectURL(url); }, 100); }// Copy function function copyConvertedText() { const tempDiv = document.createElement('div'); tempDiv.innerHTML = tinyMCEEditor.getContent(); const plainText = tempDiv.textContent || tempDiv.innerText || ''; navigator.clipboard.writeText(plainText) .then(() => alert("📝 Text copied to clipboard!")) .catch((err) => { console.error('Copy failed:', err); const textArea = document.createElement('textarea'); textArea.value = plainText; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); alert("📝 Text copied to clipboard!"); }); }// Close modals when clicking outside window.onclick = function(event) { const booleanModal = document.getElementById('booleanModal'); const templatesModal = document.getElementById('templatesModal'); if (event.target == booleanModal) booleanModal.style.display = 'none'; if (event.target == templatesModal) templatesModal.style.display = 'none'; }