-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bc503c
commit 8605084
Showing
24 changed files
with
685 additions
and
140 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Geçici veritabanı | ||
let recipes = [ | ||
{ | ||
title: "Spaghetti Bolognese", | ||
ingredients: "Pasta, Ground Beef, Tomato Sauce, Onion, Garlic, Olive Oil, Salt, Pepper", | ||
description: "Classic Italian dish with a rich meat sauce." | ||
}, | ||
{ | ||
title: "Chicken Alfredo", | ||
ingredients: "Fettuccine, Chicken Breast, Heavy Cream, Parmesan Cheese, Butter, Garlic, Salt, Pepper", | ||
description: "Creamy pasta dish with grilled chicken." | ||
}, | ||
{ | ||
title: "Vegetarian Stir-Fry", | ||
ingredients: "Tofu, Broccoli, Bell Peppers, Carrots, Soy Sauce, Ginger, Garlic, Sesame Oil", | ||
description: "Healthy and flavorful stir-fried vegetables with tofu." | ||
} | ||
]; | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
const recipeContainer = document.querySelector(".recipe-book-container"); | ||
|
||
// Show recipes when the page is loaded | ||
showRecipes(); | ||
|
||
// Add New Recipe sayfasından gelen verileri al ve veritabanına ekle | ||
function addRecipe() { | ||
const title = document.getElementById("recipe-title").value; | ||
const ingredients = document.getElementById("recipe-ingredients").value; | ||
const description = document.getElementById("recipe-description").value; | ||
|
||
if (title && ingredients && description) { | ||
// Yeni tarifi veritabanına ekle | ||
recipes.push({ | ||
title: title, | ||
ingredients: ingredients, | ||
description: description | ||
}); | ||
|
||
// Tarif eklendikten sonra tarifleri göster | ||
showRecipes(); | ||
|
||
// Add New Recipe sayfasını temizle | ||
document.getElementById("recipe-form").reset(); | ||
} else { | ||
alert("Please fill in all fields."); | ||
} | ||
} | ||
|
||
// Sayfa yüklendiğinde formun submit işlemini dinle | ||
const recipeForm = document.getElementById("recipe-form"); | ||
recipeForm.addEventListener("submit", function (event) { | ||
event.preventDefault(); // Sayfanın yeniden yüklenmesini önle | ||
addRecipe(); // Tarifi ekle | ||
}); | ||
}); | ||
|
||
// Function to display recipes in the recipe container | ||
function showRecipes() { | ||
const recipeContainer = document.querySelector(".recipe-book-container"); | ||
recipeContainer.innerHTML = ""; | ||
|
||
recipes.forEach(recipe => { | ||
const recipeItem = document.createElement("div"); | ||
recipeItem.classList.add("recipe-item"); | ||
recipeItem.innerHTML = ` | ||
<h2>${recipe.title}</h2> | ||
<p><strong>Ingredients:</strong> ${recipe.ingredients}</p> | ||
<p><strong>Description:</strong> ${recipe.description}</p> | ||
`; | ||
recipeContainer.appendChild(recipeItem); | ||
}); | ||
} |
File renamed without changes.
Oops, something went wrong.