/** * Recent plots sidebar management */ export class RecentPlotsManager { constructor(maxRecentPlots = 20) { this.MAX_RECENT_PLOTS = maxRecentPlots; this.init(); } init() { this.updateRecentPlotsDisplay(); this.trackPlotClicks(); } /** * Add plot to recent plots list */ addToRecentPlots(plotHref) { const plotName = plotHref.split('/').pop().replace('.pdf', ''); const pathParts = plotHref.split('/').filter(p => p !== '' && p !== plotName + '.pdf'); const plotPath = pathParts.join(' / '); const thumbUrl = plotHref.replace('.pdf', '.png'); // Determine the gallery page URL (directory containing the plot) const plotDir = plotHref.substring(0, plotHref.lastIndexOf('/')); const galleryUrl = plotDir + '/index.html'; const plotInfo = { name: plotName, path: plotPath, href: plotHref, thumbUrl: thumbUrl, galleryUrl: galleryUrl, timestamp: Date.now() }; let recentPlots = JSON.parse(localStorage.getItem('recentPlots') || '[]'); recentPlots = recentPlots.filter(p => p.href !== plotHref); recentPlots.unshift(plotInfo); recentPlots = recentPlots.slice(0, this.MAX_RECENT_PLOTS); localStorage.setItem('recentPlots', JSON.stringify(recentPlots)); this.updateRecentPlotsDisplay(); } /** * Update recent plots sidebar display */ updateRecentPlotsDisplay() { const sidebarContent = document.getElementById('sidebarContent'); if (!sidebarContent) return; const recentPlots = JSON.parse(localStorage.getItem('recentPlots') || '[]'); if (recentPlots.length === 0) { sidebarContent.innerHTML = `