Spaces:
Sleeping
Sleeping
Lê Đăng Khoa (Liam) commited on
Update index.html
Browse files59 unmodified lines60616263646566671268 unmodified lines13361337133813391340134161 unmodified lines14031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144727 unmodified lines1475147614771478147914801481303 unmodified lines178517861787178817891790179159 unmodified lines<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet"><!-- AOS (Animate On Scroll) --><link href="https://unpkg.com/aos@2.3.4/dist/aos.css" rel="stylesheet" /><script defer src="https://unpkg.com/aos@2.3.4/dist/aos.js"></script><!-- Lucide Icons -->1268 unmodified linesconst $ = (sel, root = document) => root.querySelector(sel);const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));function showToast(msg) {const t = $('#toast');if (!t) return;61 unmodified lines}// ---------- Mermaid ----------async function renderMermaid() {if (!window.mermaid) return;const isDark = document.documentElement.classList.contains('dark');mermaid.initialize({startOnLoad: false,theme: isDark ? 'dark' : 'default',securityLevel: 'loose',fontFamily: 'Inter, ui-sans-serif, system-ui',flowchart: { useMaxWidth: true, htmlLabels: true }});const blocks = document.querySelectorAll('.mermaid');let idx = 0;for (const el of blocks) {// 1) Cache original source once (before SVG replacement)if (!el.dataset.mermaidSrc) {const src = (el.textContent || '').trim();// If the element already contains svg (e.g., from previous render), don't overwrite cacheif (src.startsWith('<svg')) continue;el.dataset.mermaidSrc = src;}const code = (el.dataset.mermaidSrc || '').trim();if (!code) continue;// 2) Render from cached sourceconst id = `mmd-${idx++}-${Date.now()}`;try {const { svg, bindFunctions } = await mermaid.render(id, code);el.innerHTML = svg;if (typeof bindFunctions === 'function') bindFunctions(el);} catch (err) {console.error('Mermaid render error:', err, code);const safe = String(err).replace(/</g, '<').replace(/>/g, '>');el.innerHTML = `<div class="text-red-300 text-sm">Mermaid render failed: ${safe}</div>`;}}}27 unmodified linesif (panel) panel.classList.remove('hidden');// re-render mermaid if panel contains diagramsrequestAnimationFrame(() => renderMermaid());});});}303 unmodified lines// Render math + mermaid after libs loadsetTimeout(() => {renderMath();renderMermaid();}, 0);initGSAP();59 unmodified lines6061626364656667686970717273741268 unmodified lines134313441345134613471348134913501351135213531354135513561357135813591360136161 unmodified lines14231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146727 unmodified lines1495149614971498149915001501303 unmodified lines180518061807180818091810181159 unmodified lines<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet"><!-- Load mermaid first, prevent default DOM --><script>window.mermaid = { startOnLoad: false };</script><script defer src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script><!-- AOS (Animate On Scroll) --><link href="https://unpkg.com/aos@2.3.4/dist/aos.css" rel="stylesheet" /><script defer src="https://unpkg.com/aos@2.3.4/dist/aos.js"></script><!-- Lucide Icons -->1268 unmodified linesconst $ = (sel, root = document) => root.querySelector(sel);const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));const MERMAID_SRC = new WeakMap();function cacheMermaidSources() {document.querySelectorAll('.mermaid').forEach(el => {if (!MERMAID_SRC.has(el)) {MERMAID_SRC.set(el, (el.textContent || '').trim());}});}// Cache mermaid src (before any render)cacheMermaidSources();function showToast(msg) {const t = $('#toast');if (!t) return;61 unmodified lines}// ---------- Mermaid ----------let _mermaidRendering = false;async function renderMermaid() {if (!window.mermaid) return;if (_mermaidRendering) return;_mermaidRendering = true;try {const isDark = document.documentElement.classList.contains('dark');mermaid.initialize({startOnLoad: false,theme: isDark ? 'dark' : 'default',securityLevel: 'loose',fontFamily: 'Inter, ui-sans-serif, system-ui',flowchart: { useMaxWidth: true, htmlLabels: true }});const blocks = document.querySelectorAll('.mermaid');let idx = 0;for (const el of blocks) {const code = (MERMAID_SRC.get(el) || '').trim();if (!code) continue;const id = `mmd-${idx++}-${Date.now()}`;try {const { svg, bindFunctions } = await mermaid.render(id, code);el.innerHTML = svg;if (typeof bindFunctions === 'function') bindFunctions(el);} catch (err) {console.error('Mermaid render error:', err, code);const safe = String(err).replace(/</g, '<').replace(/>/g, '>');el.innerHTML = `<div class="text-red-300 text-sm">Mermaid render failed: ${safe}</div>`;}}} finally {_mermaidRendering = false;}}27 unmodified linesif (panel) panel.classList.remove('hidden');// re-render mermaid if panel contains diagramsrequestAnimationFrame(() => await renderMermaid());});});}303 unmodified lines// Render math + mermaid after libs loadsetTimeout(() => {renderMath();await renderMermaid();}, 0);initGSAP();
index.html+52-32