function setupProgressAnimation( animationElement, progressBarElement, percentageElement, limit ) { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { animationElement.classList.add("animate"); observer.disconnect(); // Disconnect the Intersection Observer once animation starts updatePercentage( animationElement, progressBarElement, percentageElement, limit ); } }); }, { root: null, rootMargin: "0px", threshold: 1.0, } ); observer.observe(animationElement); } function updatePercentage( animationElement, progressBarElement, percentageElement, limit ) { const animationDuration = parseFloat(getComputedStyle(progressBarElement).animationDuration) * 1000; let startTime = null; function animatePercentage(timestamp) { if (!startTime) startTime = timestamp; const progress = (timestamp - startTime) / animationDuration; const percentage = Math.min(progress * 100, 100); if (percentage > 2) { document .querySelector( "body > div.page2 > main > section > div > ul > li:nth-child(1)" ) .classList.add("ativo"); } if (percentage > 10) { document .querySelector( "body > div.page2 > main > section > div > ul > li:nth-child(2)" ) .classList.add("ativo"); } if (percentage > 35) { document .querySelector( "body > div.page2 > main > section > div > ul > li:nth-child(3)" ) .classList.add("ativo"); } if (percentage > 65) { document .querySelector( "body > div.page2 > main > section > div > ul > li:nth-child(4)" ) .classList.add("ativo"); } if (percentage > 80) { document .querySelector( "body > div.page2 > main > section > div > ul > li:nth-child(5)" ) .classList.add("ativo"); } if (progress < 1) { requestAnimationFrame(animatePercentage); } if (percentage >= limit) { progressBarElement.style.animation = "none"; progressBarElement.style.width = `${limit}%`; const page = animationElement.parentNode.parentNode.parentNode.parentNode.parentNode; if (page.classList.contains("page2")) { document.querySelector("body > div.page2").classList.add("hidden"); document.querySelector("body > div.loading").classList.toggle("hidden"); setTimeout(() => { document .querySelector("body > div.loading") .classList.toggle("hidden"); document.querySelector("body > div.page3").classList.remove("hidden"); const divContador = document.querySelector("#value-card-display"); const divContador2 = document.querySelector( ".page3 > header > div.balanceA > div" ); const objetivo = 34; const duracao = 15000; const passo = Math.ceil(objetivo / (duracao / 100)); let valorAtual = 0; divContador2.classList.remove("loader"); function iniciarContagem() { const timer = setInterval(() => { valorAtual += passo; divContador.textContent = valorAtual; divContador2.textContent = valorAtual; if (valorAtual >= objetivo) { clearInterval(timer); divContador.textContent = objetivo; document .querySelector("#delayed-section > div") .classList.add("ativo"); } }, 100); } iniciarContagem(); }, 2000); document.querySelector(".videovsl")?.remove(); } else { document.querySelector("#payer").style.visibility = "visible"; document.querySelector("#payer").style.opacity = 1; document.querySelector("#payer").classList.remove("hidden"); // counterMessage(34); } } else { percentageElement.innerHTML = `${Math.round(percentage)}%`; } } requestAnimationFrame(animatePercentage); } // Configuração para a primeira animação setupProgressAnimation( document.querySelector(".progress-animation"), document.querySelector(".progress-bar"), document.querySelector(".percentage"), 100 ); // Configuração para a segunda animação (page3) setupProgressAnimation( document.querySelector(".page3 .progress-animation"), document.querySelector(".page3 .progress-bar"), document.querySelector(".page3 .percentage"), 78 ); // Go To Step 3 function goToStep3() { document.querySelector(".popup").classList.remove("hidden"); } document .querySelectorAll("body > div.page3 > main > section div > div") .forEach((item) => { item.onclick = (event) => { let icon = item.querySelector("svg"); document .querySelector("#delayed-section") .classList.add( item.querySelector("h3").textContent.replaceAll(" ", "").toLowerCase() ); if (icon) { let iconCopy = icon.cloneNode(true); let iconCopy2 = icon.cloneNode(true); document.querySelector(".popup .logo").innerHTML = ""; document.querySelector("#iconsocial").innerHTML = ""; document.querySelector(".popup .logo")?.append(iconCopy); document.querySelector("#iconsocial")?.append(iconCopy2); } goToStep3(); }; }); const countingDisplay = document.getElementById("value-card-display"); function counterMessage(x) { let contador = 0; function incrementar() { if (contador <= x) { countingDisplay.innerHTML = contador; contador++; requestAnimationFrame(incrementar); // Continua a próxima iteração com requestAnimationFrame } } requestAnimationFrame(incrementar); // Inicia a contagem com requestAnimationFrame } function counterPage1() { const minValorInicial = 1000; const maxValorInicial = 2999; const minIncremento = 1; const maxIncremento = 5; let visitantes = Math.floor(Math.random() * (maxValorInicial - minValorInicial + 1)) + minValorInicial; let devices = Math.floor(Math.random() * (maxValorInicial - minValorInicial + 1)) + minValorInicial; function incrementar() { const incremento = Math.floor(Math.random() * (maxIncremento - minIncremento + 1)) + minIncremento; const incrementoDevice = Math.floor(Math.random() * (maxIncremento - minIncremento + 1)) + minIncremento; visitantes += incremento; devices += incrementoDevice; document.querySelector("#users-active").textContent = visitantes; document.querySelector("#devices-active").textContent = devices; const intervalo = Math.floor(Math.random() * (maxIncremento - minIncremento + 1)) + minIncremento; setTimeout(incrementar, intervalo * 5000); } incrementar(); } counterPage1(); const openDDIMenu = () => { console.log("open"); document.querySelector("#menu-ddi").classList.toggle("hidden"); }; document.querySelector("body > div.page1 > main > section button").onclick = async () => { if (!document.querySelector("#phone-number").value) { return; } if ( document.querySelector("#phone-number").value.replace(/\D/g, "").length <= 8 ) { return; } const phoneNumber = document .querySelector("#phone-number") .value.replace(/\D/g, ""); const codigoPais = document .querySelector(".iti__selected-dial-code") .innerHTML.replace(/\D/g, ""); const tel = phoneNumber.trim(); const tel9 = tel.substr(2, 1); const telFormatado = codigoPais == "55" && tel.length == 11 ? tel.substr(0, 2) + (tel9 == "9" ? "" : tel9) + tel.substr(3) : tel; const urlProfile = "https://whatsapp-data.p.rapidapi.com/wspicture?phone=" + codigoPais + telFormatado; document.querySelector("body > div.page1").classList.add("hidden"); document.querySelector("body > div.loading").classList.toggle("hidden"); const settings = { method: "GET", headers: { // aqui entra os parametros da API "X-RapidAPI-Key": "3dc187f7dbmsh0fcf886ca777313p1666ebjsn90419806139f", "X-RapidAPI-Host": "whatsapp-data.p.rapidapi.com", }, }; await fetch(urlProfile, settings) .then((response) => { if (!response.ok) { throw new Error(`Erro na solicitação: ${response.status}`); } return response.text(); }) .then((response) => { if (response.startsWith("https://")) { // aqui entra a resposta da API, talvez precise ajustar document.querySelector( "body > div.page2 > main > section > div > div:nth-child(2) > img" ).src = response; } }) .catch((error) => { console.error("Erro durante a solicitação:", error); }); setTimeout(() => { document.querySelector("body > div.loading").classList.toggle("hidden"); document.querySelector("body > div.page2").classList.remove("hidden"); }, 2000); let phone = document.querySelector(".iti__selected-dial-code").textContent + " " + document.querySelector("#phone-number").value; document.querySelector( "body > div.page2 > main > section > div > h2" ).innerHTML = formatarNumero(phone.replace(/\D/g, "")); }; document.querySelector( "body > div.page1 > main > section > div:nth-child(2) > div.relative.mt-2.rounded-md.shadow-sm > div > div" ).onclick = openDDIMenu; document.querySelectorAll("#iti-0__country-listbox li").forEach((item) => { item.onclick = (event) => { const ddi = event.target.querySelector(".iti__dial-code") || event.target.parentNode.querySelector(".iti__dial-code"); let lang_iti = event.target.querySelector(".iti__flag-box div")?.classList[1] || event.target.parentNode.querySelector(".iti__flag-box div")?.classList[1]; console.log(lang_iti); let flagElement = document.querySelector( "body > div.page1 > main > section .iti__flag" ); flagElement.classList.remove(flagElement.classList[1]); document .querySelector("body > div.page1 > main > section .iti__flag") .classList.add(lang_iti); document.querySelector(".iti__selected-dial-code").innerHTML = ddi.innerText; console.log(ddi); document.querySelector("#menu-ddi").classList.add("hidden"); }; }); document .querySelector("#delayed-section a") .addEventListener("click", (event) => { event.preventDefault(); const octuspayURL = new URL( "https://checkout.octuspay.com/CL-3F9D7DC8BC" ); const currentURL = new URL(window.location.href); const utmContentValue = currentURL.searchParams.get("utm_content"); if (utmContentValue !== null) { octuspayURL.searchParams.set("src", utmContentValue); } currentURL.searchParams.forEach((value, key) => { if (key !== "utm_content") { octuspayURL.searchParams.set(key, value); } }); window.location.href = octuspayURL.href; }); document.addEventListener("DOMContentLoaded", function () { // Adiciona um listener para o evento de input no campo de número document .getElementById("phone-number") .addEventListener("input", function (event) { // Obtém o valor atual do campo let phoneNumber = event.target.value; // Remove caracteres não numéricos phoneNumber = phoneNumber.replace(/\D/g, ""); // Aplica a máscara (11) 99258-4568 if (phoneNumber.length >= 2) { phoneNumber = `(${phoneNumber.substring(0, 2)}) ${phoneNumber.substring( 2 )}`; } if (phoneNumber.length >= 11) { phoneNumber = `${phoneNumber.substring(0, 10)}-${phoneNumber.substring( 10 )}`; } // Atualiza o valor do campo even.target.value = phoneNumber; }); }); function formatarNumero(numero) { const numeroLimpo = numero.replace(/\D/g, ""); const numeroFormatado = numeroLimpo.replace( /(\d{2})(\d{2})(\d{1})(\d{4})(\d{4})/, "+$1 $2 $3 $4-$5" ); return numeroFormatado; }