feat: add PDF download action from sidebar

This commit is contained in:
2026-03-08 10:09:20 +01:00
parent 068c433a8f
commit a3a762675f

View File

@@ -83,6 +83,7 @@ body.modal-open { overflow: hidden; }
<!-- Import menu hidden by request --> <!-- Import menu hidden by request -->
<button id="openReorder">↕️ Reihenfolge anpassen</button> <button id="openReorder">↕️ Reihenfolge anpassen</button>
<button id="openAi">🤖 KI-Generierung</button> <button id="openAi">🤖 KI-Generierung</button>
<button id="downloadPdf">📄 PDF Download</button>
</aside> </aside>
<main class="main"><div id="app"></div></main> <main class="main"><div id="app"></div></main>
</div> </div>
@@ -493,6 +494,16 @@ function closeAiModal(){
document.body.classList.remove('modal-open'); document.body.classList.remove('modal-open');
} }
function downloadPdf(){
const printWin = window.open('', '_blank');
if (!printWin) return;
const cardsHtml = app.innerHTML;
const css = [...document.querySelectorAll('style')].map(s=>s.textContent||'').join('\n');
printWin.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>Coachingcards PDF</title><style>${css}\n.topbar,.sidebar,.card-actions,.modal-actions,.menu-btn{display:none!important;} body{background:#fff!important;padding:0!important;} .main{padding:0!important;} .card-size{margin:0 auto 12px auto!important;box-shadow:none!important;} @media print{.exercise-container{page-break-after:always;}}</style></head><body><div id="app">${cardsHtml}</div></body></html>`);
printWin.document.close();
printWin.onload = () => setTimeout(() => printWin.print(), 200);
}
async function syncActiveJob(){ async function syncActiveJob(){
const r = await fetch('/api/generate/active'); const r = await fetch('/api/generate/active');
const j = await r.json(); const j = await r.json();
@@ -620,6 +631,7 @@ document.getElementById('saveAll').onclick=async()=>{
document.getElementById('menuToggle').onclick=()=>sidebar.classList.toggle('open'); document.getElementById('menuToggle').onclick=()=>sidebar.classList.toggle('open');
document.getElementById('openReorder').onclick=()=>{ sidebar.classList.remove('open'); openReorderModal(); }; document.getElementById('openReorder').onclick=()=>{ sidebar.classList.remove('open'); openReorderModal(); };
document.getElementById('openAi').onclick=async()=>{ sidebar.classList.remove('open'); await openAiModal(); }; document.getElementById('openAi').onclick=async()=>{ sidebar.classList.remove('open'); await openAiModal(); };
document.getElementById('downloadPdf').onclick=()=>{ sidebar.classList.remove('open'); downloadPdf(); };
document.getElementById('cancelReorder').onclick=closeReorderModal; document.getElementById('cancelReorder').onclick=closeReorderModal;
document.getElementById('closeReorderX').onclick=closeReorderModal; document.getElementById('closeReorderX').onclick=closeReorderModal;
document.getElementById('saveReorder').onclick=async()=>{ document.getElementById('saveReorder').onclick=async()=>{