All client-side interactivity for Sentidos Café lives in a single file,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jimmy13anhelo/paginaweb2.github.io/llms.txt
Use this file to discover all available pages before exploring further.
buscador.js, which is loaded at the bottom of index.php just before the closing </body> tag — alongside the secondary whatsapp_interactivo.js. The script is written in vanilla ES6 with no external JavaScript libraries; Font Awesome icons are the only CDN dependency, loaded via a <link> tag in <head>.
Overview of the Five Logical Sections
buscador.js is divided into five clearly commented sections, each responsible for a distinct feature of the page:
| # | Section | Trigger |
|---|---|---|
| 1 | Image hover effects | mouseenter / mouseleave on .tarjeta cards and #imagen-especialidad |
| 2 | WhatsApp messaging | click on .btn-wsp-pedido buttons and #btn-wsp-flotante |
| 3 | AJAX user registration | saludar() called from a registration form |
| 4 | Payroll calculator | calcularYMostrar() called from a salary form |
| 5 | Category search sidebar | submit on #formularioBuscador |
DOMContentLoaded listener. Sections 3 and 4 are standalone functions called directly from form onclick attributes.
1. Image Hover Effects
A constant object,fondosAlternativos, maps each combo product name to a replacement Unsplash image URL. When the user hovers over a .tarjeta card, the card’s backgroundImage style property is swapped to the alternative photo; when the cursor leaves, it reverts to the original image captured before the hover.
data-producto attribute of the .btn-wsp-pedido button nested inside each .tarjeta. This keeps the mapping tightly coupled to the same attribute used for WhatsApp orders, so updating a product name in the HTML automatically updates both the hover image and the order message.
A separate hover swap also applies to #imagen-especialidad (the “Nuestra Especialidad del Día” image in the welcome panel), which swaps to fotoBrunchEspecial on hover.
2. Event Wiring with DOMContentLoaded
All event listeners for sections 1, 2, and 5 are registered inside a singleDOMContentLoaded callback. This guarantees the DOM is fully parsed before any querySelector or getElementById call runs:
The script checks
if (!botonInterno) return; and if (imgEspecialidad) before attaching listeners. Similarly, the category search uses if (formularioBuscador) before adding the submit listener. These null-guard checks make buscador.js safe to include on any page — elements that are absent simply skip their setup without throwing a TypeError.3. AJAX User Registration
Thesaludar() function is a standalone function called directly from the registration form. It collects four fields — names, surnames, age, and gender — validates them client-side, then sends a POST request to guardar_usuario.php using the Fetch API with a FormData body.
The PHP endpoint returns the plain string "EXITO" on success, or an error message on failure. The result is written back into #bloqueResultadoSaludo without a page reload:
⏳ Conectando con MySQL...) is shown immediately after submission so the user receives feedback before the server responds.
4. Payroll Calculator
ThecalcularYMostrar() function implements a simple Peruvian income-tax retention table. It reads a name and gross salary, applies a tiered tax rate, then populates a <table> (#tablaResultados) with the results:
5. Category Search Sidebar
The#formularioBuscador form contains a <select id="categoria"> whose value attributes are URLs (relative paths to category pages). The script intercepts the default form submission, reads the selected URL, and navigates there directly:
event.preventDefault() stops the browser from appending query parameters to the URL, keeping the navigation clean. If the user submits without selecting a category (empty value), the if (categoriaSeleccionada) guard silently does nothing.
Dependencies
No JS frameworks
buscador.js is plain ES6. There is no jQuery, no Alpine.js, no React — only native browser APIs (document.querySelector, addEventListener, fetch, window.location).Font Awesome via CDN
Icons used inside buttons (e.g., the WhatsApp brand icon
fa-brands fa-whatsapp) come from Font Awesome 6.4.0, loaded in <head>:whatsapp_interactivo.js
A second script,
whatsapp_interactivo.js, is also loaded in index.php after buscador.js. It is a separate file that may contain additional WhatsApp-specific logic. The two scripts are independent — buscador.js already handles all .btn-wsp-pedido and #btn-wsp-flotante click events internally.