From 6de0df365eee32b83a1c6e81e7798e7a36335284 Mon Sep 17 00:00:00 2001 From: Jaakko Vanhala Date: Thu, 9 Apr 2026 21:11:11 +0300 Subject: [PATCH] Korjattu projektikortin JSON-parsintavirhe: tiedostot globaaliin muuttujaan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Koodin sisältämät lainausmerkit ja erikoismerkit rikkoivat data-files HTML-attribuutin. Nyt tiedostot tallennetaan window._projectFiles[id]:hen ja onclick-handlerit viittaavat siihen suoraan. Ei JSON DOM:ssa. Co-Authored-By: Claude Opus 4.6 (1M context) --- network-poc/frontend/src/pages/index.astro | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/network-poc/frontend/src/pages/index.astro b/network-poc/frontend/src/pages/index.astro index 3e9ebfd..cc3fd47 100644 --- a/network-poc/frontend/src/pages/index.astro +++ b/network-poc/frontend/src/pages/index.astro @@ -491,18 +491,49 @@ import AgentBar from "../components/AgentBar.astro"; } // === Project card === + window._projectFiles = {}; // id → files + function renderProjectCard(files, name) { const entries = Object.entries(files); if (!entries.length) return; const id = 'proj-' + Date.now(); - const tabs = entries.map(([n],i) => `
${esc(n)}
`).join(''); - const panels = entries.map(([n,c],i) => `
${highlightCode(c)}
`).join(''); - const html = `
${esc(name||'Projekti')} (${entries.length})
${tabs}
${panels}
`; + window._projectFiles[id] = files; + + const tabs = entries.map(([n],i) => + `
${esc(n)}
` + ).join(''); + + const panels = entries.map(([n,c],i) => + `
` + + `
` + + `
` + + `
${highlightCode(c)}
` + ).join(''); + + const html = `
` + + `
` + + `${esc(name||'Projekti')} (${entries.length})` + + `` + + `` + + `` + + `
` + + `
${tabs}
${panels}
`; + const div = document.createElement('div'); div.innerHTML = html; termPanel.appendChild(div.firstElementChild); termPanel.scrollTop = termPanel.scrollHeight; } + window.copyProjectFile = function(id, name) { + const files = window._projectFiles[id]; + if (files && files[name]) navigator.clipboard.writeText(files[name]); + }; + window.copyAllProjectFiles = function(id) { + const files = window._projectFiles[id]; + if (!files) return; + const text = Object.entries(files).map(([n,c]) => '# --- ' + n + ' ---\n' + c).join('\n\n'); + navigator.clipboard.writeText(text); + }; window.switchProjTab = function(id,i) { document.querySelectorAll(`.project-tab[data-card="${id}"]`).forEach((t,j) => t.classList.toggle('active', j===i)); document.querySelectorAll(`.proj-panel[data-card="${id}"]`).forEach((p,j) => p.style.display = j===i ? '' : 'none');