// File processing logic document.addEventListener('DOMContentLoaded', () => { console.log('BlogVista initialized'); // Handle file uploads and generation const handleFileUpload = async (files) => { if (!files || files.length === 0) return; // Convert FileList to array const filesArray = Array.from(files); // Process each file for (const file of filesArray) { try { const content = await extractFileContent(file); const html = generateBlogHTML(file.name.replace(/\.[^/.]+$/, ""), content); downloadHTMLFile(file.name.replace(/\.[^/.]+$/, ".html"), html); // Initialize Feather Icons when DOM is loaded document.addEventListener('DOMContentLoaded', () => { feather.replace(); // Handle file uploads and generation const handleFileUpload = async (files) => { if (!files || files.length === 0) return; // Convert FileList to array const filesArray = Array.from(files); // Process each file for (const file of filesArray) { try { const content = await extractFileContent(file); const html = generateBlogHTML(file.name.replace(/\.[^/.]+$/, ""), content); downloadHTMLFile(file.name.replace(/\.[^/.]+$/, ".html"), html); } catch (error) { console.error(`Error processing ${file.name}:`, error); showErrorNotification(`Failed to process ${file.name}`); } } }; // Listen for custom event from file-upload component document.addEventListener('files-uploaded', (e) => { if (e.detail && e.detail.files) { handleFileUpload(e.detail.files); } }); }); catch (error) { console.error(`Error processing ${file.name}:`, error); showErrorNotification(`Failed to process ${file.name}`); } } }; // Listen for custom event from file-upload component document.addEventListener('files-uploaded', (e) => { if (e.detail && e.detail.files) { handleFileUpload(e.detail.files); } }); }); function showErrorNotification(message) { const notification = document.createElement('div'); notification.style.position = 'fixed'; notification.style.bottom = '20px'; notification.style.right = '20px'; notification.style.backgroundColor = '#ef4444'; notification.style.color = 'white'; notification.style.padding = '12px 24px'; notification.style.borderRadius = '8px'; notification.style.boxShadow = '0 4px 6px rgba(0,0,0,0.1)'; notification.style.zIndex = '1000'; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => { notification.style.transition = 'opacity 0.5s'; notification.style.opacity = '0'; setTimeout(() => notification.remove(), 500); }, 3000); } // Simulate file content extraction with improved mock content async function extractFileContent(file) { return new Promise((resolve) => { // Simulate processing delay setTimeout(() => { const isPPT = file.type.includes('powerpoint'); const mockContent = `
Auto-generated from ${isPPT ? 'PowerPoint' : 'Word'} document
This would contain your PowerPoint slides content.
This would contain the formatted text content from your document with proper headings, lists, and paragraphs.
This section would contain any speaker notes from your presentation.
This HTML was automatically generated from your original document while preserving the structure and key content elements.