Author Interview Simulator

Author Interview Simulator

Practice Your Responses

Click "Get New Question" to begin...

Practice Session Review

Review your saved answers. You can edit or remove them before exporting.

Data Configuration

Customize the tool to fit your specific needs. All changes are saved in your browser.

Book Information

Question Bank

Add, edit, or delete questions from the simulator.

You have no saved answers in this session.

'; return; } aisState.practiceSession.forEach((item, index) => { const itemEl = document.createElement('div'); itemEl.className = 'ais-session-item'; itemEl.innerHTML = `

Q: ${item.question}

${item.answer.replace(/\n/g, '
')}

`; sessionList.appendChild(itemEl); }); } // Need to attach edit/remove functions to window scope for onclick window.editAisQnA = function(id) { const itemIndex = aisState.practiceSession.findIndex(item => item.id === id); if (itemIndex === -1) return; const item = aisState.practiceSession[itemIndex]; // Pre-fill Tab 1 questionDisplay.textContent = item.question; aisState.currentQuestion = item.question; answerTextarea.value = item.answer; // Remove from session aisState.practiceSession.splice(itemIndex, 1); saveState(); renderAisSession(); // Move to Tab 1 showAisTab(1); answerTextarea.focus(); } window.removeAisQnA = function(id) { if (confirm('Are you sure you want to remove this answer?')) { const itemIndex = aisState.practiceSession.findIndex(item => item.id === id); if (itemIndex > -1) { aisState.practiceSession.splice(itemIndex, 1); saveState(); renderAisSession(); } } } // --- PDF DOWNLOAD FUNCTION (Spec II.C) --- function downloadAisPdf() { if (typeof jspdf === 'undefined' || typeof jspdf.plugin.autotable === 'undefined') { alert('Error: PDF library is not loaded. Cannot download PDF.'); return; } if (aisState.practiceSession.length === 0) { alert('There are no saved answers to download.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); // 1. Title doc.setFontSize(18); doc.setTextColor('#2c3e50'); doc.text("Author Interview Practice Session", 105, 22, { align: 'center' }); // 2. Subtitle (Book Title) doc.setFontSize(14); doc.setTextColor('#555'); doc.text(`Book: ${aisState.bookTitle}`, 105, 30, { align: 'center' }); // 3. Prepare Table Data const tableData = aisState.practiceSession.map((item, index) => { return [`Q: ${item.question}`, `A: ${item.answer}`]; }); // 4. Generate Table (Spec C.2.o) doc.autoTable({ startY: 40, head: [['Practice Questions & Answers']], body: tableData, theme: 'grid', headStyles: { fillColor: '#0073e6', // Consistent color scheme (Spec C.3) textColor: '#ffffff', fontSize: 12, halign: 'center' }, columnStyles: { 0: { cellWidth: 'auto' }, // Let autotable handle it }, didParseCell: function (data) { // Split Q&A formatting if (data.section === 'body') { if (data.cell.text[0].startsWith('Q:')) { data.cell.styles.fontStyle = 'bold'; data.cell.styles.fillColor = '#f8f9fa'; } if (data.cell.text[0].startsWith('A:')) { data.cell.styles.fontStyle = 'normal'; } } } }); // 5. Save PDF doc.save(`Author_Interview_Practice_${aisState.bookTitle.replace(/\s+/g, '_')}.pdf`); } // --- TAB 3: CONFIGURATION FUNCTIONS (Spec #4, #6) --- function saveBookTitle() { aisState.bookTitle = bookTitleInput.value || "My Book"; saveState(); alert('Book title updated.'); } function renderQuestionBank() { questionBankEditor.innerHTML = ''; for (const [category, questions] of Object.entries(aisState.questions)) { const categoryEl = document.createElement('div'); categoryEl.className = 'ais-config-category'; // Get a user-friendly category name let categoryName = "Unknown"; const option = categorySelect.querySelector(`option[value="${category}"]`); if (option) { categoryName = option.textContent; } let questionItems = ''; questions.forEach((q, index) => { questionItems += `

${q}

`; }); categoryEl.innerHTML = `

${categoryName}

${questionItems}
`; questionBankEditor.appendChild(categoryEl); } } window.addAisQuestion = function(category) { const input = document.getElementById(`ais-add-q-${category}`); const question = input.value.trim(); if (question) { aisState.questions[category].push(question); saveState(); renderQuestionBank(); // Re-render this tab } else { alert('Please enter a question.'); } } window.deleteAisQuestion = function(category, index) { if (confirm('Are you sure you want to delete this question?')) { aisState.questions[category].splice(index, 1); saveState(); renderQuestionBank(); // Re-render } } // --- INITIALIZATION (Spec IV.A) --- loadState(); // Load saved data // Populate inputs with loaded state bookTitleInput.value = aisState.bookTitle; questionDisplay.textContent = aisState.currentQuestion; // Render dynamic content renderAisSession(); renderQuestionBank(); // Attach Event Listeners getQuestionBtn.addEventListener('click', getNewAisQuestion); saveAnswerBtn.addEventListener('click', saveAisQnA); saveBookTitleBtn.addEventListener('click', saveBookTitle); downloadPdfBtn.addEventListener('click', downloadAisPdf); // Show initial tab showAisTab(1); });