From ed02e47158102fbf10c42c0f5dc7cfffa33a13b7 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 7 Apr 2026 06:00:17 +0300 Subject: [PATCH] ZIP-lataus korjattu: tiedostot globaaliin muuttujaan data-attribuutin sijaan JSON data-attribuutissa heittomerkit katkaisivat HTML:n. Nyt projectFiles[cardId] tallentaa tiedostot muistiin. Co-Authored-By: Claude Opus 4.6 (1M context) --- network-poc/static/index.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/network-poc/static/index.html b/network-poc/static/index.html index 2fa6b5d..6048efb 100644 --- a/network-poc/static/index.html +++ b/network-poc/static/index.html @@ -1905,11 +1905,15 @@ } // Projektikortti: tiedostovälilehdet + kopioi + lataa ZIP + // Globaali storage projektikorttien tiedostoille (välttää JSON data-attribuuttien ongelmat) + const projectFiles = {}; + function renderProjectCard(files, projectName) { const fileEntries = Object.entries(files); if (fileEntries.length === 0) return; const cardId = 'proj-' + Date.now(); + projectFiles[cardId] = files; const tabsHtml = fileEntries.map(([name], i) => `${esc(name)}` ).join(''); @@ -1926,7 +1930,7 @@ const allText = fileEntries.map(([name, code]) => `# --- ${name} ---\n${code}`).join('\n\n'); const cardHtml = ` -
+
${esc(projectName || 'Projekti')} (${fileEntries.length} tiedostoa) @@ -1960,7 +1964,7 @@ window.copyFileContent = function(cardId, idx) { const card = document.getElementById(cardId); if (!card) return; - const files = JSON.parse(card.dataset.files); + const files = projectFiles[cardId]; const entries = Object.entries(files); if (entries[idx]) { navigator.clipboard.writeText(entries[idx][1]); @@ -1973,7 +1977,7 @@ window.copyAllFiles = function(cardId) { const card = document.getElementById(cardId); if (!card) return; - const files = JSON.parse(card.dataset.files); + const files = projectFiles[cardId]; const text = Object.entries(files).map(([name, code]) => `# --- ${name} ---\n${code}`).join('\n\n'); navigator.clipboard.writeText(text); const btn = card.querySelector('[onclick*="copyAllFiles"]'); @@ -1983,7 +1987,7 @@ window.downloadZip = async function(cardId) { const card = document.getElementById(cardId); if (!card) return; - const files = JSON.parse(card.dataset.files); + const files = projectFiles[cardId]; // Luodaan ZIP ilman ulkoisia kirjastoja (yksinkertainen uncompressed ZIP) const entries = Object.entries(files);