File size: 2,873 Bytes
247fca7
e13ca72
247fca7
 
 
 
 
 
e13ca72
247fca7
e13ca72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247fca7
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

document.addEventListener('DOMContentLoaded', function() {
    // PDF Uploader functionality
    // Initialize charts if on dashboard page
    if (window.location.pathname.includes('dashboard.html')) {
        initDashboardCharts();
    }

    const fileUpload = document.getElementById('file-upload');
const uploadedFilesContainer = document.getElementById('uploaded-files');
    const shareBtn = document.getElementById('share-btn');
    
    fileUpload.addEventListener('change', function(e) {
        const files = Array.from(e.target.files);
        
        if (files.length > 0) {
            uploadedFilesContainer.classList.remove('hidden');
            shareBtn.classList.remove('hidden');
            uploadedFilesContainer.innerHTML = '<h3 class="text-lg font-medium text-gray-700 mb-2">Your Uploads</h3>';
            
            files.forEach((file, index) => {
                if (file.type === 'application/pdf') {
                    const fileCard = document.createElement('div');
                    fileCard.className = 'file-card bg-gray-50 rounded-lg p-4 flex items-center justify-between';
                    
                    fileCard.innerHTML = `
                        <div class="flex items-center">
                            <i data-feather="file-text" class="w-6 h-6 text-red-500 mr-3"></i>
                            <div>
                                <p class="font-medium text-gray-800 truncate max-w-xs">${file.name}</p>
                                <p class="text-sm text-gray-500">${(file.size / (1024 * 1024)).toFixed(2)} MB</p>
                            </div>
                        </div>
                        <div class="flex items-center space-x-2">
                            <button class="text-blue-500 hover:text-blue-700">
                                <i data-feather="eye" class="w-4 h-4"></i>
                            </button>
                            <button class="text-red-500 hover:text-red-700">
                                <i data-feather="trash-2" class="w-4 h-4"></i>
                            </button>
                        </div>
                    `;
                    
                    uploadedFilesContainer.appendChild(fileCard);
                }
            });
            
            feather.replace();
        }
    });
    shareBtn.addEventListener('click', function() {
        alert('Sharing functionality would be implemented here!');
    });

    function initDashboardCharts() {
        // Additional chart initialization can be done here if needed
    }
});

// Export functionality for dashboard
function exportTo(format) {
    console.log(`Exporting to ${format}...`);
    // In a real implementation, this would call the backend API
    alert(`Exporting data to ${format} format. This would be implemented via backend in a real application.`);
}