/* Site DTF — the product page's buy box: grade, price per metre, billed length, total and the add-to-cart button, beside the live sheet. It shows the item the other site-*.js files already priced (itemAtual) and never computes a price of its own, so the box and the cart always agree. */ (function(){ const vals=$('compraVals'), add=$('bAdd'); function pintaCompra(){ const it=itemAtual; vals.hidden=!it; add.disabled=!it || !itemPodeEnviar(it); if(!it) return; const semNota=!it.nota; $('cNota').textContent = semNota ? 'sem nota' : it.nota; $('cNotaBar').style.width=(semNota?0:it.nota)+'%'; $('cNotaBar').className = semNota ? '' : it.nota>=85 ? 'ok' : it.nota>=50 ? 'av' : 'er'; $('cTabela').textContent = TABELA[it.modo]-it.unit>0.001 ? rs(TABELA[it.modo]) : ''; $('cMetro').textContent=rs(it.unit); $('cMetragem').textContent=fmtM(it.cob)+' m'; const sobraCm=Math.round((it.cob-it.metros)*100); $('cObs').textContent = it.cob===MINIMO_M && it.metros0 ? fmtM(it.metros)+' m de folha, arredondado a cada 10 cm.' : ''; $('cTotal').textContent=rs(it.total); } add.addEventListener('click',()=>adicionaAoCarrinho()); addEventListener('dtf-cart-changed',pintaCompra); pintaCompra(); })();