var lf_chatbot_token = '0834274ac3c28e0d23e2b0c90285cc79' var lf_chatbot_leadID = '193691623' var lf_formulario = '0' var lf_chatbot_root = 'https://chat.leadforce.com.br/' var lf_chatbot_atendente_avatar = 'https://chat.leadforce.com.br/assets/chat-0834274ac3c28e0d23e2b0c90285cc79/atendente2.jpg' var lf_chatbot_atendente_nome = 'Fernanda' var lf_chatbot_atendente_cargo = 'Consultora de Vendas Online' var lf_chatbot_language = 'pt-br' var lf_chatbot_start = 0 var lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_proximo_block_id, lf_chatbot_texto_bloco, lf_chatbot_identificador, chat_login_skip = false, lf_chatbot_ult_msg_timmer = 15000, lf_chatbot_tiping_timmer = 2500, lf_chatbot_device = 'd', lf_chatbot_btn_img, lf_chatbot_autostart_countdown, lf_chatbot_altura, lf_chatbot_isopen; function lf_chatbot_parse_query_string(query) { query = query.replace('?', ''); var vars = query.split("&"); var query_string = {}; for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = decodeURIComponent(pair[1]); // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [query_string[pair[0]], decodeURIComponent(pair[1])]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(decodeURIComponent(pair[1])); } } return query_string; } function lf_chatbot_getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } // if (lf_chatbot_getCookie('lf_chatbot_query_string') == '') { // document.cookie = 'lf_chatbot_query_string=' + location.search // } // console.log('teste'); if (lf_chatbot_getCookie('lf_chatbot_query_string') == '') { let url_params = window.location.href.split('?') console.log("url_params: " + url_params); console.log(url_params[1]); if (typeof url_params[1] === 'undefined') { url_params_filter = ""; }else{ console.log("URL: " + url_params[1]); if (url_params[1].match(/#utm_source/)) { url_params_filter = url_params[1].replace('#utm_source', '&utm_source') console.log("URL2: " + url_params_filter); }else{ url_params_filter = url_params[1]; } } document.cookie = 'lf_chatbot_query_string=' + url_params_filter } var lf_chatbot_query_string = lf_chatbot_getCookie("lf_chatbot_query_string"); console.log("conteudo do cookie: " + lf_chatbot_query_string); var lf_chatbot_parsed_qs = lf_chatbot_parse_query_string(lf_chatbot_query_string); if (screen.width < 1025) { lf_chatbot_device = 'm'; } if (screen.width < 768) { lf_chatbot_btn_img = lf_chatbot_root + 'assets/chat-' + lf_chatbot_token + '/lf_chatbot_btninicial_mobile.png'; } else { lf_chatbot_btn_img = lf_chatbot_root + 'assets/chat-' + lf_chatbot_token + '/lf_chatbot_btninicial.png'; } // Identifica o idioma cadastrado no chatbot. var arr_idioma = { "loadingMessage" : "Digitando", "footerText" : "Nós usamos a", "confirmText": "Você deseja", "btnClose" : "Encerrar", "btnMinimize" : "Minimizar", "selectLabel" : "Selecione acima", "thank" : "Obrigado pela preferência!", "account_for" : "Vamos analisar esse diálogo e em breve retornaremos.", "shutdown_message" : "Esta conversa fechará automaticamente
em ", "time" : "segundos." } if (lf_chatbot_language == 'en') { arr_idioma = { "loadingMessage" : "Typing", "footerText" : "We use the", "confirmText" : "You wish", "btnClose" : "Close", "btnMinimize" : "Minimize", "selectLabel" : "Select above", "thank" : "Thank you for your preference!", "account_for" : "We will analyze this dialogue and soon we will return.", "shutdown_message" : "This conversation will automatically close
on ", "time" : "seconds." } } else if (lf_chatbot_language == 'es') { arr_idioma = { "loadingMessage" : "Tecleando", "footerText" : "Usamos el", "confirmText" : "Quieres", "btnClose" : "Cerrar", "btnMinimize" : "Minimizar", "selectLabel" : "Seleccionar arriba", "thank" : "¡Gracias por la preferencia!", "account_for" : "Analizaremos este diálogo y pronto volveremos.", "shutdown_message" : "Esta conversación se cerrará automáticamente
el ", "time" : "segundos." } } if (lf_formulario == 1) { var lf_chatbot_html = '

' + lf_chatbot_atendente_nome + '

' + lf_chatbot_atendente_cargo + '.

Deseja realmente sair?

'; } var lf_chatbot_html_rebuild = '

' + lf_chatbot_atendente_nome + '

' + lf_chatbot_atendente_cargo + '.

'+arr_idioma.confirmText+'

'; // document.querySelector('.lf_chatbot-container'); var chat_post_data; lf_chatbot_init(); var lf_chatbot_canvas; function lf_chatbot_init() { document.querySelector("head").insertAdjacentHTML('beforeend', '
'); setTimeout(function () { if (lf_formulario == 1) { document.querySelector("body").insertAdjacentHTML('beforeend', lf_chatbot_html); } else { document.querySelector("body").insertAdjacentHTML('beforeend', lf_chatbot_html_rebuild); } if (lf_chatbot_start > 0) { lf_chatbot_autostart_countdown = setTimeout(function () { lf_chatbot_click_events(); var init_btn = document.getElementById("lf_chatbot-init-btn"); lf_chatbot_triggerEvent('click', init_btn); }, lf_chatbot_start); } else { lf_chatbot_click_events(); } }, 2000); } var lf_chatbot_v_obj; var lf_chatbot_v_fun; function lf_chatbot_execmascara(v_obj, v_fun) { v_obj.value = v_fun(v_obj.value) } function chat_submit_request(chat_post_data) { lf_chatbot_canvas = document.getElementById("lf_chatbot-canvas"); var lf_chatbot_post_url = lf_chatbot_root + "ws/" + lf_chatbot_token; var lf_chatbot_post_request = new XMLHttpRequest(); lf_chatbot_post_request.open("POST", lf_chatbot_post_url, true); lf_chatbot_post_request.setRequestHeader("Content-Type", "application/json"); var d = new Date(); var lf_chatbot_bloco_id = d.getTime(); var lf_chatbot_row = '

'+arr_idioma.loadingMessage+'

'; lf_chatbot_canvas.insertAdjacentHTML('beforeend', lf_chatbot_row); //Parar executação do js para teste // throw new Error("Something went badly wrong!"); var lf_chatbot_block_el = document.querySelector("#lf_chatbot_bloco-" + lf_chatbot_bloco_id); lf_chatbot_canvas.scrollTop = lf_chatbot_canvas.scrollHeight; lf_chatbot_post_request.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var chat_json_response = JSON.parse(this.responseText); var chat_main_box = document.getElementById("lf_chatbot-main-box"); // console.log('chat_json_response.script = '+chat_json_response.script); // console.log('chat_json_response = '+this.responseText); lf_chatbot_bloco_atual_id = chat_json_response.blocoID; lf_chatbot_texto_bloco = chat_json_response.texto; lf_chatbot_texto_embed = chat_json_response.embed ? chat_json_response.embed : false; lf_chatbot_bloco_atual_tipo = chat_json_response.tipo_bloco; lf_chatbot_proximo_block_id = chat_json_response.proximo_bloco; lf_chatbot_identificador = chat_json_response.identificador; lf_chatbot_altura = chat_json_response.altura_chat; // console.log(lf_chatbot_bloco_atual_tipo); var lf_chatbot_form_option; if (lf_chatbot_altura == 1) { lf_chatbot_set_height(); document.querySelector(".lf_chatbot-container").setAttribute('lf-chatbot-height', lf_chatbot_altura) } setTimeout(function () { lf_chatbot_block_el.querySelector("p").innerHTML = lf_chatbot_texto_bloco; lf_chatbot_canvas.scrollTop = lf_chatbot_canvas.scrollHeight; switch (lf_chatbot_bloco_atual_tipo) { case 1: if (lf_chatbot_proximo_block_id != 0) { chat_post_data = lf_chatbot_create_postdada(lf_chatbot_leadID, lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_proximo_block_id); chat_submit_request(chat_post_data); } else if (chat_login_skip == true && lf_chatbot_proximo_block_id == 0) { setTimeout(function () { document.querySelector("#lf_chatbot-canvas-outter").style.display = "none"; var lf_chatbot_end_form = '

' + lf_chatbot_atendente_nome + '

' + lf_chatbot_atendente_cargo + '.

Para finalizar,

por gentileza, informe seus dados:

'; document.querySelector("#lf_chatbot-content").innerHTML = lf_chatbot_end_form; var chat_login_block_end = document.querySelector("#lf_chatbot-login-end-btn"); chat_login_block_end.addEventListener("click", function (e) { e.preventDefault(); var chat_client_nome = document.querySelector("#lf_chat_client_nome_end"), chat_client_email = document.querySelector("#lf_chat_client_email_end"); if (chat_login_submit(chat_client_nome, chat_client_email)) { chat_client_nome = chat_client_nome.value; chat_client_email = chat_client_email.value; chat_post_data = { "leadID": lf_chatbot_leadID, "nome": chat_client_nome, "email": chat_client_email, "tipo_bloco": 0 }; chat_post_data = JSON.stringify(chat_post_data); fadeIn(document.querySelector("#lf_chatbot-login-mask"), 0.3); setTimeout(function () { lf_chatbot_post_request.open("POST", lf_chatbot_post_url, true); lf_chatbot_post_request.setRequestHeader("Content-Type", "application/json"); lf_chatbot_post_request.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { lf_chatbot_send_final(); setTimeout(function () { var lf_chatbot_end_screen = '

'+arr_idioma.thank+'

'+arr_idioma.account_for+'

'+arr_idioma.shutdown_message+' 10 '+arr_idioma.time+'.

'; document.querySelector("#lf_chatbot-content").innerHTML = lf_chatbot_end_screen; fadeIn(document.querySelector(".lf_chatbot-endscreen"), 0.3); var lf_chatbot_countdown_el = document.querySelector("#lf_chatbot-countdown"); var lf_chatbot_countdown_val = parseInt(lf_chatbot_countdown_el.innerHTML); var lf_chatbot_countdown_loop = setInterval(function () { lf_chatbot_countdown_val -= 1; lf_chatbot_countdown_el.innerHTML = lf_chatbot_countdown_val; if (lf_chatbot_countdown_val == 0) { clearInterval(lf_chatbot_countdown_loop); chat_login_skip = false; lf_chatbot_close(); } }, 1000); }, 1500); } }; lf_chatbot_post_request.send(chat_post_data); }, 300); } }); }, lf_chatbot_ult_msg_timmer); } else { lf_chatbot_send_final(); setTimeout(function () { var lf_chatbot_end_screen = '

'+arr_idioma.thank+'

'+arr_idioma.account_for+'

'+arr_idioma.shutdown_message+' 10 '+arr_idioma.time+'

'; document.querySelector("#lf_chatbot-canvas-outter").innerHTML = lf_chatbot_end_screen; fadeIn(document.querySelector(".lf_chatbot-endscreen"), 0.3); var lf_chatbot_countdown_el = document.querySelector("#lf_chatbot-countdown"); var lf_chatbot_countdown_val = parseInt(lf_chatbot_countdown_el.innerHTML); var lf_chatbot_countdown_loop = setInterval(function () { lf_chatbot_countdown_val -= 1; lf_chatbot_countdown_el.innerHTML = lf_chatbot_countdown_val; if (lf_chatbot_countdown_val == 0) { clearInterval(lf_chatbot_countdown_loop); lf_chatbot_close(); } }, 1000); }, lf_chatbot_ult_msg_timmer); } // Aqui executa o tag script cadastrada na criação do diálogo. if (chat_json_response.script != null) { eval(chat_json_response.script); } break; case 2: var lf_chatbot_mask_chat_options = document.querySelector("#lf_chatbot-mask-chat-options"); lf_chatbot_form_option = document.querySelector("#lf_chatbot-canvas-form"); lf_chatbot_form_option.innerHTML = '
' + '
' + '
'; if (lf_chatbot_identificador == 'telefone') { function lf_chatbot_mascara(o, f) { lf_chatbot_v_obj = o; lf_chatbot_v_fun = f; setTimeout("lf_chatbot_execmascara(lf_chatbot_v_obj,lf_chatbot_v_fun)", 1); } function lf_chatbot_mtel(v) { 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 return v; } function lf_chatbot_id(el) { return document.getElementById(el); } lf_chatbot_id("lf_chatbot-canvas-form-input-" + lf_chatbot_bloco_atual_id).onkeyup = function () { this.maxLength = 15; lf_chatbot_mascara(this, lf_chatbot_mtel); } } // fadeIn(lf_chatbot_mask_chat_options, 0.1); var lf_chatbot_btn_responder = document.querySelector(".lf_chatbot-btn"); lf_chatbot_btn_responder.addEventListener("click", function (e) { e.preventDefault(); var lf_chatbot_form_value_el = lf_chatbot_btn_responder.parentNode; lf_chatbot_form_value_el = lf_chatbot_form_value_el.querySelector("#lf_chatbot-canvas-form-input-" + lf_chatbot_bloco_atual_id); switch (lf_chatbot_identificador) { case 'nome': lf_chatbot_validate_post(lf_chatbot_form_value_el, 'text'); break; case 'email': lf_chatbot_validate_post(lf_chatbot_form_value_el, 'email'); break; case 'telefone': lf_chatbot_validate_post(lf_chatbot_form_value_el, 'telefone'); break; default: lf_chatbot_validate_post(lf_chatbot_form_value_el, 'text_mix'); } // Aqui executa o tag script cadastrada na criação do diálogo. if (chat_json_response.script != null) { eval(chat_json_response.script); } // fadeOut(lf_chatbot_mask_chat_options, 0.1); }); break; case 7: var lf_chatbot_mask_chat_options = document.querySelector("#lf_chatbot-mask-chat-options"); // if (lf_chatbot_embed_box != null) { // lf_chatbot_embed_box.remove() // } var lf_chatbot_embed = ''; lf_chatbot_form_option = document.querySelector("#lf_chatbot-canvas-form"); lf_chatbot_form_option.innerHTML = '
' + '

Continuar diálogo

' + '
'; // Faz a verificação da posição do chat e abre o container do iframe na posição oposta. var box_embed = document.querySelector('.lf_chatbot-container'); var box_embed_style = getComputedStyle(box_embed); if ( box_embed_style.right === '0px' ) { lf_chatbot_embed = "
" + lf_chatbot_texto_embed + "
X
"; } else { lf_chatbot_embed = "
" + lf_chatbot_texto_embed + "
X
" } // if (lf_chatbot_texto_embed != false) // { chat_main_box.insertAdjacentHTML('beforeend', lf_chatbot_embed); var lf_chatbot_embed_height = document.querySelector('#lf_chatbot_embed-container'); setTimeout(function() { fadeIn(document.querySelector("#lf_chatbot_embed-container"), 0.3); }, 500) setTimeout(function() { var lf_chatbot_height_embed_box = lf_chatbot_embed_height.offsetHeight lf_chatbot_embed_height.style.height = lf_chatbot_height_embed_box + 'px' }, 1200) var lf_chatbot_close_embed = document.querySelector('.lf_chatbot_close_embed'); lf_chatbot_close_embed.addEventListener("click", function (e) { var lf_chatbot_trigger_embed_element = document.querySelector('.lf_chatbot-trigger-embed'); lf_chatbot_triggerEvent('click', lf_chatbot_trigger_embed_element); }) // fadeIn(lf_chatbot_mask_chat_options, 0.1); var lf_chatbot_btn_responder = document.querySelector(".lf_chatbot-btn"); lf_chatbot_btn_responder.addEventListener("click", function (e) { fadeOut(document.querySelector("#lf_chatbot_embed-container"), 0.3); e.preventDefault(); var lf_chatbot_embed_box = document.querySelector('#lf_chatbot_embed-container'); lf_chatbot_embed_box.remove() var lf_chatbot_form_value_el = lf_chatbot_btn_responder.parentNode; lf_chatbot_form_value_el = lf_chatbot_form_value_el.querySelector("#lf_chatbot-canvas-form-input-" + lf_chatbot_bloco_atual_id); // lf_chatbot_validate_post(lf_chatbot_form_value_el, 'text'); var lf_chatbot_form_value_text = lf_chatbot_form_value_el.value; chat_post_data = lf_chatbot_create_postdada(lf_chatbot_leadID, lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_proximo_block_id, lf_chatbot_form_value_text); setTimeout(function () { chat_submit_request(chat_post_data); }, 1000); }); // } // Aqui executa o tag script cadastrada na criação do diálogo. if (chat_json_response.script != null) { eval(chat_json_response.script); } break; case 3: var lf_chatbot_options = chat_json_response.respostas; var lf_chatbot_container = document.getElementById("#lf_chatbot_container"); var lf_chatbot_container_cls = document.querySelector(".lf_chatbot-container"); lf_chatbot_form_option = document.querySelector("#lf_chatbot-canvas-form"); lf_chatbot_form_option.innerHTML = '
' + '
'+arr_idioma.selectLabel+'
'; var lf_chatbot_form_option_atual = document.querySelector("#lf_chatbot-drop-" + lf_chatbot_bloco_atual_id); if (chat_json_response.tipo == "botoes") { lf_chatbot_form_option_atual.classList.add('lf_chatbot-botoes'); for (var i = 0; i < lf_chatbot_options.length; i++) { var lf_chatbot_option_text = lf_chatbot_options[i].texto; var lf_chatbot_option_proximo_block = lf_chatbot_options[i].proximo_bloco; lf_chatbot_form_option_atual.insertAdjacentHTML('beforeend', '
  • ' + lf_chatbot_option_text + '
  • ') } } else { for (var i = 0; i < lf_chatbot_options.length; i++) { // Condição para listar as lojas por região setadas no cookie do site. if (typeof chat_json_response.identificador !== 'undefined' && chat_json_response.identificador == 'unidade') { var options_unidades = remove_acentos(lf_chatbot_options[i].texto.toLowerCase()); if (options_unidades.match(remove_acentos(lf_chatbot_getCookie('REGIAO')))) { var lf_chatbot_option_text = lf_chatbot_options[i].texto; var lf_chatbot_option_proximo_block = lf_chatbot_options[i].proximo_bloco; lf_chatbot_form_option_atual.insertAdjacentHTML('beforeend', '
  • ' + lf_chatbot_option_text + '
  • ') } else { // Poderíamos colocar aqui uma mensagem para verificar ser há alguma loja cadastrada no mkt para esta região // ou se parte do nome da loja coincide com o cookie. } } else { var lf_chatbot_option_text = lf_chatbot_options[i].texto; var lf_chatbot_option_proximo_block = lf_chatbot_options[i].proximo_bloco; lf_chatbot_form_option_atual.insertAdjacentHTML('beforeend', '
  • ' + lf_chatbot_option_text + '
  • ') } } } lf_chabot_select(); var lf_chatbot_btn_responder = document.querySelector(".lf_chatbot-canvas-form-options-drop"); lf_chatbot_btn_responder.addEventListener("click", function (e) { // e.preventDefault(); var lf_chatbot_form_value_el = lf_chatbot_btn_responder.parentNode; lf_chatbot_form_value_el = lf_chatbot_form_value_el.querySelector(".lf_chatbot-canvas-form-input-fake"); var lf_chatbot_form_value_text = lf_chatbot_form_value_el.innerHTML; var lf_chatbot_form_value_proximo_bloco = lf_chatbot_form_value_el.getAttribute("data-lfchatbot-proximo-bloco"); if (lf_chatbot_form_value_text != arr_idioma.selectLabel) { lf_chatbot_write_answer(lf_chatbot_form_value_text); chat_post_data = lf_chatbot_create_postdada(lf_chatbot_leadID, lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_form_value_proximo_bloco, lf_chatbot_form_value_text); setTimeout(function () { chat_submit_request(chat_post_data); }, 2000); } }); function lf_chatbot_validate_load() { var chat_isOpen = lf_chatbot_hasClass(lf_chatbot_container_cls, 'lf_chatbot_open'); if (chat_isOpen) { // Abre o menu de opçoes do diálogo automaticamente. setTimeout(function () { var chat_option_drop = document.querySelector(".lf_chatbot-canvas-form-options-drop"); if (!isVisible(chat_option_drop)) { // lf_chatbot_triggerEvent('click', lf_chatbot_btn_responder); } }, 5000); } } var lf_chatbot_select_load = document.querySelector('.lf_chatbot-canvas-form-options-drop'); lf_chatbot_select_load.addEventListener("load", lf_chatbot_validate_load()); // Aqui executa o tag script cadastrada na criação do diálogo. if (chat_json_response.script != null) { eval(chat_json_response.script); } break; default: } }, lf_chatbot_tiping_timmer); } }; lf_chatbot_post_request.send(chat_post_data); } function lf_chatbot_triggerEvent(event, elem) { var evt = document.createEvent('HTMLEvents'); evt.initEvent(event, true, true); elem.dispatchEvent(evt); } function lf_chatbot_validate_post(lf_chatbot_form_value_el, input_type) { if (chat_input_validate(lf_chatbot_form_value_el, input_type)) { var lf_chatbot_form_value_text = lf_chatbot_form_value_el.value; lf_chatbot_write_answer(lf_chatbot_form_value_text); chat_post_data = lf_chatbot_create_postdada(lf_chatbot_leadID, lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_proximo_block_id, lf_chatbot_form_value_text); // console.log('lf_chatbot_leadID = '+lf_chatbot_leadID); // console.log('lf_chatbot_bloco_atual_id = '+lf_chatbot_bloco_atual_id); // console.log('lf_chatbot_bloco_atual_tipo = '+lf_chatbot_bloco_atual_tipo); // console.log('lf_chatbot_proximo_block_id = '+lf_chatbot_proximo_block_id); // console.log('lf_chatbot_form_value_text = '+lf_chatbot_form_value_text); setTimeout(function () { chat_submit_request(chat_post_data); }, 2000); } } function lf_chatbot_write_answer(lf_chatbot_answer) { var lf_chatbot_row = '

    ' + lf_chatbot_answer + '

    '; //lf_chatbot_canvas.innerHTML += lf_chatbot_row; lf_chatbot_canvas.insertAdjacentHTML('beforeend', lf_chatbot_row); var lf_chatbot_form_container = document.querySelector("#lf_chatbot-canvas-form"); lf_chatbot_form_container.innerHTML = ""; lf_chatbot_canvas.scrollTop = lf_chatbot_canvas.scrollHeight; } function lf_chatbot_create_postdada(lf_chatbot_leadID, lf_chatbot_bloco_atual_id, lf_chatbot_bloco_atual_tipo, lf_chatbot_proximo_block_id, lf_chatbot_resposta) { chat_post_data = { "leadID": lf_chatbot_leadID, "blocoID": lf_chatbot_bloco_atual_id, "tipo_bloco": lf_chatbot_bloco_atual_tipo, "proximo_bloco": lf_chatbot_proximo_block_id, "resposta": lf_chatbot_resposta }; chat_post_data = JSON.stringify(chat_post_data); return chat_post_data; } function lf_chatbot_send_final() { if (lf_chatbot_leadID > 0) { var lf_chatbot_post_url = lf_chatbot_root + "ws/finaliza_chat/" + lf_chatbot_leadID; var lf_chatbot_post_request = new XMLHttpRequest(); lf_chatbot_post_request.open("POST", lf_chatbot_post_url, true); lf_chatbot_post_request.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var chat_json_response = JSON.parse(this.responseText); lf_chatbot_leadID = chat_json_response.leadID; } } lf_chatbot_post_request.send(); } } function lf_chatbot_close() { var chat_main_box = document.getElementById("lf_chatbot-main-box"); slideUp(chat_main_box, 200); var lf_chabot_container = document.querySelector(".lf_chatbot-container"); var lf_chabot_container_mask = document.querySelector("#lf_chatbot-outter-mask"); fadeOut(lf_chabot_container_mask, 0.3); if (chat_login_skip == true && lf_formulario == 1) { setTimeout(function () { lf_chabot_container_mask.parentNode.removeChild(lf_chabot_container_mask); lf_chabot_container.parentNode.removeChild(lf_chabot_container); document.querySelector("body").insertAdjacentHTML('beforeend', lf_chatbot_html); lf_chatbot_click_events(); }, 5000); } else { setTimeout(function () { lf_chabot_container_mask.parentNode.removeChild(lf_chabot_container_mask); lf_chabot_container.parentNode.removeChild(lf_chabot_container); document.querySelector("body").insertAdjacentHTML('beforeend', lf_chatbot_html_rebuild); lf_chatbot_click_events(); }, 3000); } lf_chatbot_leadID = 0; } function lf_chatbot_closebtn_event() { var close_btn = document.getElementById("lf_chatbot-close"), chat_content = document.getElementById("lf_chatbot-content"), chat_mask_close_confirm = document.getElementById("lf_chatbot-mask-confirm"), chat_mask_close_confirm_yes = document.getElementById("lf_chatbot-close-confirm-yes"), chat_mask_close_confirm_no = document.getElementById("lf_chatbot-close-confirm-no"), minimize_btn = document.querySelector(".lf_chatbot-minimize"), chat_container = document.querySelector(".lf_chatbot-container"); close_btn.addEventListener("click", function () { chat_content = document.getElementById("lf_chatbot-content"); var chat_content_display = chat_content.style.display; if (chat_content_display == "none") { slideDown(chat_content, 200); fadeIn(document.querySelector("#lf_chatbot-outter-mask"), 0.3); } fadeIn(chat_mask_close_confirm, 0.3); }); chat_mask_close_confirm_no.addEventListener("click", function () { fadeOut(chat_mask_close_confirm, 0.3); minimize_btn.classList.add('lf_chatbot-close'); slideUp(chat_content, 200); fadeOut(document.querySelector("#lf_chatbot-outter-mask"), 0.3); chat_container.classList.remove('lf_chatbot_open'); var chat_isOpen = lf_chatbot_hasClass(chat_container, 'lf_chatbot_open'); }); chat_mask_close_confirm_yes.addEventListener("click", function () { lf_chatbot_send_final(); lf_chatbot_close(); }); } function lf_chatbot_hasClass(elem, cls) { return (' ' + elem.className + ' ').indexOf(' ' + cls + ' ') > -1; } function lf_chatbot_click_events() { var init_btn = document.getElementById("lf_chatbot-init-btn"), close_btn = document.getElementById("lf_chatbot-close"), minimize_btn = document.getElementById("lf_chatbot-minimize"), login_btn = document.getElementById("lf_chatbot-login-btn"), skip_login_btn = document.getElementById("lf_chatbot-login-skip"), chat_main_box = document.getElementById("lf_chatbot-main-box"), chat_content = document.getElementById("lf_chatbot-content"), chat_mask_close_confirm = document.getElementById("lf_chatbot-mask-confirm"), chat_mask_close_confirm_yes = document.getElementById("lf_chatbot-close-confirm-yes"), chat_mask_close_confirm_no = document.getElementById("lf_chatbot-close-confirm-no"), chat_login_block = document.getElementById("lf_chatbot-login"), chat_container = document.querySelector(".lf_chatbot-container"); init_btn.addEventListener("click", function () { var chat_responder = document.querySelector(".lf_chatbot-canvas-form-options-drop"); chat_container.classList.add('lf_chatbot_open'); this.style.display = "none"; fadeIn(document.querySelector("#lf_chatbot-outter-mask"), 0.3); slideDown(chat_main_box, 200); clearInterval(lf_chatbot_autostart_countdown); document.cookie = "lf_chatbot_start=disable"; if (lf_chatbot_leadID == 0) { var lf_chatbot_lead = new XMLHttpRequest(); lf_chatbot_lead.open("POST", lf_chatbot_root + "ws/lead/" + lf_chatbot_token, false); lf_chatbot_lead.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); lf_chatbot_lead.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var result = JSON.parse(this.responseText); lf_chatbot_leadID = result[0]; } }; lf_chatbot_lead.send(); } if (lf_formulario != 1) { chat_post_data = { "leadID": lf_chatbot_leadID, "dispositivo": lf_chatbot_device, "nome_atendente": lf_chatbot_atendente_nome, "utm_source": lf_chatbot_parsed_qs.utm_source, "utm_medium": lf_chatbot_parsed_qs.utm_medium, "utm_campaign": lf_chatbot_parsed_qs.utm_campaign, "utm_content": lf_chatbot_parsed_qs.utm_content, "utm_term": lf_chatbot_parsed_qs.utm_term }; chat_post_data = JSON.stringify(chat_post_data); chat_submit_request(chat_post_data); } }); lf_chatbot_closebtn_event(); minimize_btn.addEventListener("click", function () { var chat_responder = document.querySelector(".lf_chatbot-canvas-form-options-drop"); var chat_active = document.querySelector(".lf_chatbot-canvas-form-input-wrapper"); var chat_content = document.getElementById("lf_chatbot-content"); var chat_icon_wrapper = document.querySelector(".lf_icon-chatbot-wrapper"); var chat_content_display = chat_content.style.display; if (chat_content_display == "none") { //Abre o Chat // chat_icon_wrapper.classList.remove('lf_icon-chatbot-maximize'); // chat_icon_wrapper.classList.add('lf_icon-chatbot-minimize'); minimize_btn.classList.remove('lf_chatbot-close'); slideDown(chat_content, 200); fadeIn(document.querySelector("#lf_chatbot-outter-mask"), 0.3); setTimeout(function () { var chat_value_height = document.querySelector(".lf_chatbot-container").getAttribute("lf-chatbot-height"); if (chat_value_height == 1) { lf_chatbot_set_height(); } }, 250); chat_container.classList.add('lf_chatbot_open'); var chat_isOpen = lf_chatbot_hasClass(chat_container, 'lf_chatbot_open'); if (chat_isOpen) { setTimeout(function () { var chat_option_drop = document.querySelector(".lf_chatbot-canvas-form-options-drop"); if (!isVisible(chat_option_drop)) { lf_chatbot_triggerEvent('click', chat_responder); } }, 5000); } } else { //Minimiza o Chat // chat_icon_wrapper.classList.remove('lf_icon-chatbot-minimize'); // chat_icon_wrapper.classList.add('lf_icon-chatbot-maximize'); minimize_btn.classList.add('lf_chatbot-close'); slideUp(chat_content, 200); fadeOut(document.querySelector("#lf_chatbot-outter-mask"), 0.3); chat_container.classList.remove('lf_chatbot_open'); chat_container.classList.add('full-width'); var chat_isOpen = lf_chatbot_hasClass(chat_container, 'lf_chatbot_open'); } }); if (skip_login_btn != null) { skip_login_btn.addEventListener("click", function () { chat_post_data = { "leadID": lf_chatbot_leadID }; chat_post_data = JSON.stringify(chat_post_data); chat_login_skip = true; var chat_avatar = document.getElementById("lf_chatbot-avatar"); lf_chatbot_addClass(chat_avatar, "lf_chatbot-avatar-top"); var chat_avatar_info = document.getElementById("lf_chatbot-consultant-info"); lf_chatbot_addClass(chat_avatar_info, "lf_chatbot-consultant-info-top"); fadeOut(chat_login_block, 0.3); setTimeout(function () { document.querySelector("#lf_chatbot-content").innerHTML += ''; chat_submit_request(chat_post_data); lf_chatbot_closebtn_event(); }, 500); }); } if (login_btn != null) { login_btn.addEventListener("click", function (e) { e.preventDefault(); var chat_client_nome = document.querySelector("#lf_chat_client_nome"), chat_client_email = document.querySelector("#lf_chat_client_email"), chat_login_step = 0; if (chat_login_submit(chat_client_nome, chat_client_email)) { chat_client_nome = chat_client_nome.value; chat_client_email = chat_client_email.value; chat_post_data = { "leadID": lf_chatbot_leadID, "nome": chat_client_nome, "email": chat_client_email, "tipo_bloco": 0 }; chat_post_data = JSON.stringify(chat_post_data); chat_login_skip = false; fadeIn(document.querySelector("#lf_chatbot-login-mask")); setTimeout(function () { var chat_avatar = document.getElementById("lf_chatbot-avatar"); lf_chatbot_addClass(chat_avatar, "lf_chatbot-avatar-top"); var chat_avatar_info = document.getElementById("lf_chatbot-consultant-info"); fadeOut(chat_login_block, 0.3); setTimeout(function () { lf_chatbot_addClass(chat_avatar_info, "lf_chatbot-consultant-info-top"); document.querySelector("#lf_chatbot-content").innerHTML += ''; chat_submit_request(chat_post_data); lf_chatbot_closebtn_event(); }, 500); }, 2000); } }); } } // setInterval(function () { // var lf_chatbot_talk_timer = document.querySelectorAll(".lf_chatbot-balloon-timer"); // if (lf_chatbot_talk_timer != null) { // for (var i = 0; i < lf_chatbot_talk_timer.length; i++) { // var lf_chatbot_tempo_anterior = parseInt(lf_chatbot_talk_timer[i].getAttribute("data-timer")); // var lf_chatbot_tempo_atual = lf_chatbot_tempo_anterior + 15; // lf_chatbot_talk_timer[i].setAttribute("data-timer", lf_chatbot_tempo_atual); // // var lf_chatbot_tempo_atual_min = Math.floor(lf_chatbot_tempo_atual / 60); // var lf_chatbot_tempo_atual_sec = lf_chatbot_tempo_atual % 60; // // if (lf_chatbot_tempo_atual_sec == 0) { // lf_chatbot_tempo_atual_sec = "00"; // } // lf_chatbot_talk_timer[i].querySelector("span").innerHTML = "há " + lf_chatbot_tempo_atual_min + ":" + lf_chatbot_tempo_atual_sec + " min"; // } // } // }, 15000); //controle dos selects function lf_chabot_select() { var chat_option_btn = document.querySelectorAll(".lf_chatbot-canvas-form-option-btn"); for (var i = 0; i < chat_option_btn.length; i++) { chat_option_btn[i].addEventListener("click", function () { lf_chatbot_addClass(this, "active"); var chat_option_drop = this.querySelector(".lf_chatbot-canvas-form-options-drop"); var lf_chatbot_mask_chat_options = document.querySelector("#lf_chatbot-mask-chat-options"); if (isVisible(chat_option_drop)) { slideUp(chat_option_drop, 100); // fadeOut(lf_chatbot_mask_chat_options, 0.1); lf_chatbot_removeClass(this, "active"); } else { slideDown(chat_option_drop, 100); setTimeout(function () { chat_option_drop.style.overflow = "auto"; }, 110); // fadeIn(lf_chatbot_mask_chat_options, 0.1); } var chat_option_selected = document.querySelectorAll(".lf_chatbot-canvas-form-option"); for (var j = 0; j < chat_option_selected.length; j++) { chat_option_selected[j].addEventListener("click", function (event) { var lf_chatbot_proximo_bloco = this.getAttribute("data-lfchatbot-proximo-bloco"); var inputbox = this.parentNode.parentNode.querySelector(".lf_chatbot-canvas-form-input-fake"); inputbox.innerHTML = this.innerHTML; inputbox.setAttribute("data-lfchatbot-proximo-bloco", lf_chatbot_proximo_bloco); lf_chatbot_removeClass(this.parentNode.parentNode, "active"); }); } }); } } //controle dos selects /end function chat_login_submit(chat_client_nome, chat_client_email) { if (chat_input_validate(chat_client_nome, "text") && chat_input_validate(chat_client_email, "email")) { var chat_client_nome_text = chat_client_nome.value, chat_client_email_text = chat_client_email.value; return true; } } function chat_input_validate(chat_input, chat_validation_type) { var chat_input_text = chat_input.value; var chat_input_parent = chat_input.parentNode; var chat_validate_return = false; switch (chat_validation_type) { case "text": if (chat_input_text == '' || chat_input_text == null) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.innerHTML += '- Preenchimento obrigatório.'; } else if (!chat_input_text.match(/^[A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]*$/)) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.innerHTML += '- Não são permitidos números.'; } else { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_validate_return = true; } break; case "text_mix": if (chat_input_text == '' || chat_input_text == null) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.innerHTML += '- Preenchimento obrigatório.'; } else { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_validate_return = true; } break; case "email": if (chat_input_text == '' || chat_input_text == null) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.innerHTML += '- Preenchimento obrigatório.'; } else if (!chat_input_text.match(/^(([^<>()[\]\\.,;:\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,}))$/)) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.innerHTML += '- Informe um e-mail válido.'; } else { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_validate_return = true; } break; case "telefone": if (chat_input_text == '' || chat_input_text == null) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.insertAdjacentHTML('beforeend', '- Preenchimento obrigatório.') } else if (!chat_input_text.match(/^\([1-9]{2}\) (?:[2-8]|9[1-9])[0-9]{3}\-[0-9]{4}$/)) { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_input_parent.insertAdjacentHTML('beforeend', '- Informe um telefone válido.'); } else { if (chat_input_parent.querySelector(".lf_chatbot_error_message") != null) { chat_input_parent.removeChild(chat_input_parent.querySelector(".lf_chatbot_error_message")); } chat_validate_return = true; } break; default: } return chat_validate_return; } //EFEITOS /* fadeIn fadeOut */ function fadeIn(element, time) { process_fade(element, time, 0, 100); } function fadeOut(element, time) { process_fade(element, time, 100, 0); } function process_fade(element, time, initial, end) { if (initial == 0) { var increment = 2; } else { increment = -2; } var opc = initial; var interval = setInterval(function () { if ((opc == end)) { if (end == 0) { element.style.display = "none"; } clearInterval(interval); } else { opc += increment; element.style.opacity = opc / 100; element.style.filter = "alpha(opacity=" + opc + ")"; element.style.display = "block"; } }, time * 10); } /* fadeIn fadeOut /end */ function lf_chatbot_set_height() { var lf_chatbot_window_height; if (lf_media_query(1024).matches) { lf_chatbot_window_height = (window.innerHeight - 80); } else { lf_chatbot_window_height = (window.innerHeight - 120); } var lf_chatbot_container = document.querySelector(".lf_chatbot-container"); lf_chatbot_container.classList.add("lf_chatbot-height"); var lf_chatbot_newheight = lf_chatbot_container.querySelector(".lf_chatbot-height .lf_chatbot-content"); lf_chatbot_newheight.style.height = lf_chatbot_window_height + "px"; } function lf_media_query(value) { var lf_media_query = window.matchMedia("(max-width:" + value + "px)") return lf_media_query; } /* slidedown/up */ function morph(element, options, animationTime, callback) { // options is an array with the same structural of Properties and DiffValues and which contains the properties values we want the animation make var ComputedElementStyle = window.getComputedStyle(element, null); var AttrElementStyle = element.style; var Properties = { // the actuals computed properties width: parseInt(ComputedElementStyle.getPropertyValue("width")), height: parseInt(ComputedElementStyle.getPropertyValue("height")), padding: { top: parseInt(ComputedElementStyle.getPropertyValue("padding-top")), right: parseInt(ComputedElementStyle.getPropertyValue("padding-right")), bot: parseInt(ComputedElementStyle.getPropertyValue("padding-bottom")), left: parseInt(ComputedElementStyle.getPropertyValue("padding-left")) }, margin: { top: parseInt(ComputedElementStyle.getPropertyValue("margin-top")), right: parseInt(ComputedElementStyle.getPropertyValue("margin-right")), bot: parseInt(ComputedElementStyle.getPropertyValue("margin-bottom")), left: parseInt(ComputedElementStyle.getPropertyValue("margin-left")) } }; var DiffValues = { // the differences between actual properties values and values we want to width: (options['width'] != null) ? (options['width'] - Properties['width']) : 0, height: (options['height'] != null) ? (options['height'] - Properties['height']) : 0, padding: { top: (options['padding'] && options['padding']['top'] != null) ? options['padding']['top'] - Properties['padding']['top'] : 0, right: (options['padding'] && options['padding']['right'] != null) ? options['padding']['right'] - Properties['padding']['right'] : 0, bot: (options['padding'] && options['padding']['bot'] != null) ? options['padding']['bot'] - Properties['padding']['bot'] : 0, left: (options['padding'] && options['padding']['left'] != null) ? options['padding']['left'] - Properties['padding']['left'] : 0 }, margin: { top: (options['margin'] && options['margin']['top'] != null) ? options['margin']['top'] - Properties['margin']['top'] : 0, right: (options['margin'] && options['margin']['right'] != null) ? options['margin']['right'] - Properties['margin']['right'] : 0, bot: (options['margin'] && options['margin']['bot'] != null) ? options['margin']['bot'] - Properties['margin']['bot'] : 0, left: (options['margin'] && options['margin']['left'] != null) ? options['margin']['left'] - Properties['margin']['left'] : 0 } }; var beginTime = new Date().getTime(); // time at begining of animation animationTime = (animationTime != null) ? animationTime : 250; AttrElementStyle.overflow = "hidden"; // disable the potentials scrollbars var sinceBeginTime; // time since the begining var progressFactor; // coeficient that correspond to the advancement of the animation timer = setInterval(function () { // begin of the animation sinceBeginTime = new Date().getTime() - beginTime; if (sinceBeginTime < animationTime) { progressFactor = sinceBeginTime / animationTime; AttrElementStyle.width = (Properties['width'] + DiffValues['width'] * progressFactor) + "px"; AttrElementStyle.height = (Properties['height'] + DiffValues['height'] * progressFactor) + "px"; AttrElementStyle.padding = (Properties['padding']['top'] + DiffValues['padding']['top'] * progressFactor) + "px " + (Properties['padding']['right'] + DiffValues['padding']['right'] * progressFactor) + "px " + (Properties['padding']['bot'] + DiffValues['padding']['bot'] * progressFactor) + "px " + (Properties['padding']['left'] + DiffValues['padding']['left'] * progressFactor) + "px"; AttrElementStyle.margin = (Properties['margin']['top'] + DiffValues['margin']['top'] * progressFactor) + "px " + (Properties['margin']['right'] + DiffValues['margin']['right'] * progressFactor) + "px " + (Properties['margin']['bot'] + DiffValues['margin']['bot'] * progressFactor) + "px " + (Properties['margin']['left'] + DiffValues['margin']['left'] * progressFactor) + "px"; } else { AttrElementStyle.width = options['width'] + "px"; AttrElementStyle.height = options['height'] + "px"; AttrElementStyle.padding = (Properties['padding']['top'] + DiffValues['padding']['top']) + "px " + (Properties['padding']['right'] + DiffValues['padding']['right']) + "px " + (Properties['padding']['bot'] + DiffValues['padding']['bot']) + "px " + (Properties['padding']['left'] + DiffValues['padding']['left']) + "px"; AttrElementStyle.margin = (Properties['margin']['top'] + DiffValues['margin']['top']) + "px " + (Properties['margin']['right'] + DiffValues['margin']['right']) + "px " + (Properties['margin']['bot'] + DiffValues['margin']['bot']) + "px " + (Properties['margin']['left'] + DiffValues['margin']['left']) + "px"; clearInterval(timer); // end of the animation if (callback != null) // if there is a CALLBACK then call it callback(Properties); } }, 15); } function slideUp(element, animationTime, callback) { morph(element, { height: 0, padding: { top: 0, bot: 0 }, margin: { top: 0, bot: 0 } }, animationTime, function (Properties) { // at the end of the slideUp we display: none the element and clean the other properties from style attribute var AttrElementStyle = element.style; AttrElementStyle.width = ""; AttrElementStyle.height = ""; AttrElementStyle.padding = ""; AttrElementStyle.margin = ""; element.style.display = 'none'; if (callback) callback(); }); } function slideDown(element, animationTime, callback) { var AttrElementStyle = element.style; var ComputedElementStyle = window.getComputedStyle(element, null); AttrElementStyle.display = "block"; var options = { // the computed properties when element is displayed width: parseInt(ComputedElementStyle.getPropertyValue("width")), height: parseInt(ComputedElementStyle.getPropertyValue("height")), padding: { top: parseInt(ComputedElementStyle.getPropertyValue("padding-top")), bot: parseInt(ComputedElementStyle.getPropertyValue("padding-bottom")) }, margin: { top: parseInt(ComputedElementStyle.getPropertyValue("margin-top")), bot: parseInt(ComputedElementStyle.getPropertyValue("margin-bottom")) } }; // after getting the actuals properties values of the element we flatten it AttrElementStyle.height = "0"; AttrElementStyle.paddingTop = "0"; AttrElementStyle.paddingBottom = "0"; AttrElementStyle.marginTop = "0"; AttrElementStyle.marginBottom = "0"; morph(element, options, animationTime, function () { // morph the element from flat to the options properties that are right // at the end of slideDown we clean up the style but keep the display: block if the element is display: none in the stylesheet AttrElementStyle.width = ""; AttrElementStyle.height = ""; AttrElementStyle.padding = ""; AttrElementStyle.margin = ""; element.style.display = 'block'; element.style.overflow = 'visible'; if (callback) // if there is a CALLBACK then call it (we are in the morph() callback) callback(); }) } /* slidedown/up /end */ /* custom scroll */ /* custom scroll /end */ function getStyle(elem, prop) { if (elem !== null && elem.currentStyle) { //IE8 return elem.currentStyle[prop]; } else if (elem !== null && window.getComputedStyle) { //Navegadores modernos return window.getComputedStyle(elem, null).getPropertyValue(prop); } } function isVisible(elem) { //Verifica inputs if (elem !== null && elem.tagName === "INPUT" && elem.type === "hidden") { return false; } //Verifica a propriedade visibility if (getStyle(elem, "visibility") === "hidden") { return false; } //Verifica a propriedade display if (getStyle(elem, "display") === "none") { return false; } return true; } function lf_chatbot_addClass(el, classNameToAdd) { el.className += ' ' + classNameToAdd; } function lf_chatbot_removeClass(el, classNameToRemove) { var elClass = ' ' + el.className + ' '; while (elClass.indexOf(' ' + classNameToRemove + ' ') !== -1) { elClass = elClass.replace(' ' + classNameToRemove + ' ', ''); } el.className = elClass; } function remove_acentos(string) { text = string.toLowerCase(); text = text.replace(new RegExp('[ÁÀÂÃ]', 'gi'), 'a'); text = text.replace(new RegExp('[ÉÈÊ]', 'gi'), 'e'); text = text.replace(new RegExp('[ÍÌÎ]', 'gi'), 'i'); text = text.replace(new RegExp('[ÓÒÔÕ]', 'gi'), 'o'); text = text.replace(new RegExp('[ÚÙÛ]', 'gi'), 'u'); text = text.replace(new RegExp('[Ç]', 'gi'), 'c'); return text; }