Random Sci-Fi Technology Generator
Generate concepts for fictional technology based on field, scale, and impact.
Your Sci-Fi technology concept will appear here!
Error: ${techConcept.name}
${techConcept.description}
`; downloadBtn.style.display = 'none'; // Ensure button stays hidden on error } else { resultsDiv.innerHTML = `Technology Name: ${techConcept.name}
Description: ${techConcept.description}
`; downloadPdfBtn.style.display = 'block'; // Show download button only on success } }); document.getElementById('clearBtn').addEventListener('click', () => { document.getElementById('techField').value = 'any'; document.getElementById('techScale').value = 'any'; document.getElementById('techImpact').value = 'any'; document.getElementById('techKeyword').value = ''; document.getElementById('techResults').innerHTML = 'Your Sci-Fi technology concept will appear here!
'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide download button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('techResults'); // Check if results are error message before attempting to get tech text if (resultsDiv.textContent.includes("Error:") || resultsDiv.textContent.includes("Your Sci-Fi technology concept will appear here!")) { alert("No technology concept to download."); return; } const nameText = resultsDiv.querySelector('p:nth-child(1)') ? resultsDiv.querySelector('p:nth-child(1)').textContent.replace('Technology Name: ', '').trim() : ''; const descriptionText = resultsDiv.querySelector('p:nth-child(2)') ? resultsDiv.querySelector('p:nth-child(2)').textContent.replace('Description: ', '').trim() : ''; if (!nameText) { // Should not happen if error check passed, but for safety alert("No technology concept to download."); return; } // --- PDF Generation --- const doc = new jsPDF(); const margin = 15; let y = margin; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const maxLineWidth = pageWidth - 2 * margin; // Max width for text line doc.setFontSize(18); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 doc.text("Sci-Fi Technology Concept", margin, y); y += 15; // Space after title doc.setFontSize(12); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Add Technology Name doc.setFontSize(14); doc.text("Technology Name:", margin, y); y += 8; doc.setFontSize(12); doc.text(nameText, margin, y); y += 10; // Add Description doc.setFontSize(14); doc.text("Description:", margin, y); y += 8; doc.setFontSize(12); const descriptionLines = doc.splitTextToSize(descriptionText, maxLineWidth); // Check if description fits and add pages if necessary descriptionLines.forEach(line => { if (y + 7 > pageHeight - margin) { // Estimate line height + padding doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("Sci-Fi Technology Concept (cont.)", margin, y); y += 15; doc.setFontSize(14); doc.text("Description (cont.):", margin, y); y += 8; doc.setFontSize(12); } doc.text(line, margin, y); y += 7; // Estimate line height }); doc.save('scifi_technology.pdf'); });Key Features:
Customizable Technology Generation: Users can generate sci-fi technology ideas based on their chosen theme.
Light and Clean Design: The tool features a bright and modern color scheme.
PDF Download: Users can download the technology idea as a PDF with a matching light color scheme.
Responsive and Centered Layout: The tool is fully responsive and centered on the page.
No Interference with Header/Footer: The tool works independently without affecting the WordPress theme’s header or footer.
