Scientific Hypothesis Generator

Scientific Hypothesis Generator

Scientific Hypothesis Generator

Generate a clearly structured, testable hypothesis using the If-Then-Because format.

Your generated hypothesis is shown below. It outlines the predicted relationship between your independent and dependent variables, supported by a scientific rationale.

Structured Hypothesis

Date Generated: ${date}

Hypothesis Structure:

${hypothesisHTML}

Breakdown:

  • IF (Independent Variable): ${shg_escapeHTML(shg_data.ifClause) || 'N/A'}
  • THEN (Dependent Variable): ${shg_escapeHTML(shg_data.thenClause) || 'N/A'}
  • BECAUSE (Rationale): ${shg_escapeHTML(shg_data.becauseClause) || 'N/A'}
`; } /** * Generates and downloads a PDF of the hypothesis */ async function shg_downloadPDF() { if (!shg_data.ifClause || !shg_data.thenClause) { alert("Please complete the IF and THEN clauses before downloading."); return; } if (typeof jspdf === 'undefined' || typeof html2canvas === 'undefined') { alert("Error: PDF libraries failed to load."); return; } shg_renderPdfClone(); const { jsPDF } = window.jspdf; try { const contentDiv = shg_pdfRenderClone.querySelector('.pdf-content'); if (!contentDiv) return; const canvas = await html2canvas(shg_pdfRenderClone, { scale: 1.5, useCORS: true }); const imgData = canvas.toDataURL('image/png'); const imgProps = { width: canvas.width, height: canvas.height }; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 40; const contentWidth = pdfWidth - (margin * 2); const contentHeight = (contentWidth * imgProps.height) / imgProps.width; let heightLeft = contentHeight; let position = 0; pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); while (heightLeft > 0) { position -= (pdfHeight - margin * 2); pdf.addPage(); pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); } pdf.save('Scientific_Hypothesis.pdf'); } catch (error) { console.error("PDF generation failed:", error); alert("An error occurred while generating the PDF."); } } // --- EVENT LISTENERS --- // Tab link clicks shg_tabLinks.forEach((link, index) => { link.addEventListener('click', () => shg_switchTab(index)); }); // Next/Prev button clicks if (shg_prevButton) { shg_prevButton.addEventListener('click', () => { if (shg_currentTab > 0) shg_switchTab(shg_currentTab - 1); }); } if (shg_nextButton) { shg_nextButton.addEventListener('click', () => { if (shg_currentTab === shg_tabLinks.length - 1) { shg_updateDataFromConfig(); shg_switchTab(0); } else { if (shg_currentTab < shg_tabLinks.length - 1) shg_switchTab(shg_currentTab + 1); } }); } // PDF download if (shg_downloadPdfButton) { shg_downloadPdfButton.addEventListener('click', shg_downloadPDF); } // --- Initialization --- shg_renderConfig(); shg_renderDashboard(); // Set initial tab state shg_tabPanes.forEach((pane, index) => { pane.classList.toggle('hidden', index !== 0); pane.classList.toggle('shg-active', index === 0); }); shg_tabLinks.forEach((link, index) => { TAB_CLASSES.active.forEach(cls => link.classList.remove(cls)); TAB_CLASSES.inactive.forEach(cls => link.classList.remove(cls)); if (index === 0) { TAB_CLASSES.active.forEach(cls => link.classList.add(cls)); } else { TAB_CLASSES.inactive.forEach(cls => link.classList.add(cls)); } }); });
Scroll to Top