Download index.html from alicari/undefined: direct link, hf CLI and curl.
- Browser
- Download file 14.5 kB
-
https://huggingface.co/spaces/alicari/undefined/resolve/main/index.html
- Command line
-
hf download hf://spaces/alicari/undefined/index.html
-
curl -L -o index.html https://huggingface.co/spaces/alicari/undefined/resolve/main/index.html
14.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>FerreApp - Tu Ferretería Digital</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: '#3B82F6', | |
| secondary: '#10B981', | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| .product-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); | |
| } | |
| .cart-item { | |
| transition: all 0.2s ease; | |
| } | |
| .cart-item:hover { | |
| background-color: #f8fafc; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <!-- Header --> | |
| <header class="bg-white shadow-sm"> | |
| <div class="container mx-auto px-4 py-4 flex justify-between items-center"> | |
| <h1 class="text-2xl font-bold text-primary">FerreApp 🛠️</h1> | |
| <div class="relative"> | |
| <button id="cart-btn" class="flex items-center space-x-1 bg-gray-100 hover:bg-gray-200 px-4 py-2 rounded-full transition"> | |
| <i data-feather="shopping-cart"></i> | |
| <span id="cart-count" class="bg-primary text-white rounded-full w-6 h-6 flex items-center justify-center text-xs">0</span> | |
| </button> | |
| <div id="cart-dropdown" class="hidden absolute right-0 mt-2 w-72 bg-white rounded-lg shadow-xl z-50 border border-gray-200"> | |
| <div class="p-4 border-b border-gray-200"> | |
| <h3 class="font-semibold text-gray-700">Tu Carrito</h3> | |
| </div> | |
| <div id="cart-items" class="max-h-64 overflow-y-auto p-2"> | |
| <p class="text-gray-500 text-sm p-4 text-center">Tu carrito está vacío</p> | |
| </div> | |
| <div class="p-4 border-t border-gray-200 flex justify-between items-center"> | |
| <span class="font-semibold">Total:</span> | |
| <span id="cart-total" class="font-bold">$0.00</span> | |
| </div> | |
| <button id="checkout-btn" class="w-full bg-primary hover:bg-blue-600 text-white py-2 px-4 rounded-b-lg transition disabled:opacity-50" disabled> | |
| Pagar por WhatsApp | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-8"> | |
| <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">Nuestros Productos</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6"> | |
| <!-- Products will be loaded dynamically from Google Sheets --> | |
| <div class="col-span-full text-center py-8"> | |
| <p class="text-gray-500">Cargando productos...</p> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="bg-gray-100 py-6 mt-12"> | |
| <div class="container mx-auto px-4 text-center text-gray-600"> | |
| <p>© 2023 FerreApp. Todos los derechos reservados.</p> | |
| <div class="flex justify-center space-x-4 mt-2"> | |
| <a href="#" class="text-gray-500 hover:text-primary transition"><i data-feather="instagram"></i></a> | |
| <a href="#" class="text-gray-500 hover:text-primary transition"><i data-feather="twitter"></i></a> | |
| <a href="#" class="text-gray-500 hover:text-primary transition"><i data-feather="facebook"></i></a> | |
| </div> | |
| </div> | |
| </footer> | |
| <script> | |
| // Initialize feather icons | |
| feather.replace(); | |
| // Load products from Google Sheet | |
| const sheetId = '1CVQYJmTc6FM1Okm6JShnOi2llZatjgmBym4pqHfmbmo'; | |
| const products = []; | |
| fetch(`https://docs.google.com/spreadsheets/d/${sheetId}/gviz/tq?tqx=out:json`) | |
| .then(res => res.text()) | |
| .then(text => { | |
| const json = JSON.parse(text.substr(47).slice(0, -2)); | |
| const sheetData = json.table.rows; | |
| const productsContainer = document.querySelector('.grid'); | |
| productsContainer.innerHTML = ''; // Clear default products | |
| sheetData.forEach((row, i) => { | |
| const product = { | |
| id: i+1, | |
| name: row.c[0].v, | |
| brand: row.c[1]?.v || '', | |
| price: parseFloat(row.c[2].v), | |
| photo: row.c[3]?.f ? `https://docs.google.com/spreadsheets/d/${sheetId}/export?format=image&id=${sheetId}&gid=0&range=${row.c[3].f.replace('=IMAGE("', '').replace('")', '')}` : `http://static.photos/technology/640x360/${i+1}`, | |
| category: row.c[4]?.v || 'General' | |
| }; | |
| products.push(product); | |
| productsContainer.innerHTML += ` | |
| <div class="product-card bg-white rounded-lg overflow-hidden shadow-md transition duration-300"> | |
| <img src="${product.photo}" alt="${product.name}" class="w-full h-48 object-cover" onerror="this.src='http://static.photos/technology/640x360/${i+1}'"> | |
| <div class="p-4"> | |
| <h3 class="font-bold text-lg mb-2">${product.name}</h3> | |
| ${product.brand ? `<p class="text-gray-500 text-xs mb-1">Marca: ${product.brand}</p>` : ''} | |
| <p class="text-gray-600 text-sm mb-3">${product.category}</p> | |
| <div class="flex justify-between items-center"> | |
| <span class="font-bold text-primary">${product.price.toFixed(2)}</span> | |
| <button class="add-to-cart bg-secondary hover:bg-emerald-600 text-white px-3 py-1 rounded-full text-xs transition" | |
| data-id="${product.id}" | |
| data-name="${product.name}" | |
| data-price="${product.price}"> | |
| Añadir al Carrito | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| // Reattach event listeners to new buttons | |
| document.querySelectorAll('.add-to-cart').forEach(button => { | |
| button.addEventListener('click', addToCartHandler); | |
| }); | |
| }) | |
| .catch(error => { | |
| console.error('Error loading products:', error); | |
| // Fallback to default products if sheet fails | |
| document.querySelector('.grid').innerHTML = ` | |
| <div class="col-span-full text-center py-8"> | |
| <p class="text-red-500">No se pudieron cargar los productos. Por favor intente más tarde.</p> | |
| </div> | |
| `; | |
| feather.replace(); | |
| }); | |
| // Cart functionality | |
| let cart = []; | |
| function addToCartHandler() { | |
| const id = this.dataset.id; | |
| const name = this.dataset.name; | |
| const price = parseFloat(this.dataset.price); | |
| // Check if item already exists in cart | |
| const existingItem = cart.find(item => item.id === id); | |
| if (existingItem) { | |
| existingItem.quantity += 1; | |
| } else { | |
| cart.push({ | |
| id, | |
| name, | |
| price, | |
| quantity: 1 | |
| }); | |
| } | |
| updateCart(); | |
| showCartNotification(name); | |
| } | |
| const cartBtn = document.getElementById('cart-btn'); | |
| const cartDropdown = document.getElementById('cart-dropdown'); | |
| const cartItemsContainer = document.getElementById('cart-items'); | |
| const cartCount = document.getElementById('cart-count'); | |
| const cartTotal = document.getElementById('cart-total'); | |
| const checkoutBtn = document.getElementById('checkout-btn'); | |
| const addToCartButtons = document.querySelectorAll('.add-to-cart'); | |
| // Toggle cart dropdown | |
| cartBtn.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| cartDropdown.classList.toggle('hidden'); | |
| }); | |
| // Close cart dropdown when clicking outside | |
| document.addEventListener('click', () => { | |
| cartDropdown.classList.add('hidden'); | |
| }); | |
| // Add to cart functionality | |
| document.querySelectorAll('.add-to-cart').forEach(button => { | |
| button.addEventListener('click', addToCartHandler); | |
| }); | |
| // Update cart UI | |
| function updateCart() { | |
| // Update cart count | |
| const totalItems = cart.reduce((total, item) => total + item.quantity, 0); | |
| cartCount.textContent = totalItems; | |
| // Update cart items list | |
| if (cart.length === 0) { | |
| cartItemsContainer.innerHTML = '<p class="text-gray-500 text-sm p-4 text-center">Your cart is empty</p>'; | |
| checkoutBtn.disabled = true; | |
| } else { | |
| checkoutBtn.disabled = false; | |
| let itemsHTML = ''; | |
| cart.forEach(item => { | |
| itemsHTML += ` | |
| <div class="cart-item flex justify-between items-center p-3 border-b border-gray-100"> | |
| <div class="flex-1"> | |
| <h4 class="text-sm font-medium">${item.name}</h4> | |
| <p class="text-xs text-gray-500">$${item.price.toFixed(2)} x ${item.quantity}</p> | |
| </div> | |
| <div class="flex items-center"> | |
| <button class="remove-item text-red-500 hover:text-red-700 text-xs" data-id="${item.id}"> | |
| <i data-feather="trash-2" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| cartItemsContainer.innerHTML = itemsHTML; | |
| // Add event listeners to remove buttons | |
| document.querySelectorAll('.remove-item').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| const id = button.dataset.id; | |
| cart = cart.filter(item => item.id !== id); | |
| updateCart(); | |
| }); | |
| }); | |
| feather.replace(); | |
| } | |
| // Update cart total | |
| const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0); | |
| cartTotal.textContent = `$${total.toFixed(2)}`; | |
| } | |
| // Show notification when adding to cart | |
| function showCartNotification(productName) { | |
| const notification = document.createElement('div'); | |
| notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg animate-fade-in-up'; | |
| notification.innerHTML = ` | |
| <div class="flex items-center"> | |
| <i data-feather="check-circle" class="mr-2"></i> | |
| <span>¡${productName} añadido al carrito!</span> | |
| </div> | |
| `; | |
| document.body.appendChild(notification); | |
| feather.replace(); | |
| setTimeout(() => { | |
| notification.classList.add('animate-fade-out'); | |
| setTimeout(() => { | |
| notification.remove(); | |
| }, 500); | |
| }, 3000); | |
| } | |
| // Checkout functionality | |
| checkoutBtn.addEventListener('click', () => { | |
| if (cart.length === 0) return; | |
| // Prepare WhatsApp message | |
| let message = "¡Hola! Me gustaría comprar los siguientes productos:\n\n"; | |
| cart.forEach(item => { | |
| message += `- ${item.name} (${item.quantity} x ${item.price.toFixed(2)})\n`; | |
| }); | |
| const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0); | |
| message += `\nTotal: ${total.toFixed(2)}\n\nPor favor indíqueme disponibilidad y formas de pago.`; | |
| // Encode message for URL | |
| const encodedMessage = encodeURIComponent(message); | |
| // Open WhatsApp with the message | |
| window.open(`https://wa.me/5491141819344?text=${encodedMessage}`, '_blank'); | |
| }); | |
| // Simple animations | |
| anime({ | |
| targets: '.product-card', | |
| opacity: [0, 1], | |
| translateY: [20, 0], | |
| duration: 800, | |
| delay: anime.stagger(100, {start: 100}), | |
| easing: 'easeOutQuad' | |
| }); | |
| // Add some CSS animations | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| @keyframes fadeInUp { | |
| from { | |
| opacity: 0; | |
| transform: translateY(20px); | |
| } | |
| to { | |
| opacity: 1; | |
| transform: translateY(0); | |
| } | |
| } | |
| @keyframes fadeOut { | |
| from { | |
| opacity: 1; | |
| } | |
| to { | |
| opacity: 0; | |
| } | |
| } | |
| .animate-fade-in-up { | |
| animation: fadeInUp 0.3s ease-out forwards; | |
| } | |
| .animate-fade-out { | |
| animation: fadeOut 0.5s ease-out forwards; | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| </script> | |
| </body> | |
| </html> | |