From 3d8bca3af78ae113a8832fbe55599ae91e1a0425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 30 Sep 2026 14:43:30 -0300 Subject: [PATCH] feat: the upload bar says how long is left, not a notice before it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The product page's notice about the upload time is gone. The cart's upload bar now reads "Enviando seus arquivos · faltam cerca de 6 min", measured from the upload's own speed (a range from the size for the first seconds), with a line saying the time depends on the internet and to keep the page open. The header and the pay button show the same time instead of a percentage. Co-Authored-By: Claude Opus 5.5 --- web/checkout.js | 19 ++++++++++++------- web/index.html | 1 - web/site-cart.js | 1 - web/site-config.js | 11 +---------- web/site-flow.js | 1 - web/site-modes.js | 2 -- web/site-pdf.js | 2 -- web/site-v2.css | 3 +-- 8 files changed, 14 insertions(+), 26 deletions(-) diff --git a/web/checkout.js b/web/checkout.js index fd7940c..10b0c34 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -147,15 +147,15 @@ return {total, sent, fase, pct:Math.floor(sent/total*100), restante: fase==='enviando' && taxa>0 ? (total-sent)/taxa : null}; } - const tempo=s=>s<60 ? 'menos de 1 min' : 'cerca de '+Math.ceil(s/60)+' min'; + const falta=s=>s<60 ? 'falta menos de 1 min' : 'faltam cerca de '+duracao(s); + // The time left, measured from the upload's own speed; until there is a + // measure, a range from the size. + const restante=e=>e.restante!=null ? falta(e.restante) : 'estimativa '+faixaEnvio(e.total-e.sent); function textoEnvio(e) { if (!e) return ''; if (e.fase==='pronto') return 'Arquivos enviados'; if (e.fase==='verificando') return 'Arquivos enviados · verificando a segurança…'; - // Until the speed is measured, the range from the file size. - return 'Enviando seus arquivos: '+e.pct+'% · '+mb(e.sent)+' de '+mb(e.total)+' · '+ - (e.restante!=null ? tempo(e.restante) : 'estimativa '+faixaEnvio(e.total-e.sent))+ - '. Mantenha a página aberta.'; + return 'Enviando seus arquivos · '+restante(e); } function pintaEnvio() { const e=estadoEnvio(), texto=textoEnvio(e); @@ -183,13 +183,18 @@ } if (e?.fase==='pronto') el.insertAdjacentHTML('beforeend', icone('okCirculo')); if (texto) el.append(document.createTextNode(texto)); + if (e?.fase==='enviando') { + const nota=document.createElement('small'); nota.className='envioNota'; + nota.textContent='O tempo depende da velocidade da sua internet. Mantenha a página aberta.'; + el.append(nota); + } el.classList.toggle('ok', e?.fase==='pronto'); } // Visible on every page while it runs. - if (topo) topo.textContent = !e || e.fase==='pronto' ? '' : e.fase==='verificando' ? '· verificando' : '· enviando '+e.pct+'%'; + if (topo) topo.textContent = !e || e.fase==='pronto' ? '' : e.fase==='verificando' ? '· verificando' : e.restante!=null ? '· '+duracao(e.restante) : '· enviando'; if (busy && texto) { message(texto); - $('bPagarTx').textContent = e && e.fase!=='pronto' ? (e.fase==='verificando' ? 'Verificando os arquivos…' : 'Enviando arquivos… '+e.pct+'%') : $('bPagarTx').textContent; + $('bPagarTx').textContent = e && e.fase!=='pronto' ? (e.fase==='verificando' ? 'Verificando os arquivos…' : 'Enviando arquivos… '+restante(e)) : $('bPagarTx').textContent; } } // Leaving the page pauses an upload; it resumes, but the customer is warned. diff --git a/web/index.html b/web/index.html index c6e1bbd..0042ddd 100644 --- a/web/index.html +++ b/web/index.html @@ -917,7 +917,6 @@ footer a:hover{color:var(--laranja2)}
-
Arraste aqui diff --git a/web/site-cart.js b/web/site-cart.js index 8a1cbb6..38714ab 100644 --- a/web/site-cart.js +++ b/web/site-cart.js @@ -77,7 +77,6 @@ function pintaPedido(){ if(pedido.length || itemAtual) $('carr').classList.add('on'); if($('cartN')){ $('cartN').textContent=noCarrinho>99?'99+':noCarrinho; $('cartN').hidden=!noCarrinho; $('cartLink').setAttribute('aria-label','Carrinho, '+noCarrinho+(noCarrinho===1?' item':' itens')); } - pintaAvisoEnvio(); window.dispatchEvent(new Event('dtf-cart-changed')); } diff --git a/web/site-config.js b/web/site-config.js index 2401117..826f668 100644 --- a/web/site-config.js +++ b/web/site-config.js @@ -124,22 +124,13 @@ const destinoApi=()=>entrega.tipo!=='frete' ? null : { // Tempo de envio antes de medir a internet de quem compra: uma faixa entre um // upload lento (10 Mbps) e um rápido (150 Mbps). O arquivo vai direto para o // armazenamento, então é o upload do cliente que manda. -const ENVIO_LENTO=10e6/8, ENVIO_RAPIDO=150e6/8, ENVIO_AVISA_S=120; +const ENVIO_LENTO=10e6/8, ENVIO_RAPIDO=150e6/8; const duracao=s=>{ const min=Math.ceil(s/60); return s<60 ? 'menos de 1 min' : min<60 ? min+' min' : Math.floor(min/60)+' h'+(min%60? ' '+min%60+' min' : ''); }; const faixaEnvio=bytes=>bytes/ENVIO_RAPIDO<60 ? 'até '+duracao(bytes/ENVIO_LENTO) : 'de '+duracao(bytes/ENVIO_RAPIDO)+' a '+duracao(bytes/ENVIO_LENTO); -// Só enquanto há arquivos no produto aberto: sai quando o item vai para o carrinho. -function pintaAvisoEnvio(){ - const el=$('avisoEnvio'); if(!el) return; - const total=modo ? (ehFolha()?folhas:artes).reduce((t,x)=>t+(x.f?.size||0),0) : 0; - el.hidden = total/ENVIO_LENTO < ENVIO_AVISA_S; - if(el.hidden) return; - el.innerHTML='Envio: '+faixaEnvio(total)+' ('+fmt(total)+'), conforme sua internet. '+ - 'Mantenha a página aberta.'; -} const larguraFilme=()=>MODOS[modo].larg; // cobrança proporcional: arredonda para cima em 10 cm · 2,75 m vira 2,80 m const cobrar=m=>Math.max(MINIMO_M, Math.ceil(m*10)/10); diff --git a/web/site-flow.js b/web/site-flow.js index e6f8c89..6b87f73 100644 --- a/web/site-flow.js +++ b/web/site-flow.js @@ -29,7 +29,6 @@ function guardaItem(){ $('foco').classList.remove('on'); ['qual','prev'].forEach(id=>$(id).classList.remove('on')); modo=null; artes=[]; folhas=[]; metros=0; nota=0; montagemCm=0; - pintaAvisoEnvio(); pintaPedido(); return true; } diff --git a/web/site-modes.js b/web/site-modes.js index 329c876..f2b0d24 100644 --- a/web/site-modes.js +++ b/web/site-modes.js @@ -11,7 +11,6 @@ function escolheProduto(m){ } function abrir(m){ modo=m; artes=[]; folhas=[]; metros=0; nota=0; reencaixado=false; - pintaAvisoEnvio(); montagemCm=0; avisoTipo(''); pintaModo(); @@ -90,7 +89,6 @@ document.querySelectorAll('#tipoEnvio .cam').forEach(b=>b.addEventListener('clic function trocaTipo(destino){ if(!destino || modo===destino) return; folhas=[]; artes=[]; recemChegada=null; metros=0; nota=0; montagemCm=0; - pintaAvisoEnvio(); modo=destino; history.replaceState(history.state,'',PAGINAS[modo]); document.title=tituloPagina(); $('lista').innerHTML=''; $('rA').style.display='none'; recusa([]); diff --git a/web/site-pdf.js b/web/site-pdf.js index bc9b7aa..ee0692f 100644 --- a/web/site-pdf.js +++ b/web/site-pdf.js @@ -406,7 +406,6 @@ function detalhesDaFolha(a,i,aberto){ } function pintaFolha(){ invalidaItemAtual(); - pintaAvisoEnvio(); const L=larguraFilme(); pintaTipoEnvio(); // trava o seletor enquanto houver folha $('zona').classList.toggle('compacta', folhas.length>0); @@ -529,7 +528,6 @@ function pintaProgressoArte(a){ } function pintaArtes(){ invalidaItemAtual(); - pintaAvisoEnvio(); $('zona').classList.toggle('compacta', artes.length>0); // The same card as a finished sheet: thumbnail, size, a DPI chip, then the // width (with the usual sizes), copies, rotation and mirroring. diff --git a/web/site-v2.css b/web/site-v2.css index b2143d1..7502e71 100644 --- a/web/site-v2.css +++ b/web/site-v2.css @@ -339,8 +339,6 @@ section+section{border-top:0} /* The payment pages: paying on the left, the order summary on the right */ html:is([data-rota="pagamento"],[data-rota="pix"]) .checkout{max-width:1040px;margin-top:8px} html:is([data-rota="pagamento"],[data-rota="pix"]) .pagGrid{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:32px;align-items:start} -.avisoEnvio{margin:10px 0 0;padding:10px 12px;border-radius:8px;background:var(--aviso-fundo);color:#5A3A00;font-size:15px;line-height:1.5} -.avisoEnvio[hidden]{display:none} .ic{width:21px;height:21px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:middle} .busca .lupa{display:flex;font-size:0} .busca .lupa .ic{width:18px;height:18px} @@ -373,6 +371,7 @@ html:is([data-rota="pagamento"],[data-rota="pix"]) .pagGrid{display:grid;grid-te .qi .c .ic{width:15px;height:15px;stroke-width:3} .passos a span .ic{width:17px;height:17px;stroke-width:3} .obr{color:#B42318;font-weight:700} +.envioNota{display:block;margin-top:4px;font-size:14px;color:var(--fraco)} .envioArq{font-size:15px;color:var(--texto2);margin-top:14px;line-height:1.5} .envioArq.ok{color:var(--verde)} .envioArq.erro{color:#B42318}