FoodipediaChef

Welcome to FoodipediaChef – discover delicious recipes from around the world!

🍽️ مرحباً بكم في عالم الطبخ والوصفات

🍽️ Explore by Category

🌟 Recipe of the Day

Loading...

Follow Us on Pinterest

Discover more delicious recipes and save your favorites!

Follow @foodipediachef

Cooking Reels

🎬 My TikTok Recipes

Watch delicious dessert recipes

Follow on TikTok
🔥 Sweet Dessert Creations

Easy baking tutorials

Watch Videos
🍰 Quick & Easy Baking

New recipes every week

Visit Profile
📱 Daily Recipe Inspiration

Searching for delicious recipes...

🔐 Admin Access

Invalid email or password

Recipe Assistant

👋 Hi! I'm your recipe assistant. Ask me for recipe ideas like "healthy dinner", "quick dessert", or "vegetarian lunch"!
FoodipediaChef - Delicious Recipes

FoodipediaChef

Welcome to FoodipediaChef – discover delicious recipes from around the world!

🍽️ مرحباً بكم في عالم الطبخ والوصفات

🍽️ Explore by Category

🌟 Recipe of the Day

Loading...

Follow Us on Pinterest

Discover more delicious recipes and save your favorites!

Follow @foodipediachef

Cooking Reels

🎬 My TikTok Recipes

Watch delicious dessert recipes

Follow on TikTok
🔥 Sweet Dessert Creations

Easy baking tutorials

Watch Videos
🍰 Quick & Easy Baking

New recipes every week

Visit Profile
📱 Daily Recipe Inspiration

Searching for delicious recipes...

🔐 Admin Access

Invalid email or password

Recipe Assistant

👋 Hi! I'm your recipe assistant. Ask me for recipe ideas like "healthy dinner", "quick dessert", or "vegetarian lunch"!
const data = full || meal; if (data.strMeal && searchTerms.some(term => data.strMeal.toLowerCase().includes(term))) { return normalizeRecipe(data, data); } return null; }) ); allMeals = detailed.filter(m => m !== null); } catch (e) { console.error(e); } renderRecipes(); updateResultCount(); } } function searchArabicRecipes(query) { return []; } const lowerQuery = query.toLowerCase(); return adminRecipes.filter(r => { const titleMatch = r.strMeal && r.strMeal.toLowerCase().includes(lowerQuery); const catMatch = r.strCategory && r.strCategory.toLowerCase().includes(lowerQuery); return titleMatch || catMatch; }).map(r => normalizeRecipe(r)).filter(r => r !== null); } async function smartSearch(query, isCategory = false) { if (isSearching) return; const sanitizedQuery = query?.trim(); if (!sanitizedQuery && !isCategory) { showHomepage(); return; } const searchBtn = document.getElementById("searchBtn"); searchBtn.classList.add("loading"); isSearching = true; document.getElementById('loadingOverlay').classList.add('active'); try { if (currentLang === 'ar') { allMeals = []; renderRecipes(); updateResultCount(); document.getElementById("recipesGrid").innerHTML = `

🚧 سيتم إضافة الوصفات قريباً

نحن نعمل على إضافة محتوى عربي عالي الجودة 🔥

`; } const [nameRes, ingRes, catRes] = await Promise.all([ fetch(`https://www.themealdb.com/api/json/v1/1/search.php?s=${encodeURIComponent(sanitizedQuery)}`), fetch(`https://www.themealdb.com/api/json/v1/1/filter.php?i=${encodeURIComponent(sanitizedQuery)}`), fetch(`https://www.themealdb.com/api/json/v1/1/filter.php?c=${encodeURIComponent(sanitizedQuery)}`) ]); const [nameData, ingData, catData] = await Promise.all([nameRes.json(), ingRes.json(), catRes.json()]); let rawResults = []; if (nameData.meals) rawResults.push(...nameData.meals); if (ingData.meals) rawResults.push(...ingData.meals); if (catData.meals) rawResults.push(...catData.meals); const uniqueById = new Map(); for (const meal of rawResults) if (meal.idMeal && !uniqueById.has(meal.idMeal)) uniqueById.set(meal.idMeal, meal); const enriched = []; for (const meal of uniqueById.values()) { const full = await fetchFullDetails(meal.idMeal); if (full) enriched.push(normalizeRecipe(full, full)); else enriched.push(normalizeRecipe(meal)); } const adminMatches = adminRecipes.filter(r => r.strMeal?.toLowerCase().includes(sanitizedQuery.toLowerCase()) || r.strCategory?.toLowerCase().includes(sanitizedQuery.toLowerCase())); for (const r of adminMatches) { const norm = normalizeRecipe(r); if (norm) enriched.push(norm); } const finalMap = new Map(); for (const meal of enriched) { if (!meal) continue; const titleMatch = meal.strMeal && meal.strMeal.toLowerCase().includes(sanitizedQuery.toLowerCase()); const catMatch = meal.strCategory && meal.strCategory.toLowerCase().includes(sanitizedQuery.toLowerCase()); if ((titleMatch || catMatch) && meal.idMeal && !finalMap.has(meal.idMeal) && meal.strMeal && meal.strMealThumb && meal.strMeal !== 'Untitled') { finalMap.set(meal.idMeal, meal); } } allMeals = Array.from(finalMap.values()); } if (allMeals.length === 0) renderNoResults(); else renderRecipes(); renderVideos(); updateResultCount(); updateRecipeOfDay(); updateTitleAndMeta(sanitizedQuery); } catch(e) { console.error(e); } finally { isSearching = false; searchBtn.classList.remove("loading"); document.getElementById('loadingOverlay').classList.remove('active'); } } function renderRecipes() { const grid = document.getElementById("recipesGrid"); const validMeals = allMeals.filter(m => m && m.strMeal && m.strMealThumb && m.strMeal !== 'Untitled'); if (!validMeals.length) { grid.innerHTML = `
${translations[currentLang].no_recipes}
`; return; } grid.innerHTML = validMeals.map(meal => `
${escapeHTML(meal.strMeal)}
${meal.docId && isAdminLoggedIn ? `` : ''}
${escapeHTML(meal.strMeal)}
${escapeHTML(meal.strCategory)}
${escapeHTML(translations[currentLang].view_recipe)} →
`).join(''); document.querySelectorAll('.recipe-card').forEach(card => { card.addEventListener('click', (e) => { if (e.target.tagName === 'BUTTON') return; const meal = allMeals.find(m => String(m.idMeal) === String(card.dataset.id)); if (meal) openModal(meal); }); }); } function openModal(meal) { const ingredients = meal.ingredients || []; const steps = meal.stepsList.length ? meal.stepsList : ['No instructions available.']; const youtubeId = meal.strYoutube?.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&]+)/)?.[1]; const related = allMeals.filter(m => m.idMeal !== meal.idMeal && m.strCategory === meal.strCategory).slice(0, 4); const relatedHTML = related.length ? `` : ''; document.getElementById("modalContent").innerHTML = `

${escapeHTML(meal.strMeal)}

Category: ${escapeHTML(meal.strCategory)}


${translations[currentLang].ingredients}

${ingredients.map(i => `🍴 ${escapeHTML(i)}`).join('')}

${translations[currentLang].instructions}

About This Recipe

${escapeHTML(meal.strMeal)} is a delightful dish that brings authentic flavors to your kitchen. Perfect for any occasion, this recipe combines carefully selected ingredients for a memorable meal.

${relatedHTML}${youtubeId ? `

Watch Tutorial

` : ''}`; setTimeout(() => { document.querySelectorAll('.related-item').forEach(item => { item.addEventListener('click', (e) => { e.stopPropagation(); const relatedMeal = allMeals.find(m => String(m.idMeal) === String(item.dataset.id)); if (relatedMeal) openModal(relatedMeal); }); }); }, 100); document.getElementById("recipeModal").classList.add("active"); } function renderVideos() { const withVideo = allMeals.filter(m => m.strYoutube?.includes('youtube')).slice(0, 4); const grid = document.getElementById("videosGrid"); if (!withVideo.length) { grid.innerHTML = '

No videos available

'; return; } grid.innerHTML = withVideo.map(meal => { const id = meal.strYoutube.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&]+)/)?.[1]; return `

🔥 ${escapeHTML(meal.strMeal)}

`; }).join(''); } function renderNoResults() { const grid = document.getElementById("recipesGrid"); grid.innerHTML = `

${translations[currentLang].no_recipes}

Try these suggestions:

${['chicken', 'pasta', 'dessert', 'salad', 'beef'].map(s => `${escapeHTML(s)}`).join('')}
`; document.querySelectorAll('.suggestion-tag').forEach(tag => tag.addEventListener('click', () => smartSearch(tag.dataset.suggestion))); } function updateResultCount() { document.getElementById("resultCount").innerText = `${allMeals.length} ${currentLang === 'fr' ? 'recettes' : (currentLang === 'ar' ? 'وصفة' : 'recipes')}`; } function updateRecipeOfDay() { if (masterMealsList.length) { const recipe = masterMealsList[Math.floor(Math.random() * masterMealsList.length)]; if(recipe) { document.getElementById("recipeOfDayTitle").innerHTML = `🍽️ ${escapeHTML(recipe.strMeal)} - Click to View`; document.getElementById("recipeOfDay").onclick = () => openModal(recipe); } } } async function loadAllMeals() { document.getElementById('loadingOverlay').classList.add('active'); try { const res = await fetch("https://www.themealdb.com/api/json/v1/1/search.php?s="); const data = await res.json(); const snapshot = await getDocs(collection(db, "recipes")); let firebaseRecipes = snapshot.docs.map(doc => ({ ...doc.data(), docId: doc.id })); const generatedArabic = []; const allCustomRecipes = [...firebaseRecipes, ...generatedArabic]; adminRecipes = allCustomRecipes; const apiMeals = (data.meals || []).map(meal => normalizeRecipe(meal, meal)).filter(m => m !== null); const customMeals = adminRecipes.map(recipe => normalizeRecipe(recipe)).filter(m => m !== null); masterMealsList = [...apiMeals, ...customMeals]; allMeals = [...masterMealsList]; renderRecipes(); renderVideos(); updateResultCount(); updateRecipeOfDay(); document.querySelector(".recipes-header").style.display = "none"; document.querySelector(".recipes-grid").style.display = "none"; } catch(e) { console.error(e); } document.getElementById('loadingOverlay').classList.remove('active'); } const translations = { en: { search_placeholder: "Search recipes...", recipes_title: "All Recipes", videos_title: "Cooking Reels", view_recipe: "View Recipe", ingredients: "Ingredients", instructions: "Instructions", no_recipes: "No recipes found. Try searching for something else!" }, fr: { search_placeholder: "Rechercher des recettes...", recipes_title: "Toutes les Recettes", videos_title: "Reels Culinaires", view_recipe: "Voir", ingredients: "Ingrédients", instructions: "Instructions", no_recipes: "Aucune recette trouvée. Essayez autre chose !" }, ar: { search_placeholder: "ابحث عن وصفات...", recipes_title: "جميع الوصفات", videos_title: "مقاطع الطبخ", view_recipe: "عرض", ingredients: "المكونات", instructions: "التعليمات", no_recipes: "لم يتم العثور على وصفات. جرب بحثًا آخر!" } }; function applyTranslations() { document.getElementById("searchInput").placeholder = translations[currentLang].search_placeholder; document.getElementById("recipesTitle").innerText = translations[currentLang].recipes_title; document.getElementById("videosTitle").innerText = translations[currentLang].videos_title; document.querySelector(".search-btn .btn-text").innerText = currentLang === 'fr' ? 'Rechercher' : (currentLang === 'ar' ? 'بحث' : 'Search'); const categoryButtons = document.querySelectorAll('.category-btn'); if (currentLang === 'ar') { categoryButtons.forEach(btn => { const originalCat = btn.dataset.category; if (arabicCategoryNames[originalCat]) btn.innerText = arabicCategoryNames[originalCat]; }); } else { categoryButtons.forEach(btn => { const originalCat = btn.dataset.category; btn.innerText = originalCat; }); } updateResultCount(); } function applyRTL() { document.body.classList.toggle('rtl', currentLang === 'ar'); } function applyTheme() { document.documentElement.style.setProperty('--primary', localStorage.getItem('primaryColor') || '#C47A44'); document.body.style.backgroundColor = localStorage.getItem('bgColor') || '#FDF8F0'; } function toggleChat() { document.getElementById("chatModal").classList.toggle('active'); } function closeChat() { document.getElementById("chatModal").classList.remove('active'); } function addMessage(text, isUser) { const container = document.getElementById("chatMessages"); const div = document.createElement('div'); div.className = `message ${isUser ? 'user-message' : 'bot-message'}`; div.innerHTML = text; container.appendChild(div); container.scrollTop = container.scrollHeight; } function sendMessage() { const input = document.getElementById("chatInput"); const query = input.value.trim(); if (!query) return; addMessage(escapeHTML(query), true); input.value = ''; setTimeout(() => { const q = query.toLowerCase(); let response = ""; if (currentLang === 'ar') { if (q.includes('حلو') || q.includes('حلوى') || q.includes('ديسير')) response = "🍰 للحلويات، جرب وصفات الحلويات الفيروسية! كيك الشوكولاتة، كنافة، بسبوسة، قطايف."; else if (q.includes('سريع') || q.includes('سهل')) response = "⚡ وصفات سريعة وسهلة: باستا، ساندويتشات، أطباق جاهزة في 15 دقيقة!"; else if (q.includes('صحي') || q.includes('دايت')) response = "🥗 وصفات صحية: سلطات، خضار مشوية، دجاج مشوي. تصفح قسم 'صحي' للحصول على أفكار رائعة!"; else if (q.includes('شارع') || q.includes('ستريت')) response = "🌮 أكل الشارع: برغر، شاورما، تاكو، بطاطا مقلية. جرب وصفات 'أكل الشارع'!"; else response = "🍽️ يمكنني مساعدتك في إيجاد وصفات! جرب أن تسأل عن 'حلويات'، 'وصفات سريعة'، 'أكل صحي'، أو تصفح الأقسام أعلاه."; } else { if (q.includes("healthy")) response = "🥗 For healthy meals, try salads, grilled vegetables, or lean proteins. Check our 'Healthy & Fit' category!"; else if (q.includes("dessert")) response = "🍰 For sweet treats, explore our 'Viral Desserts' category! Try chocolate cake, cookies, or fruit-based desserts."; else if (q.includes("quick") || q.includes("easy")) response = "⚡ Need quick meals? Pasta, stir-fries, and 15-minute recipes are perfect! Check 'Quick & Easy' category."; else if (q.includes("street")) response = "🌮 Love street food? Try tacos, burgers, or fried chicken from our 'Street Food' collection!"; else if (q.includes("trending")) response = "🔥 Trending recipes include viral desserts, one-pot meals, and fusion dishes. Explore 'Trending Now'!"; else response = "🍽️ I can help you find recipes! Try asking about 'healthy meals', 'quick desserts', 'street food', or browse our categories above."; } addMessage(response, false); }, 500); } function setRotatingBackground() { const hero = document.getElementById('heroSection'); const images = ['https://images.unsplash.com/photo-1504674900247-0877df9cc836?w=1600', 'https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=1600', 'https://images.unsplash.com/photo-1567620905732-2d1ec7ab7445?w=1600']; let idx = parseInt(localStorage.getItem('heroBgIdx')) || 0; hero.style.backgroundImage = `url('${images[idx]}')`; hero.style.backgroundSize = 'cover'; hero.style.backgroundPosition = 'center'; setInterval(() => { idx = (idx + 1) % images.length; localStorage.setItem('heroBgIdx', idx); hero.style.backgroundImage = `url('${images[idx]}')`; }, 86400000); } function checkAdminSession() { if (isAdminLoggedIn) document.getElementById("adminPanel").style.display = "block"; } function showAdminLogin() { document.getElementById("adminLoginModal").classList.add("active"); } function hideAdminLogin() { document.getElementById("adminLoginModal").classList.remove("active"); document.getElementById("loginError").style.display = "none"; } function adminLogin() { const email = document.getElementById("adminEmail").value; const pwd = document.getElementById("adminPassword").value; if (email === ADMIN_EMAIL && pwd === ADMIN_PASSWORD) { isAdminLoggedIn = true; localStorage.setItem('adminLoggedIn', 'true'); document.getElementById("adminPanel").style.display = "block"; hideAdminLogin(); } else document.getElementById("loginError").style.display = "block"; } function adminLogout() { isAdminLoggedIn = false; localStorage.setItem('adminLoggedIn', 'false'); document.getElementById("adminPanel").style.display = "none"; } function renderFeatured() { const grid = document.getElementById("featuredGrid"); const featuredKeywords = ["cake", "pasta", "salad"]; Promise.all(featuredKeywords.map(async (keyword) => { try { const res = await fetch(`https://www.themealdb.com/api/json/v1/1/search.php?s=${keyword}`); const data = await res.json(); if (data.meals && data.meals.length > 0) { const filtered = data.meals.filter(m => m.strMeal && m.strMeal.toLowerCase().includes(keyword)); if (filtered.length === 0) return null; return filtered[0]; } return null; } catch (e) { return null; } })).then(results => { const meals = results.filter(m => m); grid.innerHTML = meals.map(meal => ``).join(""); document.querySelectorAll(".featured-card").forEach(card => { card.addEventListener("click", async () => { const id = card.dataset.id; const res = await fetch(`https://www.themealdb.com/api/json/v1/1/lookup.php?i=${id}`); const data = await res.json(); if (data.meals && data.meals[0]) { const meal = normalizeRecipe(data.meals[0], data.meals[0]); openModal(meal); } }); }); }); } document.querySelectorAll('.category-btn').forEach(btn => btn.addEventListener('click', () => searchByCategory(btn.dataset.category))); document.getElementById("homeBtn").addEventListener("click", showHomepage); document.getElementById("searchBtn").addEventListener("click", () => smartSearch(document.getElementById("searchInput").value)); document.getElementById("searchInput").addEventListener("keyup", (e) => { if (e.key === 'Enter') smartSearch(e.target.value); }); document.getElementById("aiBtn").addEventListener("click", () => smartSearch(prompt("What are you craving?"))); document.querySelector(".close-modal").addEventListener("click", () => document.getElementById("recipeModal").classList.remove("active")); document.getElementById("recipeModal").addEventListener("click", (e) => { if (e.target.classList.contains("modal")) e.target.classList.remove("active"); }); document.getElementById("adminLoginBtn").addEventListener("click", adminLogin); document.getElementById("adminLogoutBtn").addEventListener("click", adminLogout); document.getElementById("adminToggleBtn").addEventListener("click", () => { if (!isAdminLoggedIn) showAdminLogin(); else document.getElementById("adminPanel").classList.toggle("open"); }); document.getElementById("chatToggleBtn").addEventListener("click", toggleChat); document.getElementById("closeChatBtn").addEventListener("click", closeChat); document.getElementById("sendChatBtn").addEventListener("click", sendMessage); document.getElementById("chatInput").addEventListener("keypress", (e) => { if (e.key === 'Enter') sendMessage(); }); document.querySelectorAll(".lang-option").forEach(opt => opt.addEventListener("click", () => { currentLang = opt.dataset.lang; localStorage.setItem('foodipedia_lang', currentLang); document.querySelectorAll(".lang-option").forEach(o => o.classList.remove("active")); opt.classList.add("active"); applyTranslations(); applyRTL(); loadAllMeals(); if (currentLang !== 'ar') { loadAllMeals(); } else { loadAllMeals(); // 🔥 نفس الشي if (adminRecipes.length === 0) { loadAllMeals(); } else { allMeals = adminRecipes.map(r => normalizeRecipe(r)).filter(r => r !== null); renderRecipes(); } } })); document.getElementById("primaryColorPicker").addEventListener("change", (e) => { localStorage.setItem('primaryColor', e.target.value); applyTheme(); }); document.getElementById("bgColorPicker").addEventListener("change", (e) => { localStorage.setItem('bgColor', e.target.value); applyTheme(); }); window.deleteRecipe = async function(id) { if (!isAdminLoggedIn) { alert("Admin access required"); showAdminLogin(); return; } if (!id || !confirm("Delete?")) return; await deleteDoc(doc(db, "recipes", id)); loadAllMeals(); }; document.getElementById("addRecipeBtn").addEventListener("click", async () => { if (!isAdminLoggedIn) { alert("Admin access required"); showAdminLogin(); return; } const file = document.getElementById("adminImageFile").files[0]; if (!file) { alert("Please select an image"); return; } const title = document.getElementById('adminTitle').value.trim(); const category = document.getElementById('adminCategory').value; if (!title || !category) { alert("Title and category required"); return; } const instructions = document.getElementById('adminSteps').value; const video = document.getElementById('adminVideo').value; const ingredientsList = document.getElementById('adminIngredients').value.split('\n').filter(i => i.trim()); const stepsList = instructions.split('\n').filter(s => s.trim()); if (!ingredientsList.length || !stepsList.length) { alert("Add ingredients and steps"); return; } const reader = new FileReader(); reader.onload = async function() { await addDoc(collection(db, "recipes"), { idMeal: `custom_${Date.now()}`, strMeal: title, strMealThumb: reader.result, strCategory: category, strInstructions: instructions, strYoutube: video, isCustom: true, ingredients: ingredientsList, stepsList: stepsList }); alert("Recipe saved!"); loadAllMeals(); document.getElementById('adminTitle').value = ''; document.getElementById('adminCategory').value = ''; document.getElementById('adminIngredients').value = ''; document.getElementById('adminSteps').value = ''; document.getElementById('adminVideo').value = ''; document.getElementById('adminImageFile').value = ''; }; reader.readAsDataURL(file); }); document.querySelector(`.lang-option[data-lang="${currentLang}"]`).classList.add("active"); applyTranslations(); applyRTL(); applyTheme(); setRotatingBackground(); checkAdminSession(); renderFeatured(); loadAllMeals();