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) <noreply@anthropic.com>
This commit is contained in:
@@ -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) =>
|
||||
`<span class="proj-tab" data-card="${cardId}" data-idx="${i}" style="padding:4px 10px;cursor:pointer;border-radius:4px 4px 0 0;font-size:12px;${i === 0 ? 'background:#161b22;color:#58a6ff;border:1px solid #30363d;border-bottom:none' : 'color:#8b949e'}" onclick="switchProjectTab('${cardId}',${i})">${esc(name)}</span>`
|
||||
).join('');
|
||||
@@ -1926,7 +1930,7 @@
|
||||
const allText = fileEntries.map(([name, code]) => `# --- ${name} ---\n${code}`).join('\n\n');
|
||||
|
||||
const cardHtml = `
|
||||
<div id="${cardId}" style="margin:8px 0;border:1px solid #30363d;border-radius:6px;background:#161b22;overflow:hidden" data-files='${esc(JSON.stringify(files))}'>
|
||||
<div id="${cardId}" style="margin:8px 0;border:1px solid #30363d;border-radius:6px;background:#161b22;overflow:hidden">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:#0d1117;border-bottom:1px solid #30363d">
|
||||
<span style="color:#a371f7;font-weight:600;font-size:13px">${esc(projectName || 'Projekti')} <span style="color:#8b949e;font-weight:normal">(${fileEntries.length} tiedostoa)</span></span>
|
||||
<span style="display:flex;gap:6px">
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user