FORMULARIO - China Venture
Pergunta 1 de 8
Pergunta 1 de 8 ${currentStep > 0 ? `Voltar` : ``} Continuar `; const input = document.getElementById("cvfInput"); const next = document.getElementById("cvfNext"); const back = document.getElementById("cvfBack"); const error = document.getElementById("cvfError"); input.focus(); next.addEventListener("click", function () { const value = input.value.trim(); if (!value) { error.style.display = "block"; return; } answers[step.id] = value; currentStep++; render(); }); input.addEventListener("keypress", function (e) { if (e.key === "Enter") { e.preventDefault(); next.click(); } }); if (back) { back.addEventListener("click", function () { currentStep--; render(); }); } } function renderRadioStep(step) { screen.innerHTML = ` ${escapeHtml(step.title)} Selecione uma opção para continuar. ${step.options.map(option => ` ${escapeHtml(option)} `).join("")} ${currentStep > 0 ? `Voltar` : ``} `; const options = screen.querySelectorAll(".cvf-option"); const back = document.getElementById("cvfBack"); options.forEach(btn => { btn.addEventListener("click", function () { answers[step.id] = btn.getAttribute("data-value"); currentStep++; render(); }); }); if (back) { back.addEventListener("click", function () { currentStep--; render(); }); } } function renderSummary() { const profile = getProfile(); screen.innerHTML = ` ✓ Formulário concluído com sucesso Tudo certo, vamos para o WhatsApp Seu preenchimento foi concluído. Clique no botão abaixo para continuar o atendimento no WhatsApp. ${escapeHtml(profile.title)} ${escapeHtml(profile.description)} ${steps.map(step => ` ${escapeHtml(step.title)} ${escapeHtml(answers[step.id] || "-")} `).join("")} Refazer formulário Ir para o WhatsApp `; document.getElementById("cvfRestart").addEventListener("click", function () { Object.keys(answers).forEach(key => delete answers[key]); currentStep = 0; render(); }); document.getElementById("cvfWhatsapp").addEventListener("click", function () { openWhatsApp(); }); setTimeout(function () { openWhatsApp(); }, 1200); } function render() { updateProgress(); if (currentStep >= steps.length) { renderSummary(); return; } const step = steps[currentStep]; if (step.type === "text") { renderTextStep(step); } else { renderRadioStep(step); } } render(); })();