spiceclassify / index.html
aminekaa's picture
Add 3 files
a66212d verified
Raw History Blame Contribute Delete
61.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SpiceClassify - Automatic Spice Classification</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> /* Custom styles */ :root { --primary: #d97706; --primary-dark: #92400e; --secondary: #f59e0b; --accent: #f97316; --light: #f5f5f4; --dark: #1c1917; } body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background-color: var(--light); color: var(--dark); } .camera-preview { background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); box-shadow: 0 4px 20px rgba(0,0,0,0.08); border-radius: 16px; position: relative; overflow: hidden; } .camera-preview::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8) 0%, transparent 70%); z-index: 1; } .spice-card { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 12px; overflow: hidden; cursor: pointer; } .spice-card:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 10px 25px rgba(0,0,0,0.1); } .spice-card .icon-container { transition: all 0.3s ease; } .spice-card:hover .icon-container { transform: scale(1.1); } .tab-active { border-bottom: 3px solid var(--primary); color: var(--primary-dark); font-weight: 600; } .flavor-badge { transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.05); } .flavor-badge:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .slide-in { animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.1); } @keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } .fade-in { animation: fadeIn 0.5s ease-in; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } /* Header styles */ header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); box-shadow: 0 2px 10px rgba(0,0,0,0.1); position: relative; z-index: 10; } header::after { content: ''; position: absolute; bottom: -10px; left: 0; right: 0; height: 10px; background: linear-gradient(to bottom, rgba(0,0,0,0.05), transparent); } /* Button styles */ button { transition: all 0.2s ease; } button:active { transform: scale(0.96); } .nav-btn { transition: all 0.2s ease; position: relative; } .nav-btn::after { content: ''; position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); width: 0; height: 3px; background: var(--primary); transition: all 0.2s ease; } .nav-btn.text-amber-600::after { width: 20px; } /* Modal styles */ #feedbackModal > div { animation: modalFadeIn 0.3s ease-out; box-shadow: 0 10px 25px rgba(0,0,0,0.15); } @keyframes modalFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .feedback-btn { transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .feedback-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); } /* Input styles */ input { transition: all 0.2s ease; border: 1px solid #e5e7eb; } input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2); } /* Scrollbar styles */ ::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } ::-webkit-scrollbar-thumb { background: var(--secondary); border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: var(--primary); } /* Pulse animation for camera buttons */ @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(217, 119, 6, 0); } 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); } } #openCamera, #uploadImage { animation: pulse 2s infinite; z-index: 2; } /* Loading animation */ .loading-spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: white; animation: spin 1s ease-in-out infinite; } @keyframes spin { to { transform: rotate(360deg); } } /* Ripple effect */ .ripple { position: relative; overflow: hidden; } .ripple:after { content: ""; display: block; position: absolute; width: 100%; height: 100%; top: 0; left: 0; pointer-events: none; background-image: radial-gradient(circle, #fff 10%, transparent 10.01%); background-repeat: no-repeat; background-position: 50%; transform: scale(10,10); opacity: 0; transition: transform .5s, opacity 1s; } .ripple:active:after { transform: scale(0,0); opacity: .3; transition: 0s; } /* Shimmer effect for loading */ .shimmer { background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; } @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } } /* Toast notification */ .toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: white; padding: 12px 24px; border-radius: 8px; z-index: 100; animation: toastIn 0.3s ease-out, toastOut 0.3s ease-out 2.7s forwards; } @keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } } @keyframes toastOut { from { opacity: 1; transform: translateX(-50%) translateY(0); } to { opacity: 0; transform: translateX(-50%) translateY(20px); } } /* Tooltip */ .tooltip { position: relative; } .tooltip:hover .tooltip-text { visibility: visible; opacity: 1; } .tooltip-text { visibility: hidden; opacity: 0; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #333; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; transition: all 0.2s ease; margin-bottom: 5px; } .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; } </style> </head> <body class="bg-gray-50 font-sans"> <!-- App Container --> <div class="max-w-md mx-auto bg-white min-h-screen shadow-lg overflow-hidden relative"> <!-- Header --> <header class="bg-gradient-to-r from-amber-600 to-amber-800 p-4 text-white flex justify-between items-center"> <div class="flex items-center"> <i class="fas fa-pepper-hot text-2xl mr-2"></i> <h1 class="text-xl font-bold">SpiceClassify</h1> </div> <div class="flex space-x-3"> <button id="searchBtn" class="text-white ripple tooltip"> <i class="fas fa-search"></i> <span class="tooltip-text">Search spices</span> </button> <button id="historyBtn" class="text-white ripple tooltip"> <i class="fas fa-history"></i> <span class="tooltip-text">History</span> </button> <button id="favoritesBtn" class="text-white ripple tooltip"> <i class="fas fa-heart"></i> <span class="tooltip-text">Favorites</span> </button> </div> </header> <!-- Main Content --> <main class="p-4 pb-20"> <!-- Search Modal --> <div id="searchModal" class="hidden absolute inset-0 bg-white z-50 p-4 slide-in"> <div class="flex items-center mb-4"> <button id="closeSearch" class="mr-2 text-gray-600 ripple"> <i class="fas fa-arrow-left"></i> </button> <div class="relative flex-grow"> <input type="text" placeholder="Search spices..." class="w-full p-2 pl-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500"> <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i> </div> </div> <div class="mb-4"> <h3 class="font-semibold text-gray-700 mb-2">Search by:</h3> <div class="flex flex-wrap gap-2"> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Name</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Flavor</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Cuisine</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Category</span> </div> </div> <div> <h3 class="font-semibold text-gray-700 mb-2">Recent Searches</h3> <div class="space-y-2"> <div class="p-2 border-b border-gray-100 flex justify-between"> <span>Cumin</span> <i class="fas fa-times text-gray-400"></i> </div> <div class="p-2 border-b border-gray-100 flex justify-between"> <span>Hot spices</span> <i class="fas fa-times text-gray-400"></i> </div> </div> </div> </div> <!-- Camera Section --> <section id="cameraSection" class="mb-8"> <div class="camera-preview rounded-xl h-64 flex flex-col items-center justify-center mb-4 relative overflow-hidden"> <div id="imagePreview" class="hidden w-full h-full bg-cover bg-center"></div> <i class="fas fa-camera text-4xl text-gray-500 mb-2"></i> <p class="text-gray-600">Capture or upload spice image</p> <div class="absolute bottom-4 flex space-x-4"> <button id="openCamera" class="bg-white p-3 rounded-full shadow-lg text-amber-600 ripple tooltip"> <i class="fas fa-camera"></i> <span class="tooltip-text">Take photo</span> </button> <button id="uploadImage" class="bg-white p-3 rounded-full shadow-lg text-amber-600 ripple tooltip"> <i class="fas fa-images"></i> <span class="tooltip-text">Upload image</span> </button> </div> </div> <div class="text-center text-sm text-gray-500"> <p>For best results, take a clear photo in good lighting</p> </div> </section> <!-- Results Section --> <section id="resultsSection" class="hidden fade-in"> <div class="bg-amber-50 rounded-xl p-4 mb-4 shadow-sm"> <div class="flex justify-between items-center mb-2"> <h2 class="font-bold text-lg text-amber-900" id="spiceName">Cumin</h2> <span class="bg-amber-100 text-amber-800 px-2 py-1 rounded-full text-xs shadow-sm" id="matchPercentage">88% match</span> </div> <p class="text-sm text-gray-700 mb-2" id="scientificName"><i>Cuminum cyminum</i></p> <div class="flex flex-wrap gap-2 mb-3" id="flavorBadges"> <span class="flavor-badge bg-red-100 text-red-800 px-2 py-1 rounded-full text-xs">Earthy</span> <span class="flavor-badge bg-yellow-100 text-yellow-800 px-2 py-1 rounded-full text-xs">Warm</span> <span class="flavor-badge bg-orange-100 text-orange-800 px-2 py-1 rounded-full text-xs">Nutty</span> </div> <button id="saveFavorite" class="text-amber-600 text-sm flex items-center ripple"> <i class="far fa-heart mr-1"></i> Add to favorites </button> </div> <!-- Spice Info Tabs --> <div class="mb-4"> <div class="flex border-b border-gray-200"> <button class="tab-btn py-2 px-4 font-medium tab-active" data-tab="overview">Overview</button> <button class="tab-btn py-2 px-4 font-medium text-gray-500" data-tab="uses">Uses</button> <button class="tab-btn py-2 px-4 font-medium text-gray-500" data-tab="health">Health</button> </div> </div> <!-- Tab Content --> <div id="overview" class="tab-content"> <p class="text-gray-700 mb-4" id="overviewText">Cumin is a flowering plant in the family Apiaceae, native to the Irano-Turanian Region. Its seeds are used in the cuisines of many cultures in both whole and ground form.</p> <div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm"> <h4 class="font-semibold text-gray-800 mb-1">Origin</h4> <p class="text-gray-700" id="originText">Middle East, India, Mediterranean</p> </div> <div class="bg-gray-50 p-3 rounded-lg shadow-sm"> <h4 class="font-semibold text-gray-800 mb-1">Similar Spices</h4> <div class="flex flex-wrap gap-2 mt-2" id="similarSpices"> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Caraway</span> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Coriander</span> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Fennel</span> </div> </div> </div> <div id="uses" class="tab-content hidden"> <div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm"> <h4 class="font-semibold text-gray-800 mb-2">Culinary Uses</h4> <ul class="list-disc pl-5 text-gray-700 space-y-1" id="culinaryUses"> <li>Essential in Indian curries and spice blends</li> <li>Used in Mexican and Tex-Mex dishes</li> <li>Common in Middle Eastern and North African cuisine</li> <li>Flavor base for soups and stews</li> </ul> </div> <div class="bg-gray-50 p-3 rounded-lg shadow-sm"> <h4 class="font-semibold text-gray-800 mb-2">Pairings</h4> <div class="flex flex-wrap gap-2" id="pairings"> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Lentils</span> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Chickpeas</span> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Lamb</span> <span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Rice</span> </div> </div> </div> <div id="health" class="tab-content hidden"> <div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm"> <h4 class="font-semibold text-gray-800 mb-2">Health Benefits</h4> <ul class="list-disc pl-5 text-gray-700 space-y-1" id="healthBenefits"> <li>Rich in iron and antioxidants</li> <li>May aid digestion and improve gut health</li> <li>Contains anti-inflammatory properties</li> <li>May help regulate blood sugar</li> </ul> </div> <div class="bg-gray-50 p-3 rounded-lg shadow-sm"> <h4 class="font-semibold text-gray-800 mb-2">Nutritional Info (per 1 tsp)</h4> <div class="grid grid-cols-2 gap-2 text-sm" id="nutritionInfo"> <div class="bg-gray-100 p-2 rounded">Calories: 8</div> <div class="bg-gray-100 p-2 rounded">Fiber: 0.6g</div> <div class="bg-gray-100 p-2 rounded">Iron: 1.4mg</div> <div class="bg-gray-100 p-2 rounded">Calcium: 20mg</div> </div> </div> </div> </section> <!-- Alternative Predictions --> <section id="altPredictions" class="hidden mt-6"> <h3 class="font-semibold text-gray-700 mb-3">Other possibilities:</h3> <div class="space-y-3" id="altPredictionsList"> <div class="flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors"> <div class="w-10 h-10 bg-amber-200 rounded-full flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-amber-700"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Caraway</h4> <p class="text-xs text-gray-500">65% match</p> </div> <button class="text-amber-600 ripple">View</button> </div> <div class="flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors"> <div class="w-10 h-10 bg-amber-200 rounded-full flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-amber-700"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Fennel</h4> <p class="text-xs text-gray-500">52% match</p> </div> <button class="text-amber-600 ripple">View</button> </div> </div> </section> <!-- Browse Section --> <section id="browseSection" class="hidden"> <div class="mb-4"> <div class="relative"> <input type="text" placeholder="Search spices..." class="w-full p-2 pl-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500"> <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i> </div> </div> <div class="mb-4"> <h3 class="font-semibold text-gray-700 mb-2">Categories</h3> <div class="flex flex-wrap gap-2" id="categoriesList"> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Seeds</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Roots</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Herbs</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Peppers</span> <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Blends</span> </div> </div> <div> <h3 class="font-semibold text-gray-700 mb-2">Popular Spices</h3> <div class="grid grid-cols-2 gap-3" id="popularSpices"> <div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100"> <div class="w-full h-20 bg-amber-100 rounded-lg mb-2 flex items-center justify-center icon-container"> <i class="fas fa-pepper-hot text-2xl text-amber-600"></i> </div> <h4 class="font-medium text-center">Cumin</h4> </div> <div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100"> <div class="w-full h-20 bg-red-100 rounded-lg mb-2 flex items-center justify-center icon-container"> <i class="fas fa-pepper-hot text-2xl text-red-600"></i> </div> <h4 class="font-medium text-center">Paprika</h4> </div> <div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100"> <div class="w-full h-20 bg-green-100 rounded-lg mb-2 flex items-center justify-center icon-container"> <i class="fas fa-pepper-hot text-2xl text-green-600"></i> </div> <h4 class="font-medium text-center">Cardamom</h4> </div> <div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100"> <div class="w-full h-20 bg-yellow-100 rounded-lg mb-2 flex items-center justify-center icon-container"> <i class="fas fa-pepper-hot text-2xl text-yellow-600"></i> </div> <h4 class="font-medium text-center">Turmeric</h4> </div> </div> </div> </section> <!-- History Section --> <section id="historySection" class="hidden"> <div class="mb-4"> <h3 class="font-semibold text-gray-700 mb-3">Recent Classifications</h3> <div class="space-y-3" id="historyList"> <div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors"> <div class="w-12 h-12 bg-amber-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-amber-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Cumin</h4> <p class="text-xs text-gray-500">Today, 10:24 AM • 88% match</p> </div> <button class="text-amber-600 ripple"> <i class="fas fa-chevron-right"></i> </button> </div> <div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors"> <div class="w-12 h-12 bg-red-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-red-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Chili Powder</h4> <p class="text-xs text-gray-500">Yesterday, 4:12 PM • 92% match</p> </div> <button class="text-amber-600 ripple"> <i class="fas fa-chevron-right"></i> </button> </div> </div> </div> </section> <!-- Favorites Section --> <section id="favoritesSection" class="hidden"> <div class="mb-4"> <h3 class="font-semibold text-gray-700 mb-3">Your Favorites</h3> <div class="space-y-3" id="favoritesList"> <div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors"> <div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-green-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Cardamom</h4> <p class="text-xs text-gray-500">Saved on Jun 12</p> </div> <button class="text-red-400 ripple"> <i class="fas fa-heart"></i> </button> </div> <div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors"> <div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-purple-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">Cinnamon</h4> <p class="text-xs text-gray-500">Saved on May 28</p> </div> <button class="text-red-400 ripple"> <i class="fas fa-heart"></i> </button> </div> </div> </div> </section> </main> <!-- Bottom Navigation --> <nav class="fixed bottom-0 w-full max-w-md bg-white border-t border-gray-200 flex justify-around py-2 shadow-lg"> <button class="nav-btn p-2 text-amber-600 flex flex-col items-center ripple" data-section="cameraSection"> <i class="fas fa-camera text-xl"></i> <span class="text-xs mt-1">Scan</span> </button> <button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="browseSection"> <i class="fas fa-book text-xl"></i> <span class="text-xs mt-1">Browse</span> </button> <button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="historySection"> <i class="fas fa-history text-xl"></i> <span class="text-xs mt-1">History</span> </button> <button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="favoritesSection"> <i class="fas fa-heart text-xl"></i> <span class="text-xs mt-1">Favorites</span> </button> </nav> <!-- Feedback Modal --> <div id="feedbackModal" class="hidden absolute inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4"> <div class="bg-white rounded-xl p-6 w-full max-w-sm"> <h3 class="font-bold text-lg mb-3">Was this correct?</h3> <p class="text-gray-700 mb-4">Help improve SpiceClassify by confirming if we identified your spice correctly.</p> <div class="flex justify-between mb-4"> <button class="feedback-btn bg-green-100 text-green-800 px-4 py-2 rounded-lg ripple" data-feedback="correct"> <i class="fas fa-check mr-1"></i> Yes </button> <button class="feedback-btn bg-red-100 text-red-800 px-4 py-2 rounded-lg ripple" data-feedback="incorrect"> <i class="fas fa-times mr-1"></i> No </button> </div> <div id="incorrectFeedback" class="hidden"> <p class="text-gray-700 mb-2">What was it actually?</p> <input type="text" placeholder="Enter spice name" class="w-full p-2 border border-gray-300 rounded-lg mb-2"> <button id="submitFeedback" class="w-full bg-amber-600 text-white py-2 rounded-lg ripple">Submit</button> </div> <button id="closeFeedback" class="w-full mt-3 text-gray-500 ripple">Close</button> </div> </div> <!-- Loading Overlay --> <div id="loadingOverlay" class="hidden absolute inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center"> <div class="bg-white p-6 rounded-xl flex flex-col items-center"> <div class="loading-spinner mb-4"></div> <p class="text-gray-700">Analyzing your spice...</p> </div> </div> </div> <script> // DOM Elements const cameraSection = document.getElementById('cameraSection'); const resultsSection = document.getElementById('resultsSection'); const browseSection = document.getElementById('browseSection'); const historySection = document.getElementById('historySection'); const favoritesSection = document.getElementById('favoritesSection'); const searchModal = document.getElementById('searchModal'); const feedbackModal = document.getElementById('feedbackModal'); const loadingOverlay = document.getElementById('loadingOverlay'); const imagePreview = document.getElementById('imagePreview'); const altPredictions = document.getElementById('altPredictions'); const navBtns = document.querySelectorAll('.nav-btn'); const tabBtns = document.querySelectorAll('.tab-btn'); const tabContents = document.querySelectorAll('.tab-content'); const searchBtn = document.getElementById('searchBtn'); const closeSearch = document.getElementById('closeSearch'); const openCamera = document.getElementById('openCamera'); const uploadImage = document.getElementById('uploadImage'); const saveFavorite = document.getElementById('saveFavorite'); const feedbackBtns = document.querySelectorAll('.feedback-btn'); const closeFeedback = document.getElementById('closeFeedback'); const submitFeedback = document.getElementById('submitFeedback'); const incorrectFeedback = document.getElementById('incorrectFeedback'); // Spice database const spiceDatabase = { 'cumin': { name: 'Cumin', scientificName: 'Cuminum cyminum', matchPercentage: '88%', flavors: ['Earthy', 'Warm', 'Nutty'], origin: 'Middle East, India, Mediterranean', similarSpices: ['Caraway', 'Coriander', 'Fennel'], overview: 'Cumin is a flowering plant in the family Apiaceae, native to the Irano-Turanian Region. Its seeds are used in the cuisines of many cultures in both whole and ground form.', culinaryUses: [ 'Essential in Indian curries and spice blends', 'Used in Mexican and Tex-Mex dishes', 'Common in Middle Eastern and North African cuisine', 'Flavor base for soups and stews' ], pairings: ['Lentils', 'Chickpeas', 'Lamb', 'Rice'], healthBenefits: [ 'Rich in iron and antioxidants', 'May aid digestion and improve gut health', 'Contains anti-inflammatory properties', 'May help regulate blood sugar' ], nutritionInfo: [ 'Calories: 8', 'Fiber: 0.6g', 'Iron: 1.4mg', 'Calcium: 20mg' ], color: 'amber' }, 'paprika': { name: 'Paprika', scientificName: 'Capsicum annuum', matchPercentage: '92%', flavors: ['Sweet', 'Smoky', 'Mild'], origin: 'Central America, Spain, Hungary', similarSpices: ['Cayenne', 'Chili Powder', 'Smoked Paprika'], overview: 'Paprika is a spice made from dried and ground red peppers. It is traditionally made from Capsicum annuum varieties in the Longum group, which also includes chili peppers.', culinaryUses: [ 'Common in Hungarian cuisine (goulash)', 'Used as garnish for deviled eggs', 'Key ingredient in Spanish chorizo', 'Adds color to stews and soups' ], pairings: ['Potatoes', 'Chicken', 'Eggs', 'Cheese'], healthBenefits: [ 'High in vitamin A', 'Contains capsaicin (anti-inflammatory)', 'May boost metabolism', 'Rich in antioxidants' ], nutritionInfo: [ 'Calories: 20', 'Vitamin A: 71% DV', 'Vitamin E: 10% DV', 'Iron: 8% DV' ], color: 'red' }, 'cardamom': { name: 'Cardamom', scientificName: 'Elettaria cardamomum', matchPercentage: '85%', flavors: ['Floral', 'Citrusy', 'Sweet'], origin: 'India, Guatemala, Sri Lanka', similarSpices: ['Cinnamon', 'Cloves', 'Nutmeg'], overview: 'Cardamom is a spice made from the seeds of several plants in the genera Elettaria and Amomum in the family Zingiberaceae. It is native to the Indian subcontinent and Indonesia.', culinaryUses: [ 'Used in Indian sweets and chai tea', 'Common in Scandinavian baking', 'Flavors Arabic coffee', 'Used in savory dishes in Middle East' ], pairings: ['Coffee', 'Rice', 'Pork', 'Desserts'], healthBenefits: [ 'May lower blood pressure', 'Contains antimicrobial properties', 'May improve breathing', 'May help with digestion' ], nutritionInfo: [ 'Calories: 18', 'Fiber: 2g', 'Manganese: 80% DV', 'Iron: 10% DV' ], color: 'green' }, 'turmeric': { name: 'Turmeric', scientificName: 'Curcuma longa', matchPercentage: '90%', flavors: ['Earthy', 'Bitter', 'Peppery'], origin: 'India, Southeast Asia', similarSpices: ['Saffron', 'Ginger', 'Galangal'], overview: 'Turmeric is a flowering plant of the ginger family, Zingiberaceae, the roots of which are used in cooking. The plant is a perennial, rhizomatous, herbaceous plant native to the Indian subcontinent and Southeast Asia.', culinaryUses: [ 'Key ingredient in curry powders', 'Used to color mustard', 'Common in Southeast Asian dishes', 'Used in golden milk' ], pairings: ['Rice', 'Chicken', 'Cauliflower', 'Lentils'], healthBenefits: [ 'Contains curcumin (anti-inflammatory)', 'May improve brain function', 'May lower risk of heart disease', 'May help prevent cancer' ], nutritionInfo: [ 'Calories: 9', 'Fiber: 1g', 'Manganese: 26% DV', 'Iron: 16% DV' ], color: 'yellow' } }; // Alternative predictions const alternativePredictions = { 'cumin': [ { name: 'Caraway', match: '65%', color: 'amber' }, { name: 'Fennel', match: '52%', color: 'green' } ], 'paprika': [ { name: 'Cayenne', match: '70%', color: 'red' }, { name: 'Chili Powder', match: '60%', color: 'red' } ], 'cardamom': [ { name: 'Cinnamon', match: '58%', color: 'amber' }, { name: 'Cloves', match: '45%', color: 'purple' } ], 'turmeric': [ { name: 'Saffron', match: '40%', color: 'yellow' }, { name: 'Ginger', match: '38%', color: 'amber' } ] }; // Current state let currentSpice = null; let favorites = ['cardamom', 'turmeric']; // Initial favorites let history = [ { spice: 'cumin', date: 'Today, 10:24 AM', match: '88%' }, { spice: 'paprika', date: 'Yesterday, 4:12 PM', match: '92%' } ]; // Event Listeners navBtns.forEach(btn => { btn.addEventListener('click', () => { // Hide all sections cameraSection.classList.add('hidden'); resultsSection.classList.add('hidden'); browseSection.classList.add('hidden'); historySection.classList.add('hidden'); favoritesSection.classList.add('hidden'); // Show selected section const sectionId = btn.getAttribute('data-section'); document.getElementById(sectionId).classList.remove('hidden'); // Update active nav button navBtns.forEach(navBtn => { navBtn.classList.remove('text-amber-600'); navBtn.classList.add('text-gray-500'); }); btn.classList.remove('text-gray-500'); btn.classList.add('text-amber-600'); // If showing history or favorites, update the lists if (sectionId === 'historySection') { updateHistoryList(); } else if (sectionId === 'favoritesSection') { updateFavoritesList(); } }); }); tabBtns.forEach(btn => { btn.addEventListener('click', () => { // Update active tab tabBtns.forEach(tabBtn => { tabBtn.classList.remove('tab-active'); tabBtn.classList.add('text-gray-500'); }); btn.classList.add('tab-active'); btn.classList.remove('text-gray-500'); // Show selected tab content const tabId = btn.getAttribute('data-tab'); tabContents.forEach(content => { content.classList.add('hidden'); }); document.getElementById(tabId).classList.remove('hidden'); }); }); searchBtn.addEventListener('click', () => { searchModal.classList.remove('hidden'); }); closeSearch.addEventListener('click', () => { searchModal.classList.add('hidden'); }); openCamera.addEventListener('click', () => { // Simulate camera opening showToast('Opening camera...'); // In a real app, this would open the camera setTimeout(() => { // Simulate image capture captureSpice('cumin'); }, 1000); }); uploadImage.addEventListener('click', () => { // Simulate image picker showToast('Opening image gallery...'); // In a real app, this would open the gallery setTimeout(() => { // Simulate image selection captureSpice('paprika'); }, 1000); }); saveFavorite.addEventListener('click', function() { if (!currentSpice) return; const spiceId = currentSpice.toLowerCase(); const isFavorite = favorites.includes(spiceId); if (isFavorite) { // Remove from favorites favorites = favorites.filter(item => item !== spiceId); this.innerHTML = '<i class="far fa-heart mr-1"></i> Add to favorites'; this.classList.add('text-amber-600'); this.classList.remove('text-red-500'); showToast('Removed from favorites'); } else { // Add to favorites favorites.push(spiceId); this.innerHTML = '<i class="fas fa-heart mr-1"></i> Added to favorites'; this.classList.add('text-red-500'); this.classList.remove('text-amber-600'); showToast('Added to favorites'); } // Update favorites list if on that section if (!favoritesSection.classList.contains('hidden')) { updateFavoritesList(); } }); feedbackBtns.forEach(btn => { btn.addEventListener('click', function() { if (this.getAttribute('data-feedback') === 'incorrect') { incorrectFeedback.classList.remove('hidden'); } else { feedbackModal.classList.add('hidden'); showToast('Thank you for your feedback!'); } }); }); closeFeedback.addEventListener('click', () => { feedbackModal.classList.add('hidden'); incorrectFeedback.classList.add('hidden'); }); submitFeedback.addEventListener('click', () => { const feedbackInput = incorrectFeedback.querySelector('input'); if (feedbackInput.value.trim() !== '') { feedbackModal.classList.add('hidden'); incorrectFeedback.classList.add('hidden'); feedbackInput.value = ''; showToast('Thank you for helping us improve!'); } }); // Initialize app with camera section visible document.addEventListener('DOMContentLoaded', () => { cameraSection.classList.remove('hidden'); navBtns[0].classList.remove('text-gray-500'); navBtns[0].classList.add('text-amber-600'); // Add click handlers for spice cards in browse section document.querySelectorAll('.spice-card').forEach(card => { card.addEventListener('click', function() { const spiceName = this.querySelector('h4').textContent.toLowerCase(); showSpiceDetails(spiceName); // Switch to results view cameraSection.classList.add('hidden'); browseSection.classList.add('hidden'); resultsSection.classList.remove('hidden'); // Update nav button navBtns.forEach(navBtn => { navBtn.classList.remove('text-amber-600'); navBtn.classList.add('text-gray-500'); }); }); }); // Add click handlers for history items document.getElementById('historyList').addEventListener('click', function(e) { if (e.target.closest('.flex.items-center')) { const item = e.target.closest('.flex.items-center'); const spiceName = item.querySelector('h4').textContent.toLowerCase(); showSpiceDetails(spiceName); // Switch to results view cameraSection.classList.add('hidden'); historySection.classList.add('hidden'); resultsSection.classList.remove('hidden'); // Update nav button navBtns.forEach(navBtn => { navBtn.classList.remove('text-amber-600'); navBtn.classList.add('text-gray-500'); }); } }); // Add click handlers for alternative predictions document.getElementById('altPredictionsList').addEventListener('click', function(e) { if (e.target.classList.contains('ripple') || e.target.closest('.ripple')) { const item = e.target.closest('.flex.items-center'); const spiceName = item.querySelector('h4').textContent.toLowerCase(); showSpiceDetails(spiceName); } }); }); // Functions function captureSpice(spiceId) { loadingOverlay.classList.remove('hidden'); // Simulate processing delay setTimeout(() => { loadingOverlay.classList.add('hidden'); // Set the image preview const spice = spiceDatabase[spiceId]; imagePreview.style.backgroundImage = `url(https://source.unsplash.com/300x300/?${spiceId},spice)`; imagePreview.classList.remove('hidden'); cameraSection.querySelector('i.fa-camera').classList.add('hidden'); cameraSection.querySelector('p').classList.add('hidden'); // Show results showSpiceDetails(spiceId); // Switch to results view cameraSection.classList.add('hidden'); resultsSection.classList.remove('hidden'); altPredictions.classList.remove('hidden'); // Add to history if not already there const existingHistory = history.find(item => item.spice === spiceId); if (!existingHistory) { const now = new Date(); const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); const dateString = now.toLocaleDateString([], { month: 'short', day: 'numeric' }); history.unshift({ spice: spiceId, date: `Today, ${timeString}`, match: spiceDatabase[spiceId].matchPercentage }); } // Show feedback modal after a delay setTimeout(() => { feedbackModal.classList.remove('hidden'); }, 1000); }, 2000); } function showSpiceDetails(spiceId) { const spice = spiceDatabase[spiceId]; if (!spice) return; currentSpice = spiceId; // Update main info document.getElementById('spiceName').textContent = spice.name; document.getElementById('scientificName').textContent = spice.scientificName; document.getElementById('matchPercentage').textContent = `${spice.matchPercentage} match`; // Update flavor badges const flavorBadges = document.getElementById('flavorBadges'); flavorBadges.innerHTML = ''; spice.flavors.forEach(flavor => { const color = flavor === 'Earthy' ? 'red' : flavor === 'Warm' ? 'yellow' : flavor === 'Nutty' ? 'orange' : flavor === 'Sweet' ? 'green' : flavor === 'Smoky' ? 'gray' : flavor === 'Floral' ? 'purple' : flavor === 'Citrusy' ? 'blue' : flavor === 'Bitter' ? 'indigo' : flavor === 'Peppery' ? 'pink' : 'amber'; const badge = document.createElement('span'); badge.className = `flavor-badge bg-${color}-100 text-${color}-800 px-2 py-1 rounded-full text-xs`; badge.textContent = flavor; flavorBadges.appendChild(badge); }); // Update favorite button const isFavorite = favorites.includes(spiceId); saveFavorite.innerHTML = isFavorite ? '<i class="fas fa-heart mr-1"></i> Added to favorites' : '<i class="far fa-heart mr-1"></i> Add to favorites'; saveFavorite.className = isFavorite ? 'text-red-500 text-sm flex items-center ripple' : 'text-amber-600 text-sm flex items-center ripple'; // Update tab content document.getElementById('overviewText').textContent = spice.overview; document.getElementById('originText').textContent = spice.origin; // Update similar spices const similarSpices = document.getElementById('similarSpices'); similarSpices.innerHTML = ''; spice.similarSpices.forEach(similar => { const span = document.createElement('span'); span.className = 'bg-gray-200 px-3 py-1 rounded-full text-sm'; span.textContent = similar; similarSpices.appendChild(span); }); // Update uses const culinaryUses = document.getElementById('culinaryUses'); culinaryUses.innerHTML = ''; spice.culinaryUses.forEach(use => { const li = document.createElement('li'); li.textContent = use; culinaryUses.appendChild(li); }); // Update pairings const pairings = document.getElementById('pairings'); pairings.innerHTML = ''; spice.pairings.forEach(pairing => { const span = document.createElement('span'); span.className = 'bg-gray-200 px-3 py-1 rounded-full text-sm'; span.textContent = pairing; pairings.appendChild(span); }); // Update health benefits const healthBenefits = document.getElementById('healthBenefits'); healthBenefits.innerHTML = ''; spice.healthBenefits.forEach(benefit => { const li = document.createElement('li'); li.textContent = benefit; healthBenefits.appendChild(li); }); // Update nutrition info const nutritionInfo = document.getElementById('nutritionInfo'); nutritionInfo.innerHTML = ''; spice.nutritionInfo.forEach(info => { const div = document.createElement('div'); div.className = 'bg-gray-100 p-2 rounded'; div.textContent = info; nutritionInfo.appendChild(div); }); // Update alternative predictions const altPredictionsList = document.getElementById('altPredictionsList'); altPredictionsList.innerHTML = ''; const alts = alternativePredictions[spiceId] || []; alts.forEach(alt => { const div = document.createElement('div'); div.className = 'flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors'; div.innerHTML = ` <div class="w-10 h-10 bg-${alt.color}-100 rounded-full flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-${alt.color}-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">${alt.name}</h4> <p class="text-xs text-gray-500">${alt.match} match</p> </div> <button class="text-amber-600 ripple">View</button> `; altPredictionsList.appendChild(div); }); } function updateHistoryList() { const historyList = document.getElementById('historyList'); historyList.innerHTML = ''; history.forEach(item => { const spice = spiceDatabase[item.spice]; if (!spice) return; const div = document.createElement('div'); div.className = 'flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors'; div.innerHTML = ` <div class="w-12 h-12 bg-${spice.color}-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-${spice.color}-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">${spice.name}</h4> <p class="text-xs text-gray-500">${item.date} • ${item.match} match</p> </div> <button class="text-amber-600 ripple"> <i class="fas fa-chevron-right"></i> </button> `; historyList.appendChild(div); }); } function updateFavoritesList() { const favoritesList = document.getElementById('favoritesList'); favoritesList.innerHTML = ''; if (favorites.length === 0) { favoritesList.innerHTML = ` <div class="text-center py-8 text-gray-500"> <i class="fas fa-heart text-4xl mb-2 text-gray-300"></i> <p>No favorites yet</p> </div> `; return; } favorites.forEach(spiceId => { const spice = spiceDatabase[spiceId]; if (!spice) return; const now = new Date(); const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; const savedDate = `${monthNames[now.getMonth()]} ${now.getDate()}`; const div = document.createElement('div'); div.className = 'flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors'; div.innerHTML = ` <div class="w-12 h-12 bg-${spice.color}-100 rounded-lg flex items-center justify-center mr-3"> <i class="fas fa-pepper-hot text-${spice.color}-600"></i> </div> <div class="flex-grow"> <h4 class="font-medium">${spice.name}</h4> <p class="text-xs text-gray-500">Saved on ${savedDate}</p> </div> <button class="text-red-400 ripple" data-spice="${spiceId}"> <i class="fas fa-heart"></i> </button> `; favoritesList.appendChild(div); // Add click handler to remove favorite div.querySelector('button').addEventListener('click', function() { favorites = favorites.filter(item => item !== spiceId); updateFavoritesList(); // If we're viewing this spice, update the favorite button if (currentSpice === spiceId) { saveFavorite.innerHTML = '<i class="far fa-heart mr-1"></i> Add to favorites'; saveFavorite.className = 'text-amber-600 text-sm flex items-center ripple'; } showToast('Removed from favorites'); }); }); } function showToast(message) { const toast = document.createElement('div'); toast.className = 'toast'; toast.textContent = message; document.body.appendChild(toast); setTimeout(() => { toast.remove(); }, 3000); } // Add ripple effect to all ripple buttons document.querySelectorAll('.ripple').forEach(button => { button.addEventListener('click', function(e) { const rect = this.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; const ripple = document.createElement('span'); ripple.className = 'ripple-effect'; ripple.style.left = `${x}px`; ripple.style.top = `${y}px`; this.appendChild(ripple); setTimeout(() => { ripple.remove(); }, 600); }); }); </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=aminekaa/spiceclassify" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SpiceClassify - Automatic Spice Classification</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>
/* Custom styles */
:root {
--primary: #d97706;
--primary-dark: #92400e;
--secondary: #f59e0b;
--accent: #f97316;
--light: #f5f5f4;
--dark: #1c1917;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
background-color: var(--light);
color: var(--dark);
}
.camera-preview {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
border-radius: 16px;
position: relative;
overflow: hidden;
}
.camera-preview::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8) 0%, transparent 70%);
z-index: 1;
}
.spice-card {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
border-radius: 12px;
overflow: hidden;
cursor: pointer;
}
.spice-card:hover {
transform: translateY(-5px) scale(1.02);
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.spice-card .icon-container {
transition: all 0.3s ease;
}
.spice-card:hover .icon-container {
transform: scale(1.1);
}
.tab-active {
border-bottom: 3px solid var(--primary);
color: var(--primary-dark);
font-weight: 600;
}
.flavor-badge {
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.flavor-badge:hover {
transform: translateY(-2px) scale(1.05);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.slide-in {
animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Header styles */
header {