web demo: load examples as blobs
Browse files215 unmodified lines216217218219220221222215 unmodified linesfor (const e of index.examples) {const f = document.createElement("figure");f.innerHTML = `<img src="${e.file}" alt="${e.category} ${e.label}" loading="lazy"><figcaption>${e.category} 路 ${e.label}</figcaption>`;f.onclick = () => { window.scrollTo({ top: 0, behavior: "smooth" }); setImage(e.file, e.category); };$("examples").appendChild(f);}const drop = $("drop"), file = $("file");215 unmodified lines216217218219220221222223224225226215 unmodified linesfor (const e of index.examples) {const f = document.createElement("figure");f.innerHTML = `<img src="${e.file}" alt="${e.category} ${e.label}" loading="lazy"><figcaption>${e.category} 路 ${e.label}</figcaption>`;f.onclick = async () => { // fetch -> blob URL: LFS files are served from a CDN origin (would taint the canvas)window.scrollTo({ top: 0, behavior: "smooth" });const blob = await (await fetch(e.file)).blob();setImage(URL.createObjectURL(blob), e.category);};$("examples").appendChild(f);}const drop = $("drop"), file = $("file");
web/app.js+5-1