Copy window.hintup.env.hintup_poptop_wheel = {};
window.hintup.env.hintup_poptop_wheel.start = function() {
window.hintup.env.hintup_poptop_wheel._control = 200;
window.hintup.env.hintup_poptop_wheel._interval = setInterval(function(){
window.hintup.env.hintup_poptop_wheel.canvas = document.querySelector('.hintup-poptop-wheel');
window.hintup.env.hintup_poptop_wheel.controlEffect();
if (window.hintup.env.hintup_poptop_wheel.canvas != null) {
clearInterval(window.hintup.env.hintup_poptop_wheel._interval);
window.hintup.env.hintup_poptop_wheel.ctx = window.hintup.env.hintup_poptop_wheel.canvas.getContext('2d');
window.hintup.env.hintup_poptop_wheel.ctx.beginPath();
window.hintup.env.hintup_poptop_wheel.ctx.strokeStyle = "#000000";
window.hintup.env.hintup_poptop_wheel.ctx.lineWidth = 5;
window.hintup.env.hintup_poptop_wheel.text_colors = ["#000","#fff","#000","#fff","#000","#fff","#000","#fff","#000","#fff","#000","#fff"];
window.hintup.env.hintup_poptop_wheel.colors = ["#ffffff","#0a0b68", "#ffffff","#0a0b68", "#ffffff","#0a0b68", "#ffffff","#0a0b68", "#ffffff","#0a0b68","#ffffff","#0a0b68"];
window.hintup.env.hintup_poptop_wheel.quienes = ["CUPOM 5%","CUPOM 7%","CUPOM 10%","FRETE GRÁTIS","CUPOM 5%","CUPOM 7%","CUPOM 10%","FRETE GRÁTIS","CUPOM 5%","CUPOM 7%","CUPOM 10%","FRETE GRÁTIS","CUPOM 5%","CUPOM 7%","CUPOM 10%","FRETE GRÁTIS"];
window.hintup.env.hintup_poptop_wheel.cupons = ["5OFF","7OFF","10OFF","FRETEBLOSS","5OFF","7OFF","10OFF","FRETEBLOSS","5OFF","7OFF","10OFF","FRETEBLOSS","5OFF","7OFF","10OFF","FRETEBLOSS"];
window.hintup.env.hintup_poptop_wheel.border_color = '#0a0b68';
window.hintup.env.hintup_poptop_wheel.arrow = '#ffffff'
window.hintup.env.hintup_poptop_wheel.insideRadiusColor = '#b5272e'
window.hintup.env.hintup_poptop_wheel.startAngle = 0;
window.hintup.env.hintup_poptop_wheel.arc = Math.PI / 6;
window.hintup.env.hintup_poptop_wheel.spinTimeout = null;
window.hintup.env.hintup_poptop_wheel.spinArcStart = 10;
window.hintup.env.hintup_poptop_wheel.spinTime = 0;
window.hintup.env.hintup_poptop_wheel.spinTimeTotal = Math.floor(Math.random() * (40000 - 20000)) + 20000;
window.hintup.env.hintup_poptop_wheel.ctx;
window.hintup.env.hintup_poptop_wheel.drawRouletteWheel();
document.querySelector('.hintup-poptop-wheel-button').onclick = function() {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var name = document.querySelector('.hintup-poptop-wheel-name').value;
var email = document.querySelector('.hintup-poptop-wheel-email').value;
var whats = document.querySelector('.hintup-poptop-wheel-whats').value;
var validEmail = re.test(String(email).toLowerCase());
document.querySelector('.hintup-poptop-wheel-cupom').style.background = 'transparent !important';
document.querySelector('.hintup-poptop-wheel-cupom').value = '';
if (name.trim().length < 3) {
document.querySelector('.hintup-poptop-wheel-name').style.background = '#ffa7a7';
document.querySelector('.hintup-poptop-wheel-name').setAttribute('placeholder','Por favor digite seu nome');
return false;
}
if (validEmail === false) {
document.querySelector('.hintup-poptop-wheel-email').style.background = '#ffa7a7';
document.querySelector('.hintup-poptop-wheel-email').setAttribute('placeholder','Por favor digite seu email');
return false;
}
if (whats.trim().length < 10) {
document.querySelector('.hintup-poptop-wheel-whats').style.background = '#ffa7a7';
document.querySelector('.hintup-poptop-wheel-whats').setAttribute('placeholder','Por favor digite seu whatsapp');
return false;
}
window.hintup.env.hintup_poptop_wheel.spin();
document.querySelector('.hintup-poptop-wheel-button').setAttribute('onclick','window.hintup.env.hintup_poptop_wheel_copy()');
}
}
window.hintup.env.hintup_poptop_wheel._control--;
if (window.hintup.env.hintup_poptop_wheel._control <=0) clearInterval(window.hintup.env.hintup_poptop_wheel._interval);
},100);
}
window.hintup.env.hintup_poptop_wheel.drawRouletteWheel = function() {
// var canvas = document.("hintup_poptop_wheel");
if (window.hintup.env.hintup_poptop_wheel.canvas.getContext) {
var outsideRadius = 240;
var textRadius = 150;
var insideRadius = 30;
window.hintup.env.hintup_poptop_wheel.ctx = window.hintup.env.hintup_poptop_wheel.canvas.getContext("2d");
window.hintup.env.hintup_poptop_wheel.ctx.clearRect(0,0,550,550);
window.hintup.env.hintup_poptop_wheel.ctx.strokeStyle = "#fff";
window.hintup.env.hintup_poptop_wheel.ctx.lineWidth = 2;
// window.hintup.env.hintup_poptop_wheel.ctx.arc(270, 270, insideRadius, 0, 2 * Math.PI);
// window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = window.hintup.env.hintup_poptop_wheel.insideRadiusColor;
// window.hintup.env.hintup_poptop_wheel.ctx.fill();
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetX = 0;
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetY = 0;
window.hintup.env.hintup_poptop_wheel.ctx.shadowColor = '';
window.hintup.env.hintup_poptop_wheel.ctx.shadowBlur = 0;
window.hintup.env.hintup_poptop_wheel.ctx.font = 'bold 18px sans-serif';
for(var i = 0; i < 12; i++) {
var angle = window.hintup.env.hintup_poptop_wheel.startAngle + i * window.hintup.env.hintup_poptop_wheel.arc;
window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = window.hintup.env.hintup_poptop_wheel.colors[i];
window.hintup.env.hintup_poptop_wheel.ctx.beginPath();
window.hintup.env.hintup_poptop_wheel.ctx.arc(270, 270, outsideRadius, angle, angle + window.hintup.env.hintup_poptop_wheel.arc, false);
window.hintup.env.hintup_poptop_wheel.ctx.arc(270, 270, insideRadius, angle + window.hintup.env.hintup_poptop_wheel.arc, angle, true);
window.hintup.env.hintup_poptop_wheel.ctx.stroke();
window.hintup.env.hintup_poptop_wheel.ctx.fill();
window.hintup.env.hintup_poptop_wheel.ctx.save();
window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = "white";
window.hintup.env.hintup_poptop_wheel.ctx.translate(270 + Math.cos(angle + window.hintup.env.hintup_poptop_wheel.arc / 2) * textRadius, 270 + Math.sin(angle + window.hintup.env.hintup_poptop_wheel.arc / 2) * textRadius);
window.hintup.env.hintup_poptop_wheel.ctx.rotate(angle + window.hintup.env.hintup_poptop_wheel.arc / 23 + Math.PI / 23);
window.hintup.env.hintup_poptop_wheel.ctx.stroke();
var text = window.hintup.env.hintup_poptop_wheel.quienes[i];
var color = window.hintup.env.hintup_poptop_wheel.text_colors[i];
window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = color;
window.hintup.env.hintup_poptop_wheel.ctx.rotate(144.6);
window.hintup.env.hintup_poptop_wheel.ctx.fillText(text, - window.hintup.env.hintup_poptop_wheel.ctx.measureText(text).width / 2, 5);
window.hintup.env.hintup_poptop_wheel.ctx.restore();
}
window.hintup.env.hintup_poptop_wheel.ctx.beginPath();
window.hintup.env.hintup_poptop_wheel.ctx.arc(270,270,245,0*Math.PI,2*Math.PI, false);
window.hintup.env.hintup_poptop_wheel.ctx.arc(270,270,230,0*Math.PI,2*Math.PI, true);
window.hintup.env.hintup_poptop_wheel.ctx.strokeStyle = window.hintup.env.hintup_poptop_wheel.border_color;
window.hintup.env.hintup_poptop_wheel.ctx.lineWidth = 1;
window.hintup.env.hintup_poptop_wheel.ctx.stroke();
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetX = 7;
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetY = 7;
window.hintup.env.hintup_poptop_wheel.ctx.shadowColor = '#000';
window.hintup.env.hintup_poptop_wheel.ctx.shadowBlur = 13;
window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = window.hintup.env.hintup_poptop_wheel.border_color;
window.hintup.env.hintup_poptop_wheel.ctx.fill();
window.hintup.env.hintup_poptop_wheel.ctx.closePath();
//Arrow
window.hintup.env.hintup_poptop_wheel.ctx.beginPath();
window.hintup.env.hintup_poptop_wheel.ctx.moveTo(470 + 15, 240 + 20);
window.hintup.env.hintup_poptop_wheel.ctx.lineTo(470 + 45, 240 + 10);
window.hintup.env.hintup_poptop_wheel.ctx.lineTo(470 + 55, 240 + 20);
window.hintup.env.hintup_poptop_wheel.ctx.lineTo(470 + 45, 240 + 30);
window.hintup.env.hintup_poptop_wheel.ctx.lineTo(470 + 15, 240 + 20);
// window.hintup.env.hintup_poptop_wheel.ctx.moveTo(270 + (outsideRadius + 15), 270 + 6);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius + 15), 270 - 6);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius - 15), 270 - 6);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius - 15), 270 - 15);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius - 33), 270 - 0);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius - 15), 270 + 15);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius - 15), 270 + 6);
// window.hintup.env.hintup_poptop_wheel.ctx.lineTo(270 + (outsideRadius + 15), 270 + 6);
window.hintup.env.hintup_poptop_wheel.ctx.strokeStyle = window.hintup.env.hintup_poptop_wheel.arrow;
window.hintup.env.hintup_poptop_wheel.ctx.lineWidth = 1;
window.hintup.env.hintup_poptop_wheel.ctx.stroke();
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetX = 2;
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetY = 2;
window.hintup.env.hintup_poptop_wheel.ctx.shadowColor = '#000';
window.hintup.env.hintup_poptop_wheel.ctx.shadowBlur = 5;
window.hintup.env.hintup_poptop_wheel.ctx.fillStyle = window.hintup.env.hintup_poptop_wheel.arrow;
window.hintup.env.hintup_poptop_wheel.ctx.fill();
window.hintup.env.hintup_poptop_wheel.ctx.closePath();
window.hintup.env.hintup_poptop_wheel.ctx.save;
}
}
window.hintup.env.hintup_poptop_wheel.rotateWheel = function() {
window.hintup.env.hintup_poptop_wheel.spinTime += 15;
if(window.hintup.env.hintup_poptop_wheel.spinTime >= window.hintup.env.hintup_poptop_wheel.spinTimeTotal) {
window.hintup.env.hintup_poptop_wheel.stop_rotateWheel();
return;
}
var spinAngle = window.hintup.env.hintup_poptop_wheel.spinAngleStart - window.hintup.env.hintup_poptop_wheel.easeOut(window.hintup.env.hintup_poptop_wheel.spinTime, 0, window.hintup.env.hintup_poptop_wheel.spinAngleStart, window.hintup.env.hintup_poptop_wheel.spinTimeTotal);
window.hintup.env.hintup_poptop_wheel.startAngle += (spinAngle * Math.PI / 180);
window.hintup.env.hintup_poptop_wheel.drawRouletteWheel();
window.hintup.env.hintup_poptop_wheel.spinTimeout = setTimeout('window.hintup.env.hintup_poptop_wheel.rotateWheel()', 30);
}
window.hintup.env.hintup_poptop_wheel.stop_rotateWheel = function() {
clearTimeout(window.hintup.env.hintup_poptop_wheel.spinTimeout);
var degrees = window.hintup.env.hintup_poptop_wheel.startAngle * 180 / Math.PI + 0; //The last parameter (+ 0) is about position of arrow
var arcd = window.hintup.env.hintup_poptop_wheel.arc * 180 / Math.PI;
var index = Math.floor((360 - degrees % 360) / arcd);
window.hintup.env.hintup_poptop_wheel.ctx.save();
window.hintup.env.hintup_poptop_wheel.ctx.font = 'bold 32px sans-serif';
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetX = 2;
window.hintup.env.hintup_poptop_wheel.ctx.shadowOffsetY = 2;
window.hintup.env.hintup_poptop_wheel.ctx.shadowBlur = 2;
window.hintup.env.hintup_poptop_wheel.ctx.shadowColor = "black";
var text = window.hintup.env.hintup_poptop_wheel.cupons[index];
document.querySelector('.hintup-poptop-wheel-cupom').style.visibility = 'visible';
document.querySelector('.hintup-poptop-wheel-cupom').value = text;
document.querySelector('.hintup-poptop-wheel-input').value = text;
document.querySelector('.hintup-poptop-wheel-button').value ='Você Ganhou! Copie seu Cupom!';
window.hintup.env.hintup_poptop_wheel.ctx.restore();
var coupon = document.querySelector('.hintup-poptop-wheel-cupom').value;
var name = document.querySelector('.hintup-poptop-wheel-name').value;
var email = document.querySelector('.hintup-poptop-wheel-email').value;
var whats = document.querySelector('.hintup-poptop-wheel-whats').value;
details= {
'nome':name,
'e-mail':email,
'whatsapp':whats,
'cupom':coupon
}
window.hintup.utilities.capture_report('Roleta - dados dos leads',details);
}
window.hintup.env.hintup_poptop_wheel.easeOut = function (t, b, c, d) {
var ts = (t/=d)*t;
var tc = ts*t;
return b+c*(tc + -3*ts + 3*t);
}
window.hintup.env.hintup_poptop_wheel.spin = function() {
window.hintup.env.hintup_poptop_wheel.spinAngleStart = Math.random() * 10 + 10;
window.hintup.env.hintup_poptop_wheel.spinTime = 0;
window.hintup.env.hintup_poptop_wheel.spinTimeTotal = Math.random() * 3 + 4 * 1000;
window.hintup.env.hintup_poptop_wheel.rotateWheel();
}
window.hintup.env.hintup_poptop_wheel.controlEffect = function(){
window.hintup.env.hintup_poptop_wheel._interval2 = setInterval(function(){
if (document.querySelector('.hintup-poptop-wheel-container').parentElement.style.visibility == 'visible') {
clearInterval(window.hintup.env.hintup_poptop_wheel._interval2);
document.querySelector('.hintup-poptop-wheel-container').classList.add("hintup-poptop-wheel-container-move");
window.hintup.env.hintup_poptop_wheel._interval3 = setInterval(function(){
if (document.querySelector('.hintup-poptop-wheel-container').parentElement.style.visibility == 'hidden') {
clearInterval(window.hintup.env.hintup_poptop_wheel._interval3);
window.hintup.env.hintup_poptop_wheel.controlEffect();
}
},100);
}
},100);
}
window.hintup.env.hintup_poptop_wheel.start();
/*COPY CUPOM Progressbar*/
window.hintup.env.hintup_poptop_wheel_copy = function() {
var copyText = document.querySelector(".hintup-poptop-wheel-input");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
document.querySelector('.hintup-poptop-wheel-button').value ='Cupom Copiado!';
}
// Movendo o elemento hintup_logo_brand para o elemento pai hintup-poptop-wheel //
var _success_times = 500;
var _success_interval = setInterval(function(){
if (document.querySelector('.hintup-poptop-wheel') !== null) {
clearInterval(_success_interval);
//mask for whatstapp field 15 chars
document.querySelector('.hintup-poptop-wheel-whats').onkeyup = function(){
setTimeout(function(){
v = document.querySelector('.hintup-poptop-wheel-whats').value
v=v.replace(/\D/g,""); //Remove tudo o que não é dígito
v=v.replace(/^(\d{2})(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
v=v.replace(/(\d)(\d{4})$/,"$1-$2"); //Coloca hífen entre o quarto e o quinto dígitos
document.querySelector('.hintup-poptop-wheel-whats').value = v;
},1)
}
}
_success_times--;
if (_success_times == 0) clearInterval(_success_interval);
},100);