Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3719,6 +3719,9 @@
.pdf-sc.on b{color:var(--accent-strong)}
.pdf-sc:disabled{opacity:.55;cursor:not-allowed}
.pdf-sc:focus-visible{outline:2px solid var(--text-2);outline-offset:2px} /* grigio, non verde: il verde dice «scelta», il fuoco iniziale cade sul primo bottone */
.pdf-esterni{margin-top:10px;display:flex;flex-direction:column;gap:5px}
.pdf-esterni .btn{width:100%;text-align:left;white-space:normal}
.pdf-esterni small{font-size:12px;color:var(--text-2);line-height:1.4}
.pdf-sc-riep{font-size:12px;color:var(--text-2);margin-top:7px;line-height:1.4}
.pdf-sc-nota{font-size:11px;color:var(--text-3);margin-top:3px;line-height:1.4}
.pdf-sc-nota[hidden]{display:none}
Expand Down Expand Up @@ -6433,6 +6436,12 @@ <h2>Esporta PDF in scala</h2>
<div class="pdf-sc-riep" id="pdfScRiepilogo" role="status" aria-live="polite"></div>
<div class="pdf-sc-nota" id="pdfScNota" hidden></div>
</div>
<!-- PALCO PER ESTERNI (16/11/2026, M-078): la seconda uscita di ogni versione, accanto al PDF completo. Solo il disegno,
con la fascia «titolo · luogo · Stage plot vN · data»: è ciò che si manda a teatro, service, Diego. -->
<div class="pdf-esterni" id="pdfEsterniBox">
<button type="button" class="btn" id="pdfEsterni"><span><b>Palco per esterni</b> (solo disegno, con versione)</span></button>
<small>PDF vettoriale per teatro, service e Diego: il palco in scala con titolo, luogo, versione e data in alto. Niente cartiglio, conteggi né liste.</small>
</div>
<div id="pdfTechBox" style="display:none">
<div class="pdf-side-h" id="pdfPillsTitle">Pagine del PDF, una per una</div>
<div id="pdfPills" class="pillrow"></div>
Expand Down
109 changes: 109 additions & 0 deletions index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,12 @@ <h2>Esporta PDF in scala</h2>
<div class="pdf-sc-riep" id="pdfScRiepilogo" role="status" aria-live="polite"></div>
<div class="pdf-sc-nota" id="pdfScNota" hidden></div>
</div>
<!-- PALCO PER ESTERNI (16/11/2026, M-078): la seconda uscita di ogni versione, accanto al PDF completo. Solo il disegno,
con la fascia «titolo · luogo · Stage plot vN · data»: è ciò che si manda a teatro, service, Diego. -->
<div class="pdf-esterni" id="pdfEsterniBox">
<button type="button" class="btn" id="pdfEsterni"><span><b>Palco per esterni</b> (solo disegno, con versione)</span></button>
<small>PDF vettoriale per teatro, service e Diego: il palco in scala con titolo, luogo, versione e data in alto. Niente cartiglio, conteggi né liste.</small>
</div>
<div id="pdfTechBox" style="display:none">
<div class="pdf-side-h" id="pdfPillsTitle">Pagine del PDF, una per una</div>
<div id="pdfPills" class="pillrow"></div>
Expand Down Expand Up @@ -41753,6 +41759,98 @@ <h2>Esporta PDF in scala</h2>
info.hidden=true; go.disabled=false; go.textContent=_t; m.hidden=true;
}).catch(function(e){ info.hidden=true; go.disabled=false; go.textContent=_t; err.textContent="Non sono riuscito a fare il pacchetto: "+(e&&e.message||e); err.hidden=false; });
}
/* ═══ PALCO PER ESTERNI (16/11/2026, M-078 approvata da Simone) ═══
Seconda uscita di ogni versione: il PDF vettoriale con SOLO il palco (disegno in scala, barra della scala, quinte, «FONDO PALCO» / «PUBBLICO»,
misure del palco, planimetria di sfondo se c'è) e in alto una FASCIA «Titolo · luogo / Stage plot vN · data [· Provvisorio]». Niente cartiglio,
conteggi (leggii, sedute, pedane, ascolti), rider né liste: è quello che si manda al teatro, al service, a Diego (il completo resta per noi).
Stesso motore del PDF «solo palco»: il foglio sotto la fascia si dimensiona come se la fascia fosse un cartiglio basso (cartH = fascia + 1) e il
disegno scende poi di quanto è alta la fascia, così in fondo resta solo il posto della barra. */
function palcoEsterniNomeFile(d){
var v=versioneNumero(), _st=statoDocEtichetta();
if(!v) return nomeConStato(fileName()+" - palco.pdf");
var t=titoloSenzaVersione(state.titolo).replace(/[\\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim().slice(0,100).trim().replace(/[. ]+$/,"");
if(!t) t="Stage plot";
return t+" - v"+v+" del "+dataGgMmAaaa(d||new Date(),"-")+(_st?" - "+_st:"")+" - palco.pdf";
}
/* le due righe della fascia (testo): titolo · luogo, poi «Stage plot vN · data · stato · evento GG/MM/AAAA» */
function palcoEsterniTesti(d){
var t=titoloSenzaVersione(state.titolo)||"Stage plot", l=String(state.luogo||"").trim();
var v=versioneNumero(), parti=[v ? "Stage plot v"+v : "Stage plot", dataGgMmAaaa(d||new Date(),"/")];
if(statoDocEtichetta()) parti.push(statoDocEtichetta());
if(/^\d{4}-\d{2}-\d{2}$/.test(String(state.evDate||""))){ var e=state.evDate.split("-"); parti.push("evento "+e[2]+"/"+e[1]+"/"+e[0]); }
return {titolo:t+(l ? " · "+l : ""), sub:parti.join(" · ")};
}
/* righe già a capo (mai «…») e altezza della fascia in mm; `doc` serve solo per misurare le parole */
function palcoEsterniFascia(doc, pw, M, d){
var T=palcoEsterniTesti(d), w=pw-2*M;
doc.setFont("helvetica","bold"); doc.setFontSize(14);
var tit=doc.splitTextToSize(T.titolo, w);
doc.setFont("helvetica","normal"); doc.setFontSize(10);
var sub=doc.splitTextToSize(T.sub, w);
var h=4+tit.length*6.2+sub.length*4.8+2.5;
return {tit:tit, sub:sub, h:Math.round(h*100)/100};
}
/* foglio, orientamento e scala: quelli scelti nell'Esporta; con «Auto» vince il verso che stampa il palco più grande (a parità, orizzontale) */
function palcoEsterniPiano(doc, paperKey, scaleSel, orientSel, d){
var os=orientSel==="landscape"||orientSel==="portrait" ? [orientSel] : ["landscape","portrait"], best=null;
os.forEach(function(o){
var L0=pdfLayout(paperKey, o, 22), F=palcoEsterniFascia(doc, L0.pw, L0.M, d), ch=F.h+1;
var N=resolveScale(paperKey, scaleSel, o, ch); if(!N) return;
var box=pdfStageBox(N, paperKey, o, ch), c={o:o, N:N, F:F, ch:ch, box:box};
if(!best || (best.box.cropped && !box.cropped) || (best.box.cropped===box.cropped && N<best.N)) best=c;
});
return best;
}
function buildPdfPalcoEsterni(paperKey, scaleSel, orientSel){
return loadJsPDF().then(function(){
var jsPDF=window.jspdf.jsPDF, d=new Date();
var P=palcoEsterniPiano(new jsPDF({orientation:"portrait", unit:"mm", format:"a4"}), paperKey, scaleSel, orientSel, d);
if(!P) throw new Error("Il palco non entra nemmeno a 1:500 su "+paperKey.toUpperCase()+": cambia foglio o area nell'Esporta.");
var N=P.N, box=P.box, F=P.F, sh=F.h, L=box.L, M=L.M;
var doc=new jsPDF({orientation:L.orient, unit:"mm", format:paperKey, compress:true});
var scena={textK:pdfTextK(N), noBlockDims:pdfQuoteFuoriDalDisegno(box) && stageBlocks().length<2,
areaFoglio:{x:L.drawX, y:L.drawY+sh, w:L.drawW, h:L.drawH}};
/* il box tutto spostato in giù della fascia, col fondo del cartiglio «finto» ridotto a 1: serve a barra e quote */
var b2=Object.assign({}, box, {L:Object.assign({}, L, {cartH:1, drawY:L.drawY+sh}), iy:box.iy+sh,
rMm:{x:box.rMm.x, y:box.rMm.y+sh, w:box.rMm.w, h:box.rMm.h}});
return drawStageVector(doc, box.ix, box.iy+sh, box.mmW, box.mmH, box.vb, "clean", scena)
.catch(function(){ return pdfRipiegoRaster(doc, box.ix, box.iy+sh, box.mmW, box.mmH, box.vb, scena); })
.then(function(){
if(pdfQuoteFuoriDalDisegno(box)){
doc.setFont("helvetica","normal"); doc.setTextColor(107,114,128); doc.setFontSize(8.5);
var q=b2.rMm;
doc.text(adattaM(state.stage.w)+" m", q.x+q.w/2, q.y-8, {align:"center"});
doc.text(adattaM(state.stage.d)+" m", q.x-5, q.y+q.h/2, {align:"center", angle:90});
}
var barra=pdfScaleBarPosa(b2, N, {blockDims:!scena.noBlockDims, quoteJs:pdfQuoteFuoriDalDisegno(box)});
pdfScaleBar(doc, barra.x, barra.y, N);
/* la fascia in alto: titolo · luogo, «Stage plot vN · data», e una riga sotto */
var T=palcoEsterniTesti(d), y=M+4.2;
doc.setFont("helvetica","bold"); doc.setFontSize(14); doc.setTextColor(17,24,39);
F.tit.forEach(function(r){ doc.text(r, M, y); y+=6.2; });
doc.setFont("helvetica","normal"); doc.setFontSize(10); doc.setTextColor(55,65,81);
F.sub.forEach(function(r){ doc.text(r, M, y-0.6); y+=4.8; });
doc.setDrawColor(31,41,55); doc.setLineWidth(0.4); doc.line(M, M+sh-0.5, L.pw-M, M+sh-0.5);
pdfCredit(doc); /* «1 di 1 · vN · data» e il credito, come ogni foglio */
doc.__palcoEsterni={N:N, orient:L.orient, cropped:!!box.cropped, testi:T};
return doc;
});
});
}
function exportPalcoEsterni(paperKey, scaleSel, orientSel){
if(custEditorAttivo()){ custEditorAvvisa(); return Promise.resolve(false); }
var info=document.getElementById("pdfInfo");
info.className="mstatus"; info.textContent="Genero il palco per esterni…";
return buildPdfPalcoEsterni(paperKey, scaleSel, orientSel).then(function(doc){
var nome=palcoEsterniNomeFile(); pdfSave(doc, nome);
if(typeof segnaPdfEsportato==="function") segnaPdfEsportato();
var m=doc.__palcoEsterni;
info.className="mstatus"+(m.cropped?" warn":" ok");
info.textContent=(m.cropped?"⚠ ":"✓ ")+"Palco per esterni scaricato ("+paperKey.toUpperCase()+" "+(m.orient==="portrait"?"verticale":"orizzontale")+", scala 1:"+m.N+")"+(m.cropped?" — stampata solo la parte centrale che ci sta nel foglio.":".");
try{ track("export",{format:"pdf-palco-esterni"}); }catch(_e){}
return true;
}).catch(function(e){ info.className="mstatus err"; info.textContent="Errore: "+(e&&e.message||e); return false; });
}
function exportPdf(paperKey, scaleSel, orient, header){
if(custEditorAttivo()){ custEditorAvvisa(); return Promise.resolve(false); } /* editor «Crea elemento» aperto: lo stato vivo è il palco temporaneo: niente export */
var info=document.getElementById("pdfInfo");
Expand Down Expand Up @@ -42684,6 +42782,17 @@ <h2>Esporta PDF in scala</h2>
orient.addEventListener("change", refresh); header.addEventListener("input", refresh);
document.getElementById("pdfPrev").addEventListener("click", function(){ prevIdx--; renderPreview(); });
document.getElementById("pdfNext").addEventListener("click", function(){ prevIdx++; renderPreview(); });
(function(){ /* PALCO PER ESTERNI (M-078): stesso foglio, orientamento e scala scelti per il PDF; stesso gate sugli errori critici */
var be=document.getElementById("pdfEsterni"); if(!be) return;
be.addEventListener("click", function(){
if(be.disabled) return;
pdfGateErrori(function(){
be.disabled=true;
var sel=pdfScaleValue(), p=exportPalcoEsterni(paper.value, sel, document.getElementById("pdfOrient") ? document.getElementById("pdfOrient").value : "auto");
p.then(function(){ be.disabled=false; }, function(){ be.disabled=false; });
});
});
})();
document.getElementById("pdfGo").addEventListener("click", function(){
var b=this;
if(b.disabled) return; /* niente due export in parallelo: erano due file e due passate di svg2pdf sul main thread */
Expand Down
Loading
Loading