Spaces:
Running
Running
Download script.js from Maxew/cookie-crumbles-delight: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/spaces/Maxew/cookie-crumbles-delight/resolve/main/script.js
- Command line
-
hf download hf://spaces/Maxew/cookie-crumbles-delight/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Maxew/cookie-crumbles-delight/resolve/main/script.js
1.91 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Add to cart functionality | |
| const addToCartButtons = document.querySelectorAll('button:contains("Add to Cart")'); | |
| addToCartButtons.forEach(button => { | |
| button.addEventListener('click', function() { | |
| const productName = this.closest('.bg-white').querySelector('h3').textContent; | |
| const productPrice = this.closest('.bg-white').querySelector('span').textContent; | |
| // Create cookie animation | |
| const cookie = document.createElement('div'); | |
| cookie.innerHTML = '<i data-feather="cookie" class="text-cookie-500"></i>'; | |
| cookie.className = 'fixed bottom-4 right-4 text-4xl cookie-spin'; | |
| document.body.appendChild(cookie); | |
| feather.replace(); | |
| // Show notification | |
| const notification = document.createElement('div'); | |
| notification.className = 'fixed bottom-4 left-4 bg-white text-cookie-800 px-4 py-2 rounded-lg shadow-lg flex items-center'; | |
| notification.innerHTML = ` | |
| <i data-feather="check-circle" class="text-green-500 mr-2"></i> | |
| Added ${productName} (${productPrice}) to cart! | |
| `; | |
| document.body.appendChild(notification); | |
| feather.replace(); | |
| // Remove notification after 3 seconds | |
| setTimeout(() => { | |
| notification.remove(); | |
| cookie.remove(); | |
| }, 3000); | |
| }); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| }); |