//FOOTER function abrir_enlace(url, ventana_nueva) { if (ventana_nueva) { window.open(url); } else { window.location = url; } } function registrar_mail() { var email = $('#mail_publicidad').val(); if (isValidEmailAddress(email)) { $.get('/ajax/ajax_suscripciones.php?email=' + email + '', function (data) { if (data == 'ok') { $('#mail_publicidad').val(''); alert('Email ' + email + ' suscrito correctamente!'); } else { alert('Ocurrió un error al registrar el correo'); } }); } else { alert('Email incorrecto'); } } function registrar_nuevo_mail() { var estilo = getComputedStyle(document.documentElement); var colorPrimario = estilo.getPropertyValue('--color-primario'); var email = $('.txt_email_newsletter').val(); if (isValidEmailAddress(email)) { $.get('/ajax/ajax_suscripciones.php?email=' + email + '', function (data) { if (data == 'ok') { Swal.fire({ title: 'Newsletter', text: 'Email ' + email + ' suscrito correctamente!', icon: 'success', showCancelButton: false, confirmButtonColor: `${colorPrimario}`, confirmButtonText: 'Aceptar' }).then((result) => { $('.txt_email_newsletter').val(''); }) } else { //alert('Ocurrió un error al registrar el correo'); Swal.fire({ title: 'Newsletter', text: 'Ocurrió un error al registrar el correo', icon: 'error', showCancelButton: false, confirmButtonColor: `${colorPrimario}`, confirmButtonText: 'Aceptar' }).then((result) => { }) } }); } else { Swal.fire({ title: 'Newsletter', text: 'Email incorrecto', icon: 'error', showCancelButton: false, confirmButtonColor: `${colorPrimario}`, confirmButtonText: 'Aceptar' }).then((result) => { }) } } function registrar_mail_v2() { let email = $('#txt_email_subs').val(); let nombre = $('#txt_name_subs').val(); let check = false; if ($('#cb_aceptar').is(':checked')) { check = true; } else { check = false; } if (!check) { alert('Debe aceptar los terminos condiciones'); return false; } if (isValidEmailAddress(email)) { $.post('/ajax/ajax_subscribers.php', { action: 'registro_mail', email: email, nombre: nombre }, function (data) { //console.log('RESPUESTA',data); if (data == 'OK') { $('#txt_email_subs').val(''); $('#txt_name_subs').val(''); alert('Email ' + email + ' suscrito correctamente!'); } else { alert('Ocurrió un error al registrar el correo'); } return false; }); } else { alert('Email incorrecto'); return false; } } function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(emailAddress); } /** Para el autocompletado del codigo postal */ var autofilldata = new Array(); var $ajax = false; var country_id = 195; function change_country(val) { country_id = val; $("#state_" + val).css("display", "block"); $("#state_" + val).attr("name", "state"); var otroval = val == 195 ? 171 : 195; $("#state_" + otroval).css("display", "none"); $("#state_" + otroval).attr("name", "state_oculto"); } $("#spinfill").hide(); $("#autofill_content").hide(); function autofill(div) { var text = div.value; if (text.length > 3) { if ($ajax) $ajax.abort(); //Con un cod postal de más de 4 cifras empezamos a cargar datos //1º mostramos spinner $("#spinfill").show("fast"); //2º lanzamos consulta por ajax. $ajax = $.ajax({ method: "POST", url: "ajax/autofill.php", data: { cp: text } }) .done(function (msg) { //console.log('Codigo postal',msg); autofilldata = ""; //1º Ocultamos el spinner y mostramos el div contenedor $("#spinfill").hide(); $("#autofill_content").show(); //Cargamos contenedor. var container = document.getElementById("autofill_content"); container.innerHTML = ""; //Limpiamos contenedor //No se han encontrado coincidencias if (!msg || msg == "") { var divE = document.createElement("div"); divE.className = "autofill_element_wrong"; divE.innerHTML = "No se han encontrado coincidencias"; $("#spinfill").show(); $("#autofill_content").show(); //Insertamos en el contenedor container.appendChild(divE); //Cerramos la ejecución. return; } //Si hemos superado la anterior condición pintamos array ordenado. var data = JSON.parse(msg); if (!data) { //ERROR. var divE = document.createElement("div"); divE.className = "autofill_element_wrong"; divE.innerHTML = "Error inesperado"; //Insertamos en el contenedor container.appendChild(divE); //Cerramos la ejecución. return; } //Si todo ha ido bien vamos a pintar divs con el contenido. autofilldata = data; //Guardamos en variable global para ser usada en otras funciones $("#spinfill").hide(); for (key in data) { var divE = document.createElement("div"); divE.id = "autofill_element_" + key; divE.className = "autofill_element"; divE.onclick = setfill; //Montamos la cadena a mostrar. console.log(data[key]["city"]); var fillcity = data[key]["city"] ? data[key]["city"] : "¿?"; var fillstate = data[key]["state"] ? data[key]["state"] : "¿?"; var fillcp = data[key]["cp"] ? data[key]["cp"] : "¿?"; if (fillcp.length == 4 && parseInt(data[key]["idprefix"]) == 195) fillcp = "0" + fillcp; var content = fillcity + ". " + fillstate + " (" + fillcp + "). " + getCountry(parseInt(data[key]["idprefix"])); divE.innerHTML = content; //E insertamos en el contenedor. container.appendChild(divE); } //Creamos una última fila con "otra población" para que oculte la lista sin mas var divE = document.createElement("div"); divE.className = "autofill_element"; divE.onclick = fillblur; var content = ' Otra población'; divE.innerHTML = content; //E insertamos en el contenedor. container.appendChild(divE); }); } else { $("#spinfill").hide(); $("#autofill_content").hide(); } } /* * Función sencilla; devuelve el país según idprefix. */ function getCountry(id) { switch (id) { case 195: return "Spain"; case 171: return "Portugal"; } } /* * Función que selecciona y autocompleta los datos de ciudad, país... */ function setfill(e) { $("#spinfill").hide(); $("#autofill_content").hide(); //Conseguimos la key gracias al id var tmpid = e.target.id; var id = tmpid.slice(17); //Teniendo la key ya podemos acceder a la parte del array deseada. var data = autofilldata[id]; if (data.cp.indexOf("-") > 0) data.cp = data.cp.slice(0, data.cp.indexOf("-")); else if (data.cp.length == 4) data.cp = "0" + data.cp; change_country(data.idprefix); document.getElementById("postcode").value = data.cp; decodedcity = $('
').html(data.city).text(); $('#city').val(decodedcity); decodedstate = $('
').html(data.state).text(); $("#state_" + country_id).val(decodedstate); // mod envio limitado if (data.state == "Ceuta" || data.state == "Melilla" || data.state == "Las Palmas" || data.state == "Santa Cruz de Tenerife") $("#alert_state_noenvio").fadeIn("fast"); //Para el país recorremos el select y ponemos como selected la opción que coincida con idprefix var sel = document.getElementById("country").options; for (key in sel) { if (parseInt(sel[key].value) == parseInt(data.idprefix)) document.getElementById("country").selectedIndex = key; } } function fillblur() { //Al perder el foco ocultamos los divs *fill y si no se ha seleccionado ningún elemento y sólo hay 1, lo seleccionamos $("#spinfill").hide(); $("#autofill_content").hide("slow"); } /** #################################### */ function sendMailO(url, subject, correo_tienda, captcha) { //Pintamos formulario var div_black = document.createElement("div"); div_black.className = "mailO_black"; div_black.id = "mailO_black"; var div_content = document.createElement("div"); div_content.className = "mailO_content"; //Header var div_header = document.createElement("div"); div_header.className = "mailO_header"; div_header.innerHTML = "Comparte este producto"; var div_close = document.createElement("div"); div_close.className = "mailO_close"; div_close.innerHTML = "×"; div_close.onclick = function () { document.getElementById("mailO_black").remove(1); } div_header.appendChild(div_close); div_content.appendChild(div_header); //Alertas var div_row = document.createElement("div"); div_row.className = "mailO_row mailO_shadow_2"; div_row.id = "mailO_alerts"; var div_text = document.createElement("div"); div_row.appendChild(div_text); div_content.appendChild(div_row); //Para var div_row = document.createElement("div"); div_row.className = "mailO_row"; var div_text = document.createElement("div"); div_text.className = "mailO_mintext"; div_text.innerHTML = "Para: "; div_row.appendChild(div_text); var input = document.createElement("input"); input.type = "email"; input.id = "mailO_para"; input.className = "mailO_input"; input.placeholder = "Email del destinatario."; /*input.value=correo_tienda; input.disabled="true";*/ div_row.appendChild(input); div_content.appendChild(div_row); //De /*var div_row=document.createElement("div"); div_row.className="mailO_row"; var div_text=document.createElement("div"); div_text.className="mailO_mintext"; div_text.innerHTML="De: "; div_row.appendChild(div_text); var input=document.createElement("input"); input.type="text"; input.id="mailO_de"; input.className="mailO_input"; input.placeholder="Nombre del remitente."; div_row.appendChild(input); div_content.appendChild(div_row);*/ //Tema var div_row = document.createElement("div"); div_row.className = "mailO_row"; var div_text = document.createElement("div"); div_text.className = "mailO_mintext"; div_text.innerHTML = "Asunto: "; div_row.appendChild(div_text); var input = document.createElement("input"); input.type = "text"; input.id = "mailO_tema"; input.className = "mailO_input"; input.value = subject; input.disabled = "true"; div_row.appendChild(input); div_content.appendChild(div_row); //Mensaje var div_row = document.createElement("div"); div_row.className = "mailO_row mailO_shadow"; var textarea = document.createElement("textarea"); textarea.rows = "15"; textarea.id = "mailO_mensaje"; textarea.className = "mailO_textarea"; textarea.placeholder = "Mensaje máximo 500 caracteres."; textarea.value = "Échale un vistazo a este producto: " + subject; div_row.appendChild(textarea); div_content.appendChild(div_row); //Url var div_row = document.createElement("div"); //div_row.className="mailO_row"; var div_text = document.createElement("div"); div_text.className = "mailO_mintext"; //div_text.innerHTML="Url: "; div_row.appendChild(div_text); var input = document.createElement("input"); input.type = "hidden"; input.id = "mailO_url"; input.className = "mailO_input"; input.value = url; //input.disabled="true"; div_row.appendChild(input); div_content.appendChild(div_row); //reCaptcha var div_row = document.createElement("div"); div_row.className = "mailO_row"; div_row.id = "mailO_captcha"; div_row.innerHTML = '
'; div_content.appendChild(div_row); // Cargamos el script $.getScript("https://www.google.com/recaptcha/api.js", function (e) { }); //Enviar var div_row = document.createElement("div"); div_row.className = "mailO_row"; //Botón enviar var button = document.createElement("button"); button.type = "button"; button.className = "mailO_button"; button.id = "mailO_enviar"; button.innerHTML = "Enviar correo Electrónico"; button.onclick = postMailO; div_row.appendChild(button); //Contenedor gif loading var div_loading = document.createElement("div"); div_loading.className = "mailO_div_loading"; div_loading.id = "mailO_loading"; div_loading.innerHTML = "Enviando..."; //Gif var img_loading = document.createElement("img"); img_loading.src = "/static/template/perfumes24horas.com/shippingimages/loading.gif"; div_loading.appendChild(img_loading); div_row.appendChild(div_loading); div_content.appendChild(div_row); div_black.appendChild(div_content); document.body.appendChild(div_black); document.getElementById("mailO_para").focus(); } function postMailO() { //Mostramos loading y bloqueamos botón enviar $("#mailO_loading").fadeIn("fast"); $("#mailO_enviar").hide(); $("#mailO_alerts").slideUp("fast"); //Capturamos los datos var captcha = $("#g-recaptcha-response").val(); var para = $("#mailO_para").val(); var de = $("#mailO_de").val(); var tema = $("#mailO_tema").val(); var mensaje = $("#mailO_mensaje").val(); var url = $("#mailO_url").val(); //Hacemos una primera verificación de los datos var error = 0; var alerts = new Array(); if (captcha.length == 0) { error = 1; alerts.push("Error en el reCAPTCHA"); } if (para.length < 3 || para.indexOf("@") == -1 || para.indexOf(".") == -1) { error = 1; alerts.push("El destinatario es incorrecto"); } /*if(de.length<3){ error=1; alerts.push("El remitente es incorrecto"); }*/ if (tema.length < 3) { error = 1; alerts.push("El tema es incorrecto"); } if (mensaje.length < 3 || mensaje.length > 500) { error = 1; alerts.push("El mensaje debe tener entre 3 y 500 caracteres."); } if (url.length < 3) { error = 1; alerts.push("La url es incorrecta."); } //Si hay errores mostramos if (error) { $("#mailO_enviar").fadeIn("fast"); $("#mailO_loading").hide(); var htmlAlerts = ""; for (key in alerts) { htmlAlerts += "
"; htmlAlerts += alerts[key]; htmlAlerts += "
"; } $("#mailO_alerts").html(htmlAlerts); $("#mailO_alerts").slideDown("fast"); } //En caso contrario enviamos por php para última verificación y envío. else { //console.log('enviamos correo ', { captcha:captcha, para:para, de:de, tema:tema, mensaje:mensaje, url:url }); $ajax = $.ajax({ method: "POST", url: "/ajax/share_mail.php", data: { captcha: captcha, para: para, de: de, tema: tema, mensaje: mensaje, url: url } }) .done(function (msg) { //console.log('llega', msg); $("#mailO_enviar").fadeIn("fast"); $("#mailO_loading").hide(); if (msg) { var data = JSON.parse(msg); var htmlAlerts = ""; for (key in data["alerts"]) { htmlAlerts += "
"; htmlAlerts += data["alerts"][key]; htmlAlerts += "
"; } $("#mailO_alerts").html(htmlAlerts); $("#mailO_alerts").slideDown("fast"); } else alert("Ha ocurrido un error inesperado."); }); } } /* MODALS */ $('.ajax-popup-link').unbind(); $('.ajax-popup-link').magnificPopup({ type: 'ajax' }); function cerrarModals() { /*$('.info_producto_modal .mfp-close').trigger('click'); $('.carrito-popup .mfp-close').trigger('click'); $('.saldo-popup .mfp-close').trigger('click');*/ $('.mfp-close').trigger('click'); } function getHoraJS() { var currentdate = new Date(); var horasLocal = currentdate.getHours().toString(); if (horasLocal.length == 1) horasLocal = "0" + horasLocal; var minutosLocal = currentdate.getMinutes().toString(); if (minutosLocal.length == 1) minutosLocal = "0" + minutosLocal; var segundosLocal = currentdate.getSeconds().toString(); if (segundosLocal.length == 1) segundosLocal = "0" + segundosLocal; return horasLocal + ":" + minutosLocal + ":" + segundosLocal; } function diferencia_segundos(hora1, hora2) { var date1 = Date.parse('01 Jan 1970 ' + hora1 + ' GMT'); var date2 = Date.parse('01 Jan 1970 ' + hora2 + ' GMT'); var dif = (date1 - date2) / 1000; return dif; } function utf8_to_b64(str) { return window.btoa(unescape(encodeURIComponent(str))); } function b64_to_utf8(str) { return decodeURIComponent(escape(window.atob(str))); } /** RELOJ */ var reloj_json = ''; function descontar(id) { //return false; //eraseCookie('reloj64'); /*if (reloj_json=='') { if (comprobarCookie('reloj64')) { //console.log('COOKIE RELOJ'); if (typeof window.atob !== "undefined") { var reloj_string = b64_to_utf8(obtenerCookie('reloj64')); } else { var reloj_string = obtenerCookie('reloj64'); } //console.log('TENEMOS COOKIE ' + reloj_string); reloj_json = JSON.parse(reloj_string); var horaJS = getHoraJS(); //console.log('hora_corte '+reloj_json.hora_corte); //console.log('hora_actual '+horaJS); var segundosRestantes = diferencia_segundos(reloj_json.hora_corte, horaJS); //console.log('segundosRestantes '+segundosRestantes); reloj_json.horaLimite = Math.floor(segundosRestantes / 3600); segundosRestantes %= 3600; reloj_json.minutoLimite = Math.floor(segundosRestantes / 60); reloj_json.segundoLimite = segundosRestantes % 60; } }*/ if (reloj_json == '') { let datos_json_temp = get_reloj_actual_json(); reloj_json = JSON.parse(datos_json_temp); } if (reloj_json == '') { //console.log('AJAX GET INFO RELOJ'); $.post("/ajax/get_info_reloj.php", { action: 'get', }, function (data) { reloj_json = JSON.parse(data); //console.log('reloj_json ', reloj_json); var horaJS = getHoraJS(); if (reloj_json.hora_actual == horaJS.substr(0, 5)) { //console.log('LA HORA DEL SERVIDOR COINCIDE CON LA DE JAVASCRIPT: GUARDAMOS COOKIE '+horaJS); //console.log('hora_corte '+reloj_json.hora_corte); //console.log('hora_actual '+horaJS); var segundosRestantes = diferencia_segundos(reloj_json.hora_corte, horaJS); //console.log('segundosRestantes '+segundosRestantes); var diasRestantes = segundosRestantes / (3600 * 24); //console.log('diasRestantes '+diasRestantes); if (typeof window.btoa !== "undefined") { crearCookie('reloj64', utf8_to_b64(data), diasRestantes); } else { crearCookie('reloj64', data, diasRestantes); } } descontar(id); return; }); } if (reloj_json.horaLimite > 0 || reloj_json.minutoLimite > 0 || reloj_json.segundoLimite > 0) { var hora_mostrar; var minuto_mostrar; var segundo_mostrar; if (reloj_json.horaLimite < 10) { hora_mostrar = '0' + reloj_json.horaLimite; } else { hora_mostrar = reloj_json.horaLimite; } if (reloj_json.minutoLimite < 10) { minuto_mostrar = '0' + reloj_json.minutoLimite; } else { minuto_mostrar = reloj_json.minutoLimite; } if (reloj_json.segundoLimite < 10) { segundo_mostrar = '0' + reloj_json.segundoLimite; } else { segundo_mostrar = reloj_json.segundoLimite; } $('.reloj_hora').html(hora_mostrar); $('.reloj_minuto').html(minuto_mostrar); $('.reloj_segundo').html(segundo_mostrar); $('.reloj').show(); if (reloj_json.segundoLimite == 0 && reloj_json.minutoLimite == 0) { reloj_json.segundoLimite = 60; reloj_json.minutoLimite = 59; reloj_json.horaLimite = reloj_json.horaLimite - 1; } else if (reloj_json.segundoLimite == 0) { reloj_json.segundoLimite = 60; reloj_json.minutoLimite = reloj_json.minutoLimite - 1; } //Restar segundo reloj_json.segundoLimite = reloj_json.segundoLimite - 1; setTimeout("descontar(\"" + id + "\")", 1000) } else if (reloj_json == '') { //console.log("Ocultar reloj!") } else { $('.reloj').hide(); } } //Cada 5 min petición ajax para que no caduque la sesión setInterval(function () { //Ajax $.ajax({ method: "POST", url: "/refresh_sesion.php" }) .done(function (msg) { console.log(msg); }); }, 300000); function es_movil() { if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { return true; } else { return false; } } function es_iphone() { if (navigator.userAgent.match(/iPhone|iPod/i)) { return true; } else { return false; } } function es_ipad() { if (navigator.userAgent.match(/iPad/i)) { return true; } else { return false; } } function es_android() { if (navigator.userAgent.match(/Android/i)) { return true; } else { return false; } } function setListenersProductosLista() { /* VARIANTES */ $('.grupo .variante').unbind(); $('.grupo .variante').click(function () { var indice = $(this).data("indice"); var grupo = $(this).parent().parent().parent(); grupo.find('.variante').removeClass("activo"); $(this).addClass("activo"); grupo.find('.precios').hide(); grupo.find('.precios_' + indice).show(); grupo.find('.insignia').hide(); grupo.find('.insignia_' + indice).show(); if (grupo.find('.insignia_regalo_marca') != undefined) grupo.find('.insignia_regalo_marca').hide(); if (grupo.find(`.insignia_regalo_marca_${indice}`) != undefined) { grupo.find(`.insignia_regalo_marca_${indice}`).show(); } grupo.find('.boton').hide(); grupo.find('.boton_' + indice).show(); if ($(this).data("img_propia") !== "undefined" && $(this).data("img_propia") != null && $(this).data("img_propia") != '') { var img_propia = $(this).data("img_propia"); grupo.find('.imagen .img_producto').prop('src', img_propia); } if ($(this).data("nombre_color") !== "undefined" && $(this).data("nombre_color") != null && $(this).data("nombre_color") != '') { var nombre_color = $(this).data("nombre_color"); grupo.find('.subtitulo').html(nombre_color); } }); /* HOVER SOBRE GRUPO */ if (es_movil()) { $('.grupo').find('.boton a').show(); } else { $('.contenido_grupo').mouseenter(function (event) { $(this).parent().css('border', '1px solid white'); $(this).find('.boton a').css('display', 'block'); $(this).find('.favbuttons').css('display', 'block'); }); $('.contenido_grupo').mouseleave(function (event) { $(this).parent().css('border', 'none'); $(this).find('.boton a').css('display', 'none'); $(this).find('.favbuttons').css('display', 'none'); }); } /* ANIMACIÓN AÑADIR PRODUCTO AL CARRITO */ $('.btn_anadir').unbind(); $('.btn_anadir').click(function () { var products_id = $(this).data('products_id'); var grupo = $(this).parent().parent().parent(); //var imagen = grupo.find('.imagen img'); var imagen = grupo.find('.imagen img').eq(1); if (imagen.hasClass("insignia")) { imagen = grupo.find('.imagen img').eq(0); } if (imagen == null || imagen == undefined || imagen == '' || imagen == 'undefined' || imagen.length == 0) { imagen = grupo.find('.imagen img').eq(0); } var nombre64 = $(this).data('nombre64'); var limit = $(this).data('limit'); if (Number.isInteger(limit)) { var href = '/ajax/limitados.ajax.php?pid=' + products_id + '&otro=' + limit; /* alert("1- "+href);*/ $.magnificPopup.open({ items: { src: href, type: 'ajax' } }); return; } else if (limit == "si") { var href = '/ajax/limitados.ajax.php?pid=' + products_id + '&a=1'; /*alert("2- "+href);*/ $.magnificPopup.open({ items: { src: href, type: 'ajax' } }); /* alert("33"); */ return false; } else if (limit == "unico") { /*alert('3');*/ var href = '/ajax/producto_unico.ajax.php?pid=' + products_id; $.magnificPopup.open({ items: { src: href, type: 'ajax' } }); return; } if (es_movil() || typeof anime === "undefined") { var href = '/ajax/carrito.ajax.php?action=comprar&pid=' + products_id + '&ajax=1&nombre=' + nombre64; /*alert("3- "+href);*/ $.magnificPopup.open({ items: { src: href, type: 'ajax' } }); } else { $addac = $.ajax({ method: "POST", url: "/ajax/add_cart.php", data: { id_prod: products_id } }).done(function (res) { console.log('RES', res); console.log("animacion"); var datos = JSON.parse(res); var num_items = datos.num_items; var grupo_id = grupo.prop('id'); // Coordenadas de origen var viewportOffsetOrigen = document.getElementById(grupo_id).getElementsByClassName('imagen')[0].getElementsByTagName("IMG")[0].getBoundingClientRect(); var topOrigen = viewportOffsetOrigen.top; var leftOrigen = viewportOffsetOrigen.left; //console.log("topOrigen "+topOrigen+" leftOrigen "+leftOrigen); // Coordenadas de destino var viewportOffsetDestino = document.getElementById('abre_mini_carro').getElementsByTagName("I")[0].getBoundingClientRect(); var topDestino = viewportOffsetDestino.top; var leftDestino = viewportOffsetDestino.left; //console.log("topDestino "+topDestino+" leftDestino "+leftDestino); $('#clon').remove(); $('.header_fijo').append(''); $('#clon').css('position', 'fixed').css('top', topOrigen).css('left', leftOrigen).css('z-index', 100000000000); // Movemos hacia destino var el = document.querySelector('#clon'); var anim1 = anime({ targets: el, rotate: 360, duration: 1000, easing: 'easeInOutSine', top: topDestino, left: leftDestino, height: 15, width: 15, complete: function (anim) { $('#clon').fadeOut(800, "linear", function () { $(this).remove(); }); $('.btn_carrito_items').html(num_items); if (res == 'num_items' && res == num_items) $('.btn_carrito_items').hide(); else $('.btn_carrito_items').show(); recargaMiniCarro(); $('.mini_carrito').show(); //clon.remove(); setTimeout(function () { $('.mini_carrito').hide(); }, 2000); } }); }); } var lista_limitados = $(this).data('lista_limitados'); if (lista_limitados != '' && $.isArray(lista_limitados)) { if (lista_limitados.length > 0) { $.each(lista_limitados, function (index, value) { value = parseInt(value); if (products_id == value) { $('#buy_now_' + value).data('limit', "si"); /* alert("x- Limit: si");*/ } else { $('#buy_now_' + value).data('limit', parseInt(lista_limitados[0])); /* alert("x- Limit:"+parseInt(lista_limitados[0]));*/ } }); } } let unidades_permitidas = $(this).data('unidades-permitidas'); if (unidades_permitidas > 1) { $(this).data('unidades-permitidas', (unidades_permitidas - 1)); $(this).data('limit', "no"); } else { $(this).data('limit', "si"); } }); $('.btn_personalizar').unbind(); $('.btn_personalizar').click(function () { //let data = {pid:$(this).attr("data-products_id"), did:$(this).parent().parent().parent().attr('id'), dp:$(this).attr("data-position")}; /*let did = $(this).parent().parent().parent().attr('id'); let dp = $(this).attr("data-position"); let nombre = $(`#${did}`).find('.nombre').html().trim(); let precio = $(`#${did}`).find(`.precios_${dp}`).find('.precio_valor').text().trim(); let data = {pid: $(this).attr("data-products_id"), nombre:nombre, precio: precio+'€'}*/ mostrar_modal_pfc($(this).attr("data-products_id")); }); } function copyTextToClipboard(text, mensaje) { var textArea = document.createElement("textarea"); // // *** This styling is an extra step which is likely not required. *** // // Why is it here? To ensure: // 1. the element is able to have focus and selection. // 2. if element was to flash render it has minimal visual impact. // 3. less flakyness with selection and copying which **might** occur if // the textarea element is not visible. // // The likelihood is the element won't even render, not even a flash, // so some of these are just precautions. However in IE the element // is visible whilst the popup box asking the user for permission for // the web page to copy to the clipboard. // // Place in top-left corner of screen regardless of scroll position. textArea.style.position = 'fixed'; textArea.style.top = 0; textArea.style.left = 0; // Ensure it has a small width and height. Setting to 1px / 1em // doesn't work as this gives a negative w/h on some browsers. textArea.style.width = '2em'; textArea.style.height = '2em'; // We don't need padding, reducing the size if it does flash render. textArea.style.padding = 0; // Clean up any borders. textArea.style.border = 'none'; textArea.style.outline = 'none'; textArea.style.boxShadow = 'none'; // Avoid flash of white box if rendered for any reason. textArea.style.background = 'transparent'; textArea.value = text; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); //var msg = successful ? 'successful' : 'unsuccessful'; //console.log('Copying text command was ' + msg); } catch (err) { //console.log('Oops, unable to copy'); } document.body.removeChild(textArea); snackbar(mensaje); } function goToByScroll(element) { // Scroll $('html,body').animate({ scrollTop: $(element).offset().top - 140 }, 'slow'); } function snackbar(texto) { // Get the snackbar DIV var x = document.getElementById("snackbar"); $('#snackbar').html(texto); // Add the "show" class to DIV x.className = "show"; // After 3 seconds, remove the show class from DIV setTimeout(function () { x.className = x.className.replace("show", ""); }, 3000); } function fav_busqueda(group_id, customers_id, guardar) { favorito_busqueda(guardar, group_id); if (guardar) { snackbar('Añadido a la lista de favoritos'); var action = "agregar_grupo_favorito"; } else { snackbar('Quitado de lista de favoritos'); var action = "quitar_grupo_favorito"; } $.post('/ajax/favoritos.php', { groups_id: group_id, customer_id: customers_id, action: action }, function (data) { //console.log('RESPUESTA',data); }); return false; } function favorito_busqueda(isFav, grupo_id) { if (isFav) { $('#div_fav_on_' + grupo_id).show(); $('#div_fav_off_' + grupo_id).hide(); } else { $('#div_fav_on_' + grupo_id).hide(); $('#div_fav_off_' + grupo_id).show(); } } /** COOKIES */ function crearCookie(clave, valor, diasexpiracion) { var d = new Date(); d.setTime(d.getTime() + (diasexpiracion * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); if (window.location.host == 'localhost:90') { document.cookie = clave + "=" + valor + "; " + expires + ";domain=localhost; path=/"; } else { document.cookie = clave + "=" + valor + "; " + expires + ";domain=." + window.location.host + "; path=/"; } } function obtenerCookie(clave) { var name = clave + "="; var ca = document.cookie.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 ""; } function eraseCookie(clave) { createCookie(clave, "", -1); } function comprobarCookie(clave) { var clave = obtenerCookie(clave); if (clave != "") { return true; } else { return false; } } function check_connect(t, u, p) { console.log("Estoy haciendo click en el banner:", t, u, p); console.log('EEE', window.screen.width); if (p == null || p == undefined || p == '') { p = ''; if (window.screen.width > 991) p = 'Escritorio'; if (window.screen.width <= 991) p = 'Movil'; if (p == '') { if ($(window).width() > 991) p = 'Escritorio'; if ($(window).width() <= 991) p = 'Movil'; } } try { $.post('/ajax/rc.php', { t: t, u: u, p: p }, function (data) { console.log('RESPUESTA', data); }); } catch (e) { console.log('ERROR'); console.log(e); } } function setSeq(cname, cvalue, segundos) { const d = new Date(); d.setTime(d.getTime() + (segundos * 1000)); let expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; }