1jQuery(document).ready(function () { 2 3 // Cargar banners hero 4 /* 5 $.ajax({ 6 url: "/internal/getHeroBanners.php", 7 method: "GET", 8 timeout: 10000, 9 success: function (data) { 10 $('#hero-banners').html(data); 11 }, 12 error: function (xhr, status, error) { 13 console.error('Error cargando banners:', error); 14 15 // Mostrar un banner simple como fallback 16 $('#hero-banners').html(` 17 <div class="carousel slide" id="fallbackCarousel" data-bs-ride="carousel"> 18 <div class="carousel-inner"> 19 <div class="carousel-item active"> 20 <div class="banner-slide" style="background: linear-gradient(135deg, #F39200 0%, #ff9500 100%); height: 400px;"> 21 <div class="banner-content"> 22 <h1 class="banner-title">¡Bienvenido a LibrosCC!</h1> 23 <p class="banner-subtitle">Descubre miles de libros en nuestra librerÃa online</p> 24 <a href="/results" class="banner-btn">Explorar Catálogo</a> 25 </div> 26 </div> 27 </div> 28 </div> 29 </div> 30 `); 31 } 32 }); 33 */ 34 35 $.ajax({
36 url: "/internal/getHomeBooks.php?type=destacados", 37 method: "GET", 38 success: function (data) { 39 $('#featuredbooks').html(data); 40 }, 41 error: function (xhr, status, error) { 42 console.error('Error cargando libros destacados:', error); 43 $('#featuredbooks').html('<div class="text-center text-muted py-5">Error cargando libros destacados</div>'); 44 } 45 }); 46 47 $.ajax({ 48 url: "/internal/getHomeBooks.php?type=best_reviews", 49 method: "GET", 50 51 success: function (data) { 52 $('#reviewsbooks').html(data); 53 }, 54 error: function (xhr, status, error) { 55 console.error('Error cargando libros mejor valorados:', error); 56 } 57 }); 58 59 $.ajax({ 60 url: "/internal/getHomeBooks.php?type=novedades", 61 method: "GET", 62 63 success: function (data) { 64 $('#lastbooks').html(data); 65 }, 66 error: function (xhr, status, error) { 67 console.error('Error cargando novedades:', error); 68 } 69 }); 70 71 $.ajax({
72 url: "/internal/getHomeBooks.php?type=vendidos", 73 method: "GET", 74 75 success: function (data) { 76 $('#bestsellerbooks').html(data); 77 }, 78 error: function (xhr, status, error) { 79 console.error('Error cargando bestsellers:', error); 80 } 81 }); 82 83 $.ajax({ 84 url: "/internal/getHomeBooks.php?type=vendidos_ebooks", 85 method: "GET", 86 87 success: function (data) { 88 $('#bestsellerebooks').html(data); 89 }, 90 error: function (xhr, status, error) { 91 console.error('Error cargando bestsellers ebooks:', error); 92 } 93 }); 94 95 $.ajax({ 96 url: "/internal/getHomeBooks.php?type=presales", 97 method: "GET", 98 99 success: function (data) { 100 $('#presalebooks').html(data); 101 }, 102 error: function (xhr, status, error) { 103 console.error('Error cargando preventas:', error); 104 } 105 }); 106 107 var login = $('#login').val(); 108 if (login == "true") { 109 $.ajax({
110 url: '../internal/accountDrawer.php?login=true', 111 type: "GET", 112 113 success: function (data) { 114 115 $('#usericon').addClass('show menu-dropdown'); 116 $('#menuuser').html(data); 117 $('#menuuser').addClass('show'); 118 $('#menuuser').css({ 119 'z-index': '105', 120 'position': 'fixed', 121 'inset': '0px 0px auto auto', 122 'margin': '0px', 123 'transform': 'translate(0px, 65px)' 124 }); 125 126 } 127 128 }); 129 } 130 131 // Event handlers para botones de navegación del carrusel 132 $(document).on('click', '.carousel-nav-prev, .carousel-nav-next', function (e) { 133 e.preventDefault(); 134 135 const target = $(this).data('target'); 136 137 // Buscar el carrusel Owl dentro del contenedor target 138 let owlCarousel = $('#' + target + ' .owl-carousel'); 139 140 if (owlCarousel.length && typeof owlCarousel.trigger === 'function') { 141 if ($(this).hasClass('carousel-nav-prev')) { 142 owlCarousel.trigger('prev.owl.carousel'); 143 } else { 144 owlCarousel.trigger('next.owl.carousel'); 145 } 146 } else { 147 148 } 149 }); 150 151 // Event handlers para botones de formato modernos 152 $(document).on('click', '.format-btn-modern', function (e) { 153 e.preventDefault(); 154 e.stopPropagation(); 155 156 if ($(this).hasClass('processing')) { 157 return; 158 } 159 $(this).addClass('processing'); 160 161 const bookId = $(this).data('book-id'); 162 const type = $(this).data('type'); 163 const format = $(this).data('format'); 164 const price = $(this).data('price'); 165 const uniqueId = type + '-' + bookId; 166 167 168 169 // Remover clase active de botones del mismo libro 170 $(`[data-book-id="${bookId}"][data-type="${type}"].format-btn-modern`).removeClass('active'); 171 172 // Agregar clase active al botón clickeado 173 $(this).addClass('active'); 174 175 // Actualizar precio - SOLUCION PARA OWL CAROUSEL 176 // Buscar todos los elementos price-display con este ID (incluidos los clones) 177 const allPriceElements = $(`[id="price-display-${uniqueId}"]`); 178 if (allPriceElements.length > 0) { 179 // Actualizar TODOS los elementos (originales y clones) 180 allPriceElements.each(function () { 181 $(this).html(price + 'â¬'); 182 }); 183 184 } 185 186 // Actualizar botón de carrito - También buscar todos los clones 187 const allCartButtons = $(`[id="idBook${uniqueId}"]`); 188 allCartButtons.each(function () { 189 $(this).attr('data-format', format); 190 $(this).attr('data-price', price); 191 }); 192 193 setTimeout(() => { 194 $(this).removeClass('processing'); 195 }, 400); 196 }); 197 198 // Event handlers para botones de formato clásicos (small) 199 $(document).on('click', '.format-btn-small', function (e) { 200 e.preventDefault(); 201 e.stopPropagation(); 202 203 if ($(this).hasClass('processing')) { 204 return; 205 } 206 $(this).addClass('processing'); 207 208 const bookId = $(this).data('book-id'); 209 const type = $(this).data('type'); 210 const format = $(this).data('format'); 211 const price = $(this).data('price'); 212 const uniqueId = type + '-' + bookId; 213 214 // Remover clase active de botones del mismo libro y tipo 215 $(`[data-book-id="${bookId}"][data-type="${type}"].format-btn-small`).removeClass('active'); 216 217 // Agregar clase active al botón clickeado 218 $(this).addClass('active'); 219 220 // Actualizar precio 221 $(`#price-display-${uniqueId}`).html(price + 'â¬'); 222 223 // Actualizar botón de carrito 224 const cartButton = $(`#idBook${uniqueId}`); 225 cartButton.attr('data-format', format); 226 cartButton.attr('data-price', price); 227 228 setTimeout(() => { 229 $(this).removeClass('processing'); 230 }, 400); 231 });
232 233});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.