File size: 4,075 Bytes
c6600ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Main application script
document.addEventListener('DOMContentLoaded', function() {
    // Initialize tooltips
    const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl);
    });

    // Toggle sidebar on mobile
    const sidebarToggle = document.getElementById('sidebarToggle');
    if (sidebarToggle) {
        sidebarToggle.addEventListener('click', function() {
            document.querySelector('.sidebar').classList.toggle('-translate-x-full');
        });
    }

    // Dark mode toggle (placeholder - would need implementation)
    const darkModeToggle = document.getElementById('darkModeToggle');
    if (darkModeToggle) {
        darkModeToggle.addEventListener('click', function() {
            document.documentElement.classList.toggle('dark');
        });
    }

    // Simulate loading data
    function simulateLoading() {
        const loadingElements = document.querySelectorAll('.loading-placeholder');
        loadingElements.forEach(el => {
            el.innerHTML = '<div class="animate-pulse flex space-x-4"><div class="flex-1 space-y-4 py-1"><div class="h-4 bg-gray-200 rounded w-3/4"></div><div class="space-y-2"><div class="h-4 bg-gray-200 rounded"></div><div class="h-4 bg-gray-200 rounded w-5/6"></div></div></div></div>';
        });

        setTimeout(() => {
            loadingElements.forEach(el => {
                el.innerHTML = '<p>Data loaded successfully!</p>';
            });
        }, 1500);
    }

    // Initialize any buttons that might need loading simulation
    const loadDataButtons = document.querySelectorAll('.load-data');
    loadDataButtons.forEach(button => {
        button.addEventListener('click', simulateLoading);
    });

    // Company search functionality
    const companySearch = document.getElementById('companySearch');
    if (companySearch) {
        companySearch.addEventListener('input', function(e) {
            const searchTerm = e.target.value.toLowerCase();
            // This would be replaced with actual search functionality
            console.log('Searching for:', searchTerm);
        });
    }
});

// API function to fetch MAD landscape data
async function fetchMADLandscapeData() {
    try {
        // In a real implementation, this would fetch from the MAD API
        // For demo purposes, we'll use a mock response
        const mockResponse = {
            categories: [
                {
                    name: "Generative AI",
                    companies: ["OpenAI", "Anthropic", "Stability AI", "Midjourney"]
                },
                {
                    name: "Computer Vision",
                    companies: ["Scale AI", "Hive", "Clarifai", "Labelbox"]
                }
            ]
        };
        
        return mockResponse;
    } catch (error) {
        console.error("Error fetching MAD landscape data:", error);
        return null;
    }
}

// Function to render company cards
function renderCompanyCards(companies, containerId) {
    const container = document.getElementById(containerId);
    if (!container) return;

    container.innerHTML = companies.map(company => `
        <div class="bg-white rounded-lg shadow p-4 hover:shadow-md transition-shadow">
            <div class="flex items-center space-x-4">
                <div class="flex-shrink-0">
                    <img class="h-10 w-10 rounded-full" src="http://static.photos/technology/200x200/${Math.floor(Math.random() * 100)}" alt="${company} logo">
                </div>
                <div class="flex-1 min-w-0">
                    <p class="text-sm font-medium text-gray-900 truncate">${company}</p>
                    <p class="text-sm text-gray-500 truncate">${company} description</p>
                </div>
                <div>
                    <i data-feather="chevron-right" class="text-gray-400"></i>
                </div>
            </div>
        </div>
    `).join('');

    feather.replace();
}