var widget_id = 'HsVPUmzhcO3S';document.addEventListener('keyup', function(event) {
if (event.ctrlKey && event.keyCode == 116) {
sessionStorage.clear();
}
});
var head = document.querySelector('head');
var s = document.createElement('script');
// s.type = 'text/javascript';
s.async = true;
s.src = '';
head.insertBefore(s, head.firstElementChild.nextSibling);
if (!sessionStorage.getItem('widgetisset')) {
sessionStorage.setItem('invitation_x', 1);
}
function prinwpp(phone, message, position, bottomP, linksA, widgetType, workH, is_invitation, invitation, invitation_sec, invitation_times, greeting_message, icon_style, icon_size, icon_size_mobile){
let wbot = document.createElement('div');
let wimg = document.createElement('img');
let body = document.querySelector('body');
let box = document.createElement('div');
let boxapp = document.createElement('div');
var mainwwpjv = document.querySelector('#mainwwpjv');
wbot.classList.add('wbotmain');
box.classList.add('box');
boxapp.classList.add('boxapp');
var number = phone;
var greeting_message = message;
var call_to_action = message;
var position = position;
var bottomPosition = bottomP + "px";
if (window.innerWidth <= 980) {
wimg.src = icon_style;
wbot.style.width = icon_size_mobile+"%";
wimg.style.width = "100%";
if (position == "left") {
wbot.style.left = "17px";
box.style.left = "0px";
if (widgetType == 0) {
}else {
boxapp.innerHTML = "
X
Olá! Como deseja
falar conosco?
"
}
if (is_invitation == 1 && sessionStorage.getItem('invitation_x') <= invitation_times) {
sessionStorage.setItem('invitation_x', parseInt(sessionStorage.getItem('invitation_x')) + 1);
wbot.innerHTML = "";
setTimeout(function(){
document.getElementById('proactiveinvitation').style.bottom = "72px";
document.querySelector('.closeinvitation').onclick = function(){
document.querySelector('.proactiveinvitation').style.display = "none";
}
}, invitation_sec)
}
}else {
wbot.style.right = "17px";
wimg.style.width = "100%";
if (widgetType == 0) {
}else {
boxapp.innerHTML = " X
Olá! Como deseja
falar conosco?
"
}
if (is_invitation == 1 && sessionStorage.getItem('invitation_x') <= invitation_times) {
sessionStorage.setItem('invitation_x', parseInt(sessionStorage.getItem('invitation_x')) + 1);
wbot.innerHTML = "";
setTimeout(function(){
document.getElementById('proactiveinvitation').style.bottom = "72px";
document.querySelector('.closeinvitation').onclick = function(){
document.querySelector('.proactiveinvitation').style.display = "none";
}
}, invitation_sec)
}
}
if (widgetType == 0) {
wimg.onclick = function() {
window.open(decodeURIComponent(linksA), '_blank');
var ajax1 = new XMLHttpRequest();
ajax1.open("POST", "https://greebox.app/widget/request.php", true);
ajax1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax1.send("widget="+ widget_id+"&increment=true");
};
}else {
wimg.onclick = function() {
if (document.querySelector('#mainwwpjv').style.bottom == '-313px') {
document.querySelector('#mainwwpjv').style.bottom = "0px"
}else {
document.querySelector('#mainwwpjv').style.bottom = "0px"
}
var ajax1 = new XMLHttpRequest();
ajax1.open("POST", "https://greebox.app/widget/request.php", true);
ajax1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax1.send("widget="+ widget_id+"&increment=true");
};
}
}else {
wimg.src = icon_style;
wbot.style.width = icon_size+"px";
wimg.style.width = "100%";
if (position == "left") {
wbot.style.left = "17px";
box.style.left = "0px";
boxapp.innerHTML = " X
Olá! Como deseja
falar conosco?
";
if (is_invitation == 1 && sessionStorage.getItem('invitation_x') <= invitation_times) {
sessionStorage.setItem('invitation_x', parseInt(sessionStorage.getItem('invitation_x')) + 1);
wbot.innerHTML = "";
setTimeout(function(){
document.getElementById('proactiveinvitation').style.bottom = "72px";
document.querySelector('.closeinvitation').onclick = function(){
document.querySelector('.proactiveinvitation').style.display = "none";
}
}, invitation_sec)
}
}else {
wbot.style.right = "17px";
boxapp.innerHTML = " X
Olá! Como deseja
falar conosco?
"
if (is_invitation == 1 && sessionStorage.getItem('invitation_x') <= invitation_times ) {
wbot.innerHTML = "";
sessionStorage.setItem('invitation_x', parseInt(sessionStorage.getItem('invitation_x')) + 1);
setTimeout(function(){
document.getElementById('proactiveinvitation').style.bottom = "72px";
document.querySelector('.closeinvitation').onclick = function(){
document.querySelector('.proactiveinvitation').style.display = "none";
}
}, invitation_sec)
}
}
if (widgetType == 0) {
wimg.onclick = function() {
window.open(linksA, '_blank');
var ajax1 = new XMLHttpRequest();
ajax1.open("POST", "https://greebox.app/widget/request.php", true);
ajax1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax1.send("widget="+ widget_id+"&increment=true");
};
}else {
wimg.onclick = function() {
if (document.querySelector('#mainwwpjv').style.bottom == '-313px') {
document.querySelector('#mainwwpjv').style.bottom = "0px"
}else {
document.querySelector('#mainwwpjv').style.bottom = "0px"
}
var ajax1 = new XMLHttpRequest();
ajax1.open("POST", "https://greebox.app/widget/request.php", true);
ajax1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax1.send("widget="+ widget_id+"&increment=true");
};
}
}
wbot.style.position = "fixed";
wbot.style.bottom = bottomPosition;
wbot.style.borderRadius = "50px";
wbot.style.zIndex = "16000000";
wbot.target = "_blank";
wbot.style.cursor = "pointer";
wbot.href = "https://web.whatsapp.com/send?phone=55" + number + "&text=" + greeting_message;
//boxstyle
box.style.position = "absolute";
box.style.top = "600px";
box.style.right = "0px";
box.style.background = "transparent";
box.style.transition = "0.4s";
body.appendChild(wbot);
body.appendChild(boxapp);
wbot.appendChild(wimg);
wbot.appendChild(box);
document.querySelector('#mainwwpjv').style.transition = "0.4s";
document.querySelector('#mainwwpjv').style.zIndex = "160000000";
//
document.querySelector('#closebox').onclick = function(){
document.querySelector('#mainwwpjv').style.bottom = "-700px";
}
if (document.querySelector('#jivopen') !== null ) {
document.querySelector('#jivopen').onclick = function(){
jivo_api.open();
document.querySelector('#mainwwpjv').style.bottom = "-700px";
}
}
//Form
if (widgetType == 2 && localStorage.getItem('leadSet56') != 1) {
const btns56 = document.querySelectorAll('.capturelead');
btns56.forEach((btn56) =>
btn56.addEventListener("click", function(){
const num56 = document.querySelectorAll('.capturelead').length;
for (let index = 0; index < num56; index++) {
document.querySelectorAll('.capturelead')[index].style.display = "none"
document.querySelector('.formlead56').style.display = "block"
}
setTimeout(function(){
document.querySelector('.formlead56').style.top = "0px"
}, 50)
})
);
const btnsend = document.querySelector('#sendlead56');
btnsend.addEventListener("click", function(){
var nomeLead56 = document.querySelector('input[name="namelead56"]');
var emailLead56 = document.querySelector('input[name="emaillead56"]');
var telefoneLead56 = document.querySelector('input[name="telefonelead56"]');
var inputerror56 = document.querySelector('#inputerror56');
if (nomeLead56.value != '' && emailLead56.value != '' && telefoneLead56.value != '') {
if( emailLead56.value.indexOf('@')==-1 || emailLead56.value.indexOf('.')==-1 ){
inputerror56.innerText = 'Email inválido*';
inputerror56.style.display = 'block';
}else{
var ajax56 = new XMLHttpRequest();
ajax56.open("POST", "https://greebox.app/widget/setlead/", true);
ajax56.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax56.send("widget="+widget_id+"&namelead565="+nomeLead56.value+"&emaillead565="+emailLead56.value+"&phonelead565="+telefoneLead56.value);
ajax56.onreadystatechange = function() {
if (ajax56.readyState == 4 && ajax56.status == 200) {
var datasetl56 = JSON.parse(this.responseText);
if (datasetl56.set == 'valid') {
const num56 = document.querySelectorAll('.contactsent').length;
for (let index = 0; index < num56; index++) {
document.querySelectorAll('.contactsent')[index].style.display = "block"
document.querySelector('.contactsentmessage').style.display = "block"
document.querySelector('.formlead56').style.display = "none"
localStorage.setItem('leadSet56', '1')
setTimeout(function(){
document.querySelector('.contactsentmessage').style.transform = "scale(1.2)";
}, 50)
setTimeout(function(){
document.querySelector('.contactsentmessage').style.transform = "scale(1.0)";
}, 1000)
}
}
}
}
}
}else if (nomeLead56.value == '' && emailLead56.value == '' && telefoneLead56.value == '') {
nomeLead56.style.borderBottom = 'solid red 1.5px';
emailLead56.style.borderBottom = 'solid red 1.5px';
telefoneLead56.style.borderBottom = 'solid red 1.5px';
inputerror56.innerText = 'Todos os campos são obrigatórios*';
inputerror56.style.display = 'block';
}else if (nomeLead56.value == '') {
nomeLead56.style.borderBottom = 'solid red 1.5px';
inputerror56.innerText = 'Todos os campos são obrigatórios*';
inputerror56.style.display = 'block';
}else if (emailLead56.value == '') {
emailLead56.style.borderBottom = 'solid red 1.5px';
inputerror56.innerText = 'Todos os campos são obrigatórios*';
inputerror56.style.display = 'block';
}else if (telefoneLead56.value == '') {
telefoneLead56.style.borderBottom = 'solid red 1.5px';
inputerror56.innerText = 'Todos os campos são obrigatórios*';
inputerror56.style.display = 'block';
}
})
}else {
const num56 = document.querySelectorAll('.contactsent').length;
for (let index = 0; index < num56; index++) {
document.querySelectorAll('.contactsent')[index].style.display = "block";
}
const num565 = document.querySelectorAll('.capturelead').length;
for (let index2 = 0; index2 < num565; index2++) {
document.querySelectorAll('.capturelead')[index2].style.display = "none"
}
try {
document.querySelector('.contactsentmessage').style.display = "none"
} catch(e) {
}
}
try {
document.querySelector('.anwrgreebx').addEventListener('click', () => {
wimg.click()
})
} catch(e) {
// statements
}
}
if (!sessionStorage.getItem('widgetisset')) {
var ajax = new XMLHttpRequest();
ajax.open("POST", "https://greebox.app/widget/request.php", true);
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax.send("widget="+ widget_id + "&site=" + window.location.host);
ajax.onreadystatechange = function() {
if(document.getElementsByClassName('wbotmain').length == 1) {
return;
}
if (ajax.readyState == 4 && ajax.status == 200) {
var dataw = JSON.parse(this.responseText);
sessionStorage.setItem('widgetisset', 'true');
var numberSet = sessionStorage.setItem('number', dataw.phone);
var greetingSet = sessionStorage.setItem('greeting_message', dataw.preset_message);
var positionSet = sessionStorage.setItem('position', dataw.position);
var bottomPosition = sessionStorage.setItem('vertical_align', dataw.vertical_align);
var links = sessionStorage.setItem('links', dataw.links);
var widget_type = sessionStorage.setItem('widget_type', dataw.widget_type);
var work_hours = sessionStorage.setItem('work_hours', dataw.work_hours);
var is_invitation = sessionStorage.setItem('is_invitation', dataw.is_invitation);
var invitation = sessionStorage.setItem('invitation', dataw.invitation);
var invitation_sec = sessionStorage.setItem('invitation_sec', dataw.invitation_sec);
var invitation_times = sessionStorage.setItem('invitation_times', dataw.invitation_times);
var greeting_message = sessionStorage.setItem('greeting_message', dataw.greeting_message);
var icon_style = sessionStorage.setItem('icon_style', dataw.icon_style);
var icon_size = sessionStorage.setItem('icon_size', dataw.icon_size);
var icon_size_mobile = sessionStorage.setItem('icon_size_mobile', dataw.icon_size_mobile);
if (dataw.widget_invalid !== 'invalid') {
prinwpp(dataw.phone,
dataw.preset_message,
dataw.position,
dataw.vertical_align,
dataw.links,
dataw.widget_type,
dataw.work_hours,
dataw.is_invitation,
dataw.invitation,
dataw.invitation_sec,
dataw.invitation_times,
dataw.greeting_message,
dataw.icon_style,
dataw.icon_size,
dataw.icon_size_mobile);
}
}
}
}else {
prinwpp(sessionStorage.getItem('number'),
sessionStorage.getItem('greeting_message'),
sessionStorage.getItem('position'),
sessionStorage.getItem('vertical_align'),
sessionStorage.getItem('links'),
sessionStorage.getItem('widget_type'),
sessionStorage.getItem('work_hours'),
sessionStorage.getItem('is_invitation'),
sessionStorage.getItem('invitation'),
sessionStorage.getItem('invitation_sec'),
sessionStorage.getItem('invitation_times'),
sessionStorage.getItem('greeting_message'),
sessionStorage.getItem('icon_style'),
sessionStorage.getItem('icon_size'),
sessionStorage.getItem('icon_size_mobile')
);
}
function open_greebox(){
document.querySelector('.wbotmain img').click();
}