" + "" + "" + ""); addElementInDom(divConteinerFrm, divFrmEmail, "beforeend"); } function getInfoInputs() { const nombre = document.getElementById('nombreFrm'), telefono = document.getElementById('telefonoFrm'), email = document.getElementById('emailFrm'), comentario = document.getElementById('comentariosFrm'); if (email && comentario) { return { nombre, telefono, email, comentario }; } return { nombre, telefono }; } function checkActiveClassOtherButtoms() { const divParent = document.getElementById('iconsConsulta'); [...divParent.children].forEach( buttom => { if (buttom.classList.contains('active')) { buttom.classList.remove('active'); } }); } function checkIfExistFrmEmail() { const divFrmEmail = document.getElementById('formulario-email'); deleteFrm(divFrmEmail); } function checkIfExistFrmPhone() { const divFrmPhone = document.getElementById('formulario-telefono'); deleteFrm(divFrmPhone); } function checkErrorMessage() { const divCheck = document.getElementById('divCheck'); if (!divCheck.classList.contains('close')) { divCheck.classList.add('close'); } } function checkInputs(datos) { const regString = /^[A-Za-z ]+$/, name = datos.nombre, phone = datos.telefono, mail = datos.email; if (!regString.test(name.value)) { addMessageAlert(name, 'Ingrese un ' + name.getAttribute('name') + ' válido'); return false; } if (regString.test(phone.value) || phone.value.length === 0) { addMessageAlert(phone, 'Ingrese un ' + phone.getAttribute('name') + ' válido'); return false; } if (mail) { if (mail.value.length === 0) { addMessageAlert(mail, 'Ingrese un ' + mail.getAttribute('name') + ' válido'); return false; } } return true; } function addHtml(element, html) { element.innerHTML = html; } function addElementInDom(elementConteiner, elementToAdd, where) { elementConteiner.insertAdjacentElement(where, elementToAdd); } function addMessageAlert(input, message) { const divAlert = document.getElementById('divCheck'); if (divAlert.classList.contains('close')) { divAlert.classList.remove('close'); } removeClassCheckInputs(); if (input) { input.classList.add('check'); } addHtml(divAlert, "
" + message + "
"); } function addMessageSuccess(message) { const formulario = document.querySelector('div.formularioConsulta'), div = document.createElement('div'), titlePopup = document.querySelector('.popup-title'), buttoms = document.getElementById('iconsConsulta'), divContainer = document.getElementById('frmConteinerDiv'); if (!formulario.classList.contains('close')) { formulario.classList.add('close'); } [titlePopup, buttoms].forEach( element => { element.remove(); }); div.classList.add('success'); removeClassCheckInputs(); addHtml(div, "" + "
" + message + "
" ); addElementInDom(divContainer, div, 'beforeend'); } function removeClassCheckInputs() { const formularioConsulta = document.querySelectorAll('.frmConsulta input'); [...formularioConsulta].forEach( input => { if (!input.classList.contains('check')) { return; } input.classList.remove('check'); }); } function removeAlertMessage() { const checkDiv = document.getElementById('divCheck'); if (checkDiv) { removeClassCheckInputs(); checkDiv.classList.add('close'); } } function deleteFrm(element) { if (element) { element.remove(); } } function enviarDatos(datos, action) { if (!checkInputs(datos)) { return; } removeAlertMessage(); sendData(datos, action); } async function sendData(datos, action) { let data = { nombre: datos.nombre.value, telefono: datos.telefono.value, email: '', comentarios: '', enlace: urlProducto, producto: nombreProducto }; if (action === 'email') { data.email = datos.email.value; data.comentarios = datos.comentario.value; } const res = await fetch('/consulta', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ data, action }) }); if (res.ok) { try { const data = await res.json(); if (data.status === 'error') { addMessageAlert(null, data.message); return; } addGoogleAnalytics('consulta', 'clickFormulario', 'popupConsulta'); addMessageSuccess(data.message); } catch (error) { addMessageAlert(null, data.message); } } } return { initPopUp }; }; popUpConsultaNuevo.initPopUp();
GarnieBilletera de cuero Phoenix - AzulBilletera de cuero con visor, credicard y doble interior para billetes.4061086https://www.garnie.com/catalogo/billetera-de-cuero-phoenix-azul_4061_086