async function loadLinks() { const container = document.getElementById('links-container'); if (!container) return; try { const response = await fetch('./assets/data/links.json'); if (!response.ok) { throw new Error(`Failed to load links: ${response.status}`); } const groups = await response.json(); // Helper function to fetch SVG content const fetchSvg = async (path) => { if (!path) return ''; try { const res = await fetch(path); if (!res.ok) return ''; return await res.text(); } catch (e) { console.error(`Failed to load SVG: ${path}`, e); return ''; } }; // Process groups and fetch SVGs in parallel const groupsWithSvgs = await Promise.all(groups.map(async (group) => { const groupIconSvg = await fetchSvg(group.iconPath); const linksWithSvgs = await Promise.all(group.links.map(async (link) => { const linkIconSvg = link.iconPath ? await fetchSvg(link.iconPath) : ''; return { ...link, iconSvg: linkIconSvg }; })); return { ...group, iconSvg: groupIconSvg, links: linksWithSvgs }; })); container.innerHTML = groupsWithSvgs.map(group => `
${group.iconSvg}

${group.title}

${group.links.map(link => { const isPrototype = link.url.startsWith('/prototypes/'); const hrefAttr = isPrototype ? 'href="#"' : `href="${link.url}" target="_blank"`; const onclickAttr = isPrototype ? `onclick="event.preventDefault(); showView('iframe', this, '${link.url}', '${link.title}')"` : ''; return `
${link.iconClass ? `
` : link.iconSvg} ${link.subtitle ? `
${link.title}
${link.subtitle}
` : ` ${link.title} `}
${link.badge ? ` ${link.badge} ` : ''} ${link.arrowIcon ? ` ` : ''}
`}).join('')}
`).join(''); } catch (error) { console.error('Error loading links:', error); container.innerHTML = `
Failed to load application links. Please try refreshing the page.
`; } } // Load links when the DOM is loaded document.addEventListener('DOMContentLoaded', loadLinks);