Office Hour Optimizer
Recurring Weekly Office Hours
One-Time Office Hours
General Settings
Week of ...
Click on a time slot to pre-assign an attendee or topic for the selected week.
Select Office Hour Block for Live Management
Not currently managing a session.
Attendee Queue (Drop-ins)
Current Interaction
No active interaction. Call next from queue or a pre-scheduled slot.
Completed Interactions in this Block
Queue is empty.
"; } else { listDiv.innerHTML = "- " + oho_currentLiveSession.queue.map((q,i) => `
- ${i+1}. ${q.name} - ${q.topic || 'General Question'} `).join('') + "
Topic: ${nextAttendee.topic || 'N/A'}`; timerDisp.textContent = "00:00:00"; oho_currentLiveSession.activeInteraction.timerInterval = setInterval(() => { if (oho_currentLiveSession.activeInteraction) { const elapsed = Date.now() - oho_currentLiveSession.activeInteraction.startTimeObj.getTime(); timerDisp.textContent = oho_formatElapsedTime(elapsed); } }, 1000); document.getElementById('oho-end-interaction-btn').disabled = false; document.getElementById('oho-call-next-btn').disabled = true; oho_renderQueue(); } function oho_endCurrentInteraction() { if (!oho_currentLiveSession.activeInteraction) return; clearInterval(oho_currentLiveSession.activeInteraction.timerInterval); const endTime = new Date(); const durationMin = Math.round((endTime.getTime() - oho_currentLiveSession.activeInteraction.startTimeObj.getTime()) / (60*1000)); const notes = document.getElementById('oho-interaction-notes').value.trim(); oho_currentLiveSession.completedInteractions.push({ name: oho_currentLiveSession.activeInteraction.name, topic: oho_currentLiveSession.activeInteraction.topic, startTime: oho_currentLiveSession.activeInteraction.startTimeObj, endTime: endTime, durationMin: durationMin, notes: notes }); oho_currentLiveSession.activeInteraction = null; document.getElementById('oho-current-interaction-display').textContent = "No active interaction. Call next or use queue."; document.getElementById('oho-current-interaction-timer').textContent = ""; document.getElementById('oho-interaction-notes').value = ''; document.getElementById('oho-end-interaction-btn').disabled = true; document.getElementById('oho-call-next-btn').disabled = oho_currentLiveSession.queue.length === 0; oho_renderCompletedInteractions(); } function oho_renderCompletedInteractions() { const listDiv = document.getElementById('oho-completed-interactions-list'); if (!listDiv) return; if (oho_currentLiveSession.completedInteractions.length === 0) { listDiv.innerHTML = "
No interactions logged yet for this block.
${c.name} (${c.topic || 'N/A'}) - ${oho_formatDuration(c.durationMin)}
${c.startTime.toLocaleTimeString()} - ${c.endTime.toLocaleTimeString()}
${c.notes ? `Notes: ${c.notes}
` : ''}` ).join(''); } } // --- PDF Exports & Clear All --- function oho_downloadWeeklyPlanPDF() { if (!tpc_jsPDF_loaded_OHO || !tpc_autoTable_loaded_OHO) { alert("OHO Error: PDF libraries not loaded."); return; } oho_renderWeeklyPlanningGrid(); const doc = new TPC_jsPDF_OHO(); const primaryColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim(); const darkColor = getComputedStyle(document.documentElement).getPropertyValue('--dark-color').trim(); let finalY = 15; doc.setFontSize(18); doc.setTextColor(primaryColor); doc.text(`Weekly Office Hour Plan: ${document.getElementById('oho-planning-week-display').textContent}`, doc.internal.pageSize.getWidth() / 2, finalY, { align: 'center' }); finalY += 10; doc.setFontSize(10); doc.setTextColor(darkColor); doc.text(`Default Slot Duration: ${oho_settings.defaultSlotDuration} minutes`, 14, finalY); finalY+=10; const dayColumns = document.querySelectorAll('#oho-weekly-schedule-grid .oho-day-column'); if (dayColumns.length === 0) { doc.text("No schedule to display.", 14, finalY); doc.save("Weekly_Office_Hour_Plan.pdf"); return;} let allDaysData = []; dayColumns.forEach(col => { const headerText = col.querySelector('.oho-day-header').innerText.replace(/\n/g, ' '); let tasksText = []; col.querySelectorAll('.oho-slot').forEach(slotEl => { const slotDataId = slotEl.dataset.slotDataId; const scheduledInfo = oho_weeklyScheduledSlotsData[slotDataId]; let taskLine = slotEl.querySelector('.time').textContent.trim(); if (scheduledInfo && (scheduledInfo.attendeeName || scheduledInfo.topic)) { taskLine += ` - ${scheduledInfo.attendeeName || 'Scheduled'}${scheduledInfo.topic ? ': ' + scheduledInfo.topic : ''}`; } // Do not add "Empty Slot" to PDF for brevity if (scheduledInfo && (scheduledInfo.attendeeName || scheduledInfo.topic)) tasksText.push(taskLine); }); if (tasksText.length > 0) { // Only add day if it has scheduled content allDaysData.push([headerText, tasksText.join('\n') || "No specific assignments"]); } }); if(allDaysData.length > 0){ doc.autoTable({ startY: finalY, head: [['Day & Date', 'Scheduled Slots / Assignments']], body: allDaysData, theme: 'grid', headStyles: { fillColor: primaryColor, textColor: '#ffffff', fontSize: 10 }, styles: { fontSize: 9, cellPadding: 2, overflow: 'linebreak' }, columnStyles: { 0: { cellWidth: 40 }, 1: { cellWidth: 'auto' } } }); } else { doc.text("No pre-assignments made for this week.", 14, finalY); } doc.save(`Weekly_Office_Hour_Plan_${oho_planningWeekStartDate.toISOString().slice(0,10)}.pdf`); } function oho_downloadSessionLogPDF() { if (!tpc_jsPDF_loaded_OHO || !tpc_autoTable_loaded_OHO) { alert("OHO Error: PDF libraries not loaded."); return; } if (!oho_currentLiveSession.blockDetails || oho_currentLiveSession.completedInteractions.length === 0) { alert("No completed interactions in the current live session block to export."); return; } const doc = new TPC_jsPDF_OHO(); const primaryColor = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim(); const darkColor = getComputedStyle(document.documentElement).getPropertyValue('--dark-color').trim(); let finalY = 15; const block = oho_currentLiveSession.blockDetails; const displayDate = new Date(block.date+"T00:00:00").toLocaleDateString(undefined, {timeZone:'UTC'}); doc.setFontSize(18); doc.setTextColor(primaryColor); doc.text("Office Hour Session Log", doc.internal.pageSize.getWidth() / 2, finalY, { align: 'center' }); finalY += 8; doc.setFontSize(10); doc.setTextColor(darkColor); doc.text(`Date: ${displayDate} | Block: ${block.startTime}-${block.endTime} (${block.location || 'N/A'})`, doc.internal.pageSize.getWidth() / 2, finalY, { align: 'center'}); finalY += 12; doc.setFontSize(12); doc.setTextColor(primaryColor); doc.text("Completed Interactions:", 14, finalY); finalY += 7; const tableBody = oho_currentLiveSession.completedInteractions.map(c => [ `${c.startTime.toLocaleTimeString()} - ${c.endTime.toLocaleTimeString()}`, c.name, c.topic || '-', oho_formatDuration(c.durationMin), c.notes || '-' ]); doc.autoTable({ startY: finalY, head: [['Time Slot', 'Attendee', 'Topic', 'Duration', 'Notes']], body: tableBody, theme: 'grid', headStyles: { fillColor: primaryColor, textColor: '#ffffff', fontSize: 9 }, styles: { fontSize: 8, cellPadding: 1.5, overflow: 'linebreak' } }); doc.save(`Office_Hour_Log_${block.date}_${block.startTime.replace(':','')}.pdf`); } function oho_clearAllData() { if(confirm("Are you sure you want to clear all configured slots and weekly plans? This cannot be undone.")){ oho_recurringSlots = []; oho_oneTimeSlots = []; oho_recCounter=0; oho_oneOffCounter=0; document.getElementById('oho-recurring-slots-list').innerHTML = ''; document.getElementById('oho-onetime-slots-list').innerHTML = ''; oho_addRecurringSlotRow(); oho_weeklyScheduledSlotsData = {}; oho_renderWeeklyPlanningGrid(); document.getElementById('oho-live-block-date').valueAsDate = new Date(2025,4,14); oho_populateLiveBlockSelect(); document.getElementById('oho-live-session-manager').style.display = 'none'; oho_currentLiveSession = { blockDetails: null, queue: [], activeInteraction: null, completedInteractions: [] }; oho_renderQueue(); oho_renderCompletedInteractions(); alert("All office hour data cleared."); } }