Spaces:
Running
Running
Download script.js from seifshehata/loginflow-pro: direct link, hf CLI and curl.
- Browser
- Download file 4.52 kB
-
https://huggingface.co/spaces/seifshehata/loginflow-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/seifshehata/loginflow-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/seifshehata/loginflow-pro/resolve/main/script.js
4.52 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize cart count | |
| const cartCount = document.getElementById('cart-count'); | |
| const cartItems = JSON.parse(localStorage.getItem('cart')) || []; | |
| if (cartItems.length > 0) { | |
| cartCount.textContent = cartItems.length; | |
| cartCount.classList.remove('hidden'); | |
| } | |
| // Tab switching functionality | |
| const loginTab = document.getElementById('login-tab'); | |
| const signupTab = document.getElementById('signup-tab'); | |
| const loginForm = document.getElementById('login-form'); | |
| const signupForm = document.getElementById('signup-form'); | |
| loginTab.addEventListener('click', function() { | |
| loginTab.classList.add('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400'); | |
| loginTab.classList.remove('text-gray-500', 'dark:text-gray-400'); | |
| signupTab.classList.add('text-gray-500', 'dark:text-gray-400'); | |
| signupTab.classList.remove('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400'); | |
| loginForm.classList.remove('hidden'); | |
| signupForm.classList.add('hidden'); | |
| }); | |
| signupTab.addEventListener('click', function() { | |
| signupTab.classList.add('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400'); | |
| signupTab.classList.remove('text-gray-500', 'dark:text-gray-400'); | |
| loginTab.classList.add('text-gray-500', 'dark:text-gray-400'); | |
| loginTab.classList.remove('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400'); | |
| signupForm.classList.remove('hidden'); | |
| loginForm.classList.add('hidden'); | |
| }); | |
| // Form submission handling | |
| const forms = document.querySelectorAll('form'); | |
| forms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Add your form submission logic here | |
| alert('تم إرسال النموذج بنجاح!'); | |
| }); | |
| }); | |
| // Payment method selection | |
| document.querySelectorAll('input[name="payment"]').forEach(radio => { | |
| radio.addEventListener('change', function() { | |
| if (this.id === 'credit-card') { | |
| document.getElementById('credit-card-form').style.display = 'block'; | |
| } else { | |
| document.getElementById('credit-card-form').style.display = 'none'; | |
| } | |
| }); | |
| }); | |
| // Cart functionality | |
| document.addEventListener('click', function(e) { | |
| // Quantity decrease | |
| if (e.target.closest('[data-action="decrease"]')) { | |
| const input = e.target.closest('[data-action="decrease"]').nextElementSibling; | |
| if (parseInt(input.value) > 1) { | |
| input.value = parseInt(input.value) - 1; | |
| updateCartItem(e.target.closest('.flex.items-center.gap-4')); | |
| } | |
| } | |
| // Quantity increase | |
| if (e.target.closest('[data-action="increase"]')) { | |
| const input = e.target.closest('[data-action="increase"]').previousElementSibling; | |
| input.value = parseInt(input.value) + 1; | |
| updateCartItem(e.target.closest('.flex.items-center.gap-4')); | |
| } | |
| // Remove item | |
| if (e.target.closest('[data-action="remove-item"]')) { | |
| e.target.closest('.flex.items-center.gap-4').remove(); | |
| updateCartTotal(); | |
| } | |
| }); | |
| function updateCartItem(itemElement) { | |
| const quantity = parseInt(itemElement.querySelector('span.w-8').textContent); | |
| const price = parseInt(itemElement.querySelector('span.font-medium').textContent.replace(' ر.س', '')); | |
| const total = quantity * price; | |
| itemElement.querySelector('span.font-medium').textContent = `${total} ر.س`; | |
| updateCartTotal(); | |
| } | |
| function updateCartTotal() { | |
| let subtotal = 0; | |
| document.querySelectorAll('.flex.items-center.gap-4').forEach(item => { | |
| const price = parseInt(item.querySelector('span.font-medium').textContent.replace(' ر.س', '')); | |
| subtotal += price; | |
| }); | |
| const shipping = 30; | |
| const total = subtotal + shipping; | |
| document.querySelector('.flex.justify-between:nth-child(1) span:nth-child(2)').textContent = `${subtotal} ر.س`; | |
| document.querySelector('.flex.justify-between.border-t span:nth-child(2)').textContent = `${total} ر.س`; | |
| } | |
| }); |