Download index.html from Yghubpush/dinner: direct link, hf CLI and curl.
- Browser
- Download file 38.9 kB
-
https://huggingface.co/spaces/Yghubpush/dinner/resolve/main/index.html
- Command line
-
hf download hf://spaces/Yghubpush/dinner/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Yghubpush/dinner/resolve/main/index.html
38.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Meal Order System</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .fade-in { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .meal-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); | |
| } | |
| .tab-active { | |
| border-bottom: 3px solid #3b82f6; | |
| color: #3b82f6; | |
| font-weight: 600; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8 max-w-6xl"> | |
| <!-- Header --> | |
| <header class="mb-8 text-center"> | |
| <h1 class="text-4xl font-bold text-blue-600 mb-2">Meal Order System</h1> | |
| <p class="text-gray-600">Order your favorite meals with ease</p> | |
| </header> | |
| <!-- Main Content --> | |
| <div class="bg-white rounded-xl shadow-lg overflow-hidden"> | |
| <!-- Tabs Navigation --> | |
| <div class="flex border-b border-gray-200"> | |
| <button onclick="switchTab('order')" class="tab-button flex-1 py-4 px-6 text-center font-medium text-gray-500 hover:text-blue-500 focus:outline-none" id="order-tab"> | |
| <i class="fas fa-utensils mr-2"></i>Order | |
| </button> | |
| <button onclick="switchTab('query')" class="tab-button flex-1 py-4 px-6 text-center font-medium text-gray-500 hover:text-blue-500 focus:outline-none" id="query-tab"> | |
| <i class="fas fa-search mr-2"></i>Query Orders | |
| </button> | |
| <button onclick="switchTab('manage')" class="tab-button flex-1 py-4 px-6 text-center font-medium text-gray-500 hover:text-blue-500 focus:outline-none" id="manage-tab"> | |
| <i class="fas fa-trash-alt mr-2"></i>Delete Orders | |
| </button> | |
| </div> | |
| <!-- Order Tab Content --> | |
| <div id="order-content" class="p-6 fade-in"> | |
| <h2 class="text-2xl font-semibold mb-6 text-gray-800">Place Your Order</h2> | |
| <!-- Meal Type Selection --> | |
| <div class="mb-8"> | |
| <h3 class="text-lg font-medium text-gray-700 mb-4">Select Meal Type</h3> | |
| <div class="grid grid-cols-2 md:grid-cols-4 gap-4"> | |
| <button onclick="selectMealType('breakfast')" class="meal-type-btn py-3 px-4 rounded-lg bg-blue-50 text-blue-600 border border-blue-200 hover:bg-blue-100 transition flex items-center justify-center"> | |
| <i class="fas fa-sun mr-2"></i> Breakfast | |
| </button> | |
| <button onclick="selectMealType('lunch')" class="meal-type-btn py-3 px-4 rounded-lg bg-green-50 text-green-600 border border-green-200 hover:bg-green-100 transition flex items-center justify-center"> | |
| <i class="fas fa-utensils mr-2"></i> Lunch | |
| </button> | |
| <button onclick="selectMealType('dinner')" class="meal-type-btn py-3 px-4 rounded-lg bg-purple-50 text-purple-600 border border-purple-200 hover:bg-purple-100 transition flex items-center justify-center"> | |
| <i class="fas fa-moon mr-2"></i> Dinner | |
| </button> | |
| <button onclick="selectMealType('supply')" class="meal-type-btn py-3 px-4 rounded-lg bg-yellow-50 text-yellow-600 border border-yellow-200 hover:bg-yellow-100 transition flex items-center justify-center"> | |
| <i class="fas fa-box-open mr-2"></i> Supply | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Meal Selection --> | |
| <div id="meal-selection" class="mb-8"> | |
| <h3 class="text-lg font-medium text-gray-700 mb-4">Available Meals</h3> | |
| <div id="meal-cards" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> | |
| <!-- Meals will be loaded here dynamically --> | |
| </div> | |
| </div> | |
| <!-- Order Form --> | |
| <div class="bg-gray-50 p-6 rounded-lg"> | |
| <h3 class="text-lg font-medium text-gray-700 mb-4">Your Order Details</h3> | |
| <form id="order-form" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name</label> | |
| <input type="text" id="name" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="table" class="block text-sm font-medium text-gray-700 mb-1">Table Number</label> | |
| <input type="text" id="table" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="special-requests" class="block text-sm font-medium text-gray-700 mb-1">Special Requests</label> | |
| <textarea id="special-requests" rows="2" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"></textarea> | |
| </div> | |
| <div id="selected-items" class="border border-gray-200 rounded-lg p-4"> | |
| <h4 class="text-sm font-medium text-gray-700 mb-2">Selected Items</h4> | |
| <div id="order-items" class="space-y-2"> | |
| <p class="text-gray-500 text-sm">No items selected yet</p> | |
| </div> | |
| <div id="order-total" class="mt-3 pt-3 border-t border-gray-200 text-right font-medium text-gray-800 hidden"> | |
| Total: $<span id="total-amount">0.00</span> | |
| </div> | |
| </div> | |
| <button type="submit" class="w-full bg-blue-600 text-white py-3 px-4 rounded-md hover:bg-blue-700 transition flex items-center justify-center"> | |
| <i class="fas fa-paper-plane mr-2"></i> Place Order | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| <!-- Query Tab Content --> | |
| <div id="query-content" class="p-6 hidden fade-in"> | |
| <h2 class="text-2xl font-semibold mb-6 text-gray-800">Order Query</h2> | |
| <div class="bg-gray-50 p-6 rounded-lg mb-6"> | |
| <h3 class="text-lg font-medium text-gray-700 mb-4">Search Orders</h3> | |
| <form id="query-form" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <div> | |
| <label for="query-name" class="block text-sm font-medium text-gray-700 mb-1">Name</label> | |
| <input type="text" id="query-name" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="query-table" class="block text-sm font-medium text-gray-700 mb-1">Table Number</label> | |
| <input type="text" id="query-table" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="query-date" class="block text-sm font-medium text-gray-700 mb-1">Date</label> | |
| <input type="date" id="query-date" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| </div> | |
| <button type="submit" class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition flex items-center justify-center"> | |
| <i class="fas fa-search mr-2"></i> Search Orders | |
| </button> | |
| </form> | |
| </div> | |
| <div id="query-results" class="border border-gray-200 rounded-lg overflow-hidden"> | |
| <div class="bg-gray-100 px-6 py-3 border-b border-gray-200 flex justify-between items-center"> | |
| <h3 class="font-medium text-gray-700">Search Results</h3> | |
| <span id="results-count" class="text-sm text-gray-500">0 orders found</span> | |
| </div> | |
| <div id="orders-list" class="divide-y divide-gray-200"> | |
| <div class="p-4 text-center text-gray-500"> | |
| No orders to display. Perform a search to see results. | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Delete Tab Content --> | |
| <div id="manage-content" class="p-6 hidden fade-in"> | |
| <h2 class="text-2xl font-semibold mb-6 text-gray-800">Manage Orders</h2> | |
| <div class="bg-gray-50 p-6 rounded-lg mb-6"> | |
| <h3 class="text-lg font-medium text-gray-700 mb-4">Delete Orders</h3> | |
| <form id="delete-form" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <div> | |
| <label for="delete-id" class="block text-sm font-medium text-gray-700 mb-1">Order ID</label> | |
| <input type="text" id="delete-id" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="delete-name" class="block text-sm font-medium text-gray-700 mb-1">Name</label> | |
| <input type="text" id="delete-name" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="delete-table" class="block text-sm font-medium text-gray-700 mb-1">Table Number</label> | |
| <input type="text" id="delete-table" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <button type="submit" class="bg-red-600 text-white py-2 px-4 rounded-md hover:bg-red-700 transition flex-1 flex items-center justify-center"> | |
| <i class="fas fa-trash-alt mr-2"></i> Delete Orders | |
| </button> | |
| <button type="button" onclick="clearAllOrders()" class="bg-gray-600 text-white py-2 px-4 rounded-md hover:bg-gray-700 transition flex-1 flex items-center justify-center"> | |
| <i class="fas fa-broom mr-2"></i> Clear All | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| <div id="delete-results" class="border border-gray-200 rounded-lg overflow-hidden"> | |
| <div class="bg-gray-100 px-6 py-3 border-b border-gray-200 flex justify-between items-center"> | |
| <h3 class="font-medium text-gray-700">All Orders</h3> | |
| <span id="delete-count" class="text-sm text-gray-500">0 orders in system</span> | |
| </div> | |
| <div id="delete-list" class="divide-y divide-gray-200"> | |
| <div class="p-4 text-center text-gray-500"> | |
| No orders in the system. | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Success Modal --> | |
| <div id="success-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg p-6 max-w-md w-full mx-4 transform transition-all fade-in"> | |
| <div class="text-center"> | |
| <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100 mb-4"> | |
| <i class="fas fa-check text-green-600 text-xl"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-gray-900 mb-2" id="success-title">Success!</h3> | |
| <div class="mt-2 text-sm text-gray-500" id="success-message"> | |
| Your order has been placed successfully. | |
| </div> | |
| <div class="mt-4"> | |
| <button onclick="closeModal('success-modal')" type="button" class="inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none sm:text-sm"> | |
| OK | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Confirmation Modal --> | |
| <div id="confirm-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg p-6 max-w-md w-full mx-4 transform transition-all fade-in"> | |
| <div class="text-center"> | |
| <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-red-100 mb-4"> | |
| <i class="fas fa-exclamation text-red-600 text-xl"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-gray-900 mb-2" id="confirm-title">Confirm Deletion</h3> | |
| <div class="mt-2 text-sm text-gray-500" id="confirm-message"> | |
| Are you sure you want to delete these orders? This action cannot be undone. | |
| </div> | |
| <div class="mt-4 flex justify-center space-x-4"> | |
| <button onclick="closeModal('confirm-modal')" type="button" class="inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:text-sm"> | |
| Cancel | |
| </button> | |
| <button onclick="confirmDeletion()" type="button" class="inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none sm:text-sm"> | |
| Delete | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Sample data for meals | |
| const mealData = { | |
| breakfast: [ | |
| { id: 1, name: "Pancakes", description: "Fluffy pancakes with maple syrup", price: 8.99, image: "🍞" }, | |
| { id: 2, name: "Omelette", description: "Three-egg omelette with cheese and vegetables", price: 9.99, image: "🍳" }, | |
| { id: 3, name: "French Toast", description: "Thick slices of bread dipped in egg batter", price: 7.99, image: "🥖" }, | |
| { id: 4, name: "Yogurt Parfait", description: "Greek yogurt with granola and fresh berries", price: 6.99, image: "🥣" }, | |
| { id: 5, name: "Breakfast Burrito", description: "Scrambled eggs, cheese, and sausage in a tortilla", price: 10.99, image: "🌯" } | |
| ], | |
| lunch: [ | |
| { id: 6, name: "Caesar Salad", description: "Romaine lettuce, croutons, parmesan cheese", price: 10.99, image: "🥗" }, | |
| { id: 7, name: "Club Sandwich", description: "Triple-decker sandwich with turkey, bacon, and veggies", price: 11.99, image: "🥪" }, | |
| { id: 8, name: "Margherita Pizza", description: "Classic pizza with tomato sauce, mozzarella, and basil", price: 12.99, image: "🍕" }, | |
| { id: 9, name: "Beef Burger", description: "Juicy beef patty with cheese and special sauce", price: 13.99, image: "🍔" }, | |
| { id: 10, name: "Chicken Wrap", description: "Grilled chicken with veggies in a tortilla", price: 9.99, image: "🌯" } | |
| ], | |
| dinner: [ | |
| { id: 11, name: "Grilled Salmon", description: "Fresh salmon with lemon butter sauce", price: 18.99, image: "🐟" }, | |
| { id: 12, name: "Filet Mignon", description: "Tender beef filet with red wine reduction", price: 24.99, image: "🥩" }, | |
| { id: 13, name: "Chicken Alfredo", description: "Fettuccine pasta with creamy alfredo sauce", price: 15.99, image: "🍝" }, | |
| { id: 14, name: "Vegetable Stir Fry", description: "Assorted vegetables with tofu in teriyaki sauce", price: 13.99, image: "🥡" }, | |
| { id: 15, name: "Shrimp Scampi", description: "Shrimp sautéed in garlic butter sauce", price: 19.99, image: "🍤" } | |
| ], | |
| supply: [ | |
| { id: 16, name: "Bottled Water", description: "500ml mineral water", price: 1.99, image: "💧" }, | |
| { id: 17, name: "Soft Drink", description: "Coke, Sprite, or Fanta", price: 2.99, image: "🥤" }, | |
| { id: 18, name: "Coffee", description: "Freshly brewed coffee", price: 3.49, image: "☕" }, | |
| { id: 19, name: "Tea", description: "Selection of herbal teas", price: 2.99, image: "🍵" }, | |
| { id: 20, name: "Juice", description: "Orange, apple, or cranberry juice", price: 3.99, image: "🧃" } | |
| ] | |
| }; | |
| // Orders storage | |
| let orders = JSON.parse(localStorage.getItem('orders')) || []; | |
| let selectedMeals = []; | |
| let currentMealType = 'breakfast'; | |
| let ordersToDelete = []; | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Set default tab | |
| switchTab('order'); | |
| // Load breakfast meals by default | |
| loadMeals(currentMealType); | |
| // Set up event listeners | |
| document.getElementById('order-form').addEventListener('submit', placeOrder); | |
| document.getElementById('query-form').addEventListener('submit', queryOrders); | |
| document.getElementById('delete-form').addEventListener('submit', prepareDeletion); | |
| // Load all orders for delete tab | |
| loadAllOrders(); | |
| }); | |
| // Tab switching | |
| function switchTab(tab) { | |
| // Hide all content | |
| document.getElementById('order-content').classList.add('hidden'); | |
| document.getElementById('query-content').classList.add('hidden'); | |
| document.getElementById('manage-content').classList.add('hidden'); | |
| // Remove active class from all tabs | |
| document.querySelectorAll('.tab-button').forEach(btn => { | |
| btn.classList.remove('tab-active'); | |
| }); | |
| // Show selected content and mark tab as active | |
| document.getElementById(`${tab}-content`).classList.remove('hidden'); | |
| document.getElementById(`${tab}-tab`).classList.add('tab-active'); | |
| } | |
| // Meal type selection | |
| function selectMealType(type) { | |
| currentMealType = type; | |
| loadMeals(type); | |
| // Update active button | |
| document.querySelectorAll('.meal-type-btn').forEach(btn => { | |
| btn.classList.remove('bg-blue-100', 'bg-green-100', 'bg-purple-100', 'bg-yellow-100'); | |
| btn.classList.add('bg-blue-50', 'bg-green-50', 'bg-purple-50', 'bg-yellow-50'); | |
| }); | |
| const activeBtn = document.querySelector(`.meal-type-btn:nth-child(${ | |
| type === 'breakfast' ? 1 : | |
| type === 'lunch' ? 2 : | |
| type === 'dinner' ? 3 : 4 | |
| })`); | |
| activeBtn.classList.remove('bg-blue-50', 'bg-green-50', 'bg-purple-50', 'bg-yellow-50'); | |
| activeBtn.classList.add( | |
| type === 'breakfast' ? 'bg-blue-100' : | |
| type === 'lunch' ? 'bg-green-100' : | |
| type === 'dinner' ? 'bg-purple-100' : 'bg-yellow-100' | |
| ); | |
| } | |
| // Load meals for selected type | |
| function loadMeals(type) { | |
| const mealsContainer = document.getElementById('meal-cards'); | |
| mealsContainer.innerHTML = ''; | |
| mealData[type].forEach(meal => { | |
| const mealCard = document.createElement('div'); | |
| mealCard.className = 'meal-card bg-white border border-gray-200 rounded-lg p-4 transition cursor-pointer hover:shadow-md'; | |
| mealCard.innerHTML = ` | |
| <div class="flex items-start"> | |
| <div class="text-4xl mr-4">${meal.image}</div> | |
| <div> | |
| <h4 class="font-medium text-gray-800">${meal.name}</h4> | |
| <p class="text-sm text-gray-600 mb-2">${meal.description}</p> | |
| <div class="flex justify-between items-center"> | |
| <span class="font-medium text-blue-600">$${meal.price.toFixed(2)}</span> | |
| <button onclick="addToOrder(${meal.id}, event)" class="text-sm bg-blue-50 text-blue-600 py-1 px-3 rounded hover:bg-blue-100 transition"> | |
| <i class="fas fa-plus mr-1"></i> Add | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| mealsContainer.appendChild(mealCard); | |
| }); | |
| } | |
| // Add meal to order | |
| function addToOrder(mealId, event) { | |
| event.stopPropagation(); | |
| // Find the meal in all categories | |
| let meal = null; | |
| for (const type in mealData) { | |
| meal = mealData[type].find(m => m.id === mealId); | |
| if (meal) break; | |
| } | |
| if (!meal) return; | |
| // Check if already added | |
| const existingIndex = selectedMeals.findIndex(m => m.id === meal.id); | |
| if (existingIndex >= 0) { | |
| selectedMeals[existingIndex].quantity += 1; | |
| } else { | |
| selectedMeals.push({ | |
| ...meal, | |
| quantity: 1 | |
| }); | |
| } | |
| updateOrderSummary(); | |
| // Show success feedback | |
| const button = event.target.closest('button'); | |
| button.innerHTML = '<i class="fas fa-check mr-1"></i> Added'; | |
| button.classList.remove('bg-blue-50', 'hover:bg-blue-100'); | |
| button.classList.add('bg-green-50', 'hover:bg-green-100'); | |
| setTimeout(() => { | |
| button.innerHTML = '<i class="fas fa-plus mr-1"></i> Add'; | |
| button.classList.remove('bg-green-50', 'hover:bg-green-100'); | |
| button.classList.add('bg-blue-50', 'hover:bg-blue-100'); | |
| }, 1000); | |
| } | |
| // Update order summary | |
| function updateOrderSummary() { | |
| const orderItems = document.getElementById('order-items'); | |
| const orderTotal = document.getElementById('order-total'); | |
| if (selectedMeals.length === 0) { | |
| orderItems.innerHTML = '<p class="text-gray-500 text-sm">No items selected yet</p>'; | |
| orderTotal.classList.add('hidden'); | |
| return; | |
| } | |
| orderItems.innerHTML = ''; | |
| let total = 0; | |
| selectedMeals.forEach((meal, index) => { | |
| const itemTotal = meal.price * meal.quantity; | |
| total += itemTotal; | |
| const item = document.createElement('div'); | |
| item.className = 'flex justify-between items-center'; | |
| item.innerHTML = ` | |
| <div> | |
| <span class="font-medium text-gray-800">${meal.name}</span> | |
| <span class="text-xs text-gray-500 ml-2">x${meal.quantity}</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <span class="text-gray-700 mr-3">$${itemTotal.toFixed(2)}</span> | |
| <button onclick="removeFromOrder(${index}, event)" class="text-red-500 hover:text-red-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| `; | |
| orderItems.appendChild(item); | |
| }); | |
| document.getElementById('total-amount').textContent = total.toFixed(2); | |
| orderTotal.classList.remove('hidden'); | |
| } | |
| // Remove item from order | |
| function removeFromOrder(index, event) { | |
| event.stopPropagation(); | |
| selectedMeals.splice(index, 1); | |
| updateOrderSummary(); | |
| } | |
| // Place order | |
| function placeOrder(e) { | |
| e.preventDefault(); | |
| if (selectedMeals.length === 0) { | |
| showModal('Please select at least one item to order', 'Error', 'error'); | |
| return; | |
| } | |
| const name = document.getElementById('name').value.trim(); | |
| const table = document.getElementById('table').value.trim(); | |
| const requests = document.getElementById('special-requests').value.trim(); | |
| if (!name || !table) { | |
| showModal('Please provide your name and table number', 'Error', 'error'); | |
| return; | |
| } | |
| // Calculate total | |
| const total = selectedMeals.reduce((sum, meal) => sum + (meal.price * meal.quantity), 0); | |
| // Create order | |
| const order = { | |
| id: Date.now(), | |
| name, | |
| table, | |
| specialRequests: requests, | |
| meals: [...selectedMeals], | |
| total, | |
| date: new Date().toISOString(), | |
| type: currentMealType | |
| }; | |
| // Save to storage | |
| orders.push(order); | |
| localStorage.setItem('orders', JSON.stringify(orders)); | |
| // Reset form | |
| document.getElementById('order-form').reset(); | |
| selectedMeals = []; | |
| updateOrderSummary(); | |
| // Show success | |
| showModal(`Order #${order.id} has been placed successfully. Total: $${total.toFixed(2)}`, 'Order Placed!', 'success'); | |
| // Update delete tab | |
| loadAllOrders(); | |
| } | |
| // Query orders | |
| function queryOrders(e) { | |
| e.preventDefault(); | |
| const name = document.getElementById('query-name').value.trim().toLowerCase(); | |
| const table = document.getElementById('query-table').value.trim().toLowerCase(); | |
| const date = document.getElementById('query-date').value; | |
| let results = [...orders]; | |
| if (name) { | |
| results = results.filter(order => order.name.toLowerCase().includes(name)); | |
| } | |
| if (table) { | |
| results = results.filter(order => order.table.toLowerCase().includes(table)); | |
| } | |
| if (date) { | |
| const searchDate = new Date(date).toDateString(); | |
| results = results.filter(order => new Date(order.date).toDateString() === searchDate); | |
| } | |
| displayQueryResults(results); | |
| } | |
| // Display query results | |
| function displayQueryResults(results) { | |
| const container = document.getElementById('orders-list'); | |
| const countElement = document.getElementById('results-count'); | |
| countElement.textContent = `${results.length} order${results.length !== 1 ? 's' : ''} found`; | |
| if (results.length === 0) { | |
| container.innerHTML = '<div class="p-4 text-center text-gray-500">No orders match your search criteria.</div>'; | |
| return; | |
| } | |
| container.innerHTML = ''; | |
| results.forEach(order => { | |
| const orderElement = document.createElement('div'); | |
| orderElement.className = 'p-4 hover:bg-gray-50'; | |
| // Format date | |
| const orderDate = new Date(order.date); | |
| const dateStr = orderDate.toLocaleDateString(); | |
| const timeStr = orderDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| orderElement.innerHTML = ` | |
| <div class="flex justify-between items-start mb-2"> | |
| <div> | |
| <span class="font-medium">Order #${order.id}</span> | |
| <span class="text-xs bg-blue-100 text-blue-800 py-1 px-2 rounded-full ml-2 capitalize">${order.type}</span> | |
| </div> | |
| <span class="text-sm text-gray-500">${dateStr} at ${timeStr}</span> | |
| </div> | |
| <div class="text-sm mb-2"> | |
| <span class="font-medium">${order.name}</span> (Table ${order.table}) | |
| </div> | |
| <div class="text-sm mb-3"> | |
| ${order.meals.map(meal => `${meal.name} x${meal.quantity}`).join(', ')} | |
| </div> | |
| <div class="flex justify-between items-center text-sm"> | |
| <div> | |
| ${order.specialRequests ? `<span class="text-gray-600"><i class="fas fa-comment-alt mr-1"></i> ${order.specialRequests}</span>` : ''} | |
| </div> | |
| <span class="font-medium">$${order.total.toFixed(2)}</span> | |
| </div> | |
| `; | |
| container.appendChild(orderElement); | |
| }); | |
| } | |
| // Prepare for deletion | |
| function prepareDeletion(e) { | |
| e.preventDefault(); | |
| const id = document.getElementById('delete-id').value.trim(); | |
| const name = document.getElementById('delete-name').value.trim().toLowerCase(); | |
| const table = document.getElementById('delete-table').value.trim().toLowerCase(); | |
| ordersToDelete = []; | |
| if (id || name || table) { | |
| // Filter orders based on criteria | |
| ordersToDelete = orders.filter(order => { | |
| return (id && order.id.toString().includes(id)) || | |
| (name && order.name.toLowerCase().includes(name)) || | |
| (table && order.table.toLowerCase().includes(table)); | |
| }); | |
| } else { | |
| // If no criteria, select all | |
| ordersToDelete = [...orders]; | |
| } | |
| if (ordersToDelete.length === 0) { | |
| showModal('No orders match your criteria', 'No Orders Found', 'error'); | |
| return; | |
| } | |
| // Show confirmation | |
| document.getElementById('confirm-message').textContent = | |
| `Are you sure you want to delete ${ordersToDelete.length} order${ordersToDelete.length !== 1 ? 's' : ''}? This action cannot be undone.`; | |
| showModal('', 'Confirm Deletion', 'confirm'); | |
| } | |
| // Confirm deletion | |
| function confirmDeletion() { | |
| // Remove orders from storage | |
| orders = orders.filter(order => !ordersToDelete.some(delOrder => delOrder.id === order.id)); | |
| localStorage.setItem('orders', JSON.stringify(orders)); | |
| // Close modal and update UI | |
| closeModal('confirm-modal'); | |
| showModal(`${ordersToDelete.length} order${ordersToDelete.length !== 1 ? 's' : ''} deleted successfully`, 'Success', 'success'); | |
| // Reset form and reload | |
| document.getElementById('delete-form').reset(); | |
| loadAllOrders(); | |
| // Clear selection | |
| ordersToDelete = []; | |
| } | |
| // Clear all orders | |
| function clearAllOrders() { | |
| if (orders.length === 0) { | |
| showModal('There are no orders to clear', 'No Orders', 'error'); | |
| return; | |
| } | |
| ordersToDelete = [...orders]; | |
| document.getElementById('confirm-message').textContent = | |
| `Are you sure you want to delete ALL ${orders.length} orders? This action cannot be undone.`; | |
| showModal('', 'Confirm Deletion', 'confirm'); | |
| } | |
| // Load all orders for delete tab | |
| function loadAllOrders() { | |
| const container = document.getElementById('delete-list'); | |
| const countElement = document.getElementById('delete-count'); | |
| countElement.textContent = `${orders.length} order${orders.length !== 1 ? 's' : ''} in system`; | |
| if (orders.length === 0) { | |
| container.innerHTML = '<div class="p-4 text-center text-gray-500">No orders in the system.</div>'; | |
| return; | |
| } | |
| container.innerHTML = ''; | |
| // Group by date | |
| const ordersByDate = {}; | |
| orders.forEach(order => { | |
| const date = new Date(order.date).toDateString(); | |
| if (!ordersByDate[date]) { | |
| ordersByDate[date] = []; | |
| } | |
| ordersByDate[date].push(order); | |
| }); | |
| // Display by date | |
| for (const date in ordersByDate) { | |
| const dateHeader = document.createElement('div'); | |
| dateHeader.className = 'bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700'; | |
| dateHeader.textContent = date; | |
| container.appendChild(dateHeader); | |
| ordersByDate[date].forEach(order => { | |
| const orderElement = document.createElement('div'); | |
| orderElement.className = 'p-4 hover:bg-gray-50 flex justify-between items-center'; | |
| // Format time | |
| const orderDate = new Date(order.date); | |
| const timeStr = orderDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| orderElement.innerHTML = ` | |
| <div> | |
| <div class="flex items-center mb-1"> | |
| <span class="font-medium mr-2">#${order.id}</span> | |
| <span class="text-xs bg-blue-100 text-blue-800 py-1 px-2 rounded-full capitalize">${order.type}</span> | |
| </div> | |
| <div class="text-sm"> | |
| ${order.name} (Table ${order.table}) • ${timeStr} | |
| </div> | |
| </div> | |
| <div class="text-right"> | |
| <div class="font-medium">$${order.total.toFixed(2)}</div> | |
| <button onclick="deleteSingleOrder(${order.id}, event)" class="text-red-500 hover:text-red-700 text-sm mt-1"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| </div> | |
| `; | |
| container.appendChild(orderElement); | |
| }); | |
| } | |
| } | |
| // Delete single order | |
| function deleteSingleOrder(orderId, event) { | |
| event.stopPropagation(); | |
| ordersToDelete = orders.filter(order => order.id === orderId); | |
| document.getElementById('confirm-message').textContent = | |
| `Are you sure you want to delete order #${orderId}? This action cannot be undone.`; | |
| showModal('', 'Confirm Deletion', 'confirm'); | |
| } | |
| // Show modal | |
| function showModal(message, title, type) { | |
| const modal = document.getElementById(`${type}-modal`); | |
| if (title) document.getElementById(`${type}-title`).textContent = title; | |
| if (message) document.getElementById(`${type}-message`).textContent = message; | |
| modal.classList.remove('hidden'); | |
| } | |
| // Close modal | |
| function closeModal(modalId) { | |
| document.getElementById(modalId).classList.add('hidden'); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Yghubpush/dinner" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |