forked from JANCOOKWebProject/Web-Programming-Projectt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingredients.html
More file actions
375 lines (356 loc) · 15.7 KB
/
ingredients.html
File metadata and controls
375 lines (356 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>재료로 검색</title>
<link rel="stylesheet" href="style.css" />
<style>
nav {
margin-bottom: 1rem;
}
</style>
<script>
function toggleSub(id) {
const subs = document.querySelectorAll('.subcategory');
subs.forEach(sub => sub.style.display = 'none'); //
const target = document.getElementById(id);
if (target) {
target.style.display = 'block';
}
}
<!-- [2] JavaScript 수정 -->
// 음식 정보 객체
const foodData = [
{
name: "김치볶음밥",
ingredients: ["밥", "김치", "앞다리살"],
img: "food-image/kimchi-rice.jpg",
link: "recipe.html"
},
{
name: "된장찌개",
ingredients: ["된장", "두부", "채소류"],
img: "food-image/soybean-soup.jpg",
link: "recipe.html"
},
{
name: "스테이크",
ingredients: ["등심", "안심"],
img: "food-image/soybean-soup.jpg",
link: "recipe.html"
},
{
name: "호박버섯 볶음",
ingredients: ["호박", "버섯"],
img: "food-image/sauteed-mushrooms-with-pumpkin-sweet-pepper.jpg",
link: "recipe.html"
},
{
name: "제육볶음",
ingredients: ["목살", "고추장", "양파", "마늘", "간장장"],
img: "food-image/pepper-paste-fork.jpg",
link: "recipe.html"
},
{
name: "계란찜",
ingredients: ["계란", "소금", "대파"],
img: "food-image/hangug-eumsig-gyelan-jjim-ttoneun-bansug-gyelan.jpg",
link: "recipe.html"
},
{
name: "떡볶이",
ingredients: ["떡", "고추장", "어묵", "대파"],
img: "food-image/beullaeg-bodeu-baegyeong-e-chijeu-tokbokki-hangug-jeontong-eumsig-jeomsim-yoli.jpg",
link: "recipe.html"
},
{
name: "계란말이",
ingredients: ["계란", "당근", "양파", "소금"],
img: "food-image/egg-cake.png",
link: "recipe.html"
},
{
name: "토마토 파스타",
ingredients: ["스파게티면", "토마토소스", "마늘", "양파", "치즈"],
img: "food-image/tasty-appetizing-classic-italian-spaghetti-pasta-with-tomato-sauce-cheese-parmesan-basil-plate-ingredients-cooking-pasta-white-marble-table.jpg",
link: "recipe.html"
},
{
name: "돼지고기 볶음 스파게티",
ingredients: ["앞다리살", "스파게티면", "양파", "간장", "고추기름"],
img: "food-image/stir-fry-spaghetti-put-pork-bowl.jpg",
link: "recipe.html"
},
{
name: "참치마요덮밥",
ingredients: ["밥", "참치캔", "마요네즈", "간장", "김"],
img: "food-image/mas-issneun-chamchi-lesipi.jpg",
link: "recipe.html"
},
{
name: "해물파전",
ingredients: ["부침가루", "오징어","새우", "대파", "계란"],
img: "food-image/seafood-pancake.png",
link: "recipe.html"
},
{
name: "김치찌개",
ingredients: ["김치", "두부", "목살","앞다리살", "대파"],
img: "food-image/kimchi-stew.jpeg",
link: "recipe.html"
},
{
name: "오징어 볶음",
ingredients: ["오징어", "고추장", "양파", "당근"],
img: "food-image/stir-fried-squid.png",
link: "recipe.html"
},
{
name: "버섯 리조또",
ingredients: ["리조또 쌀", "버섯", "양파", "치킨스톡"],
img: "food-image/mushroom-risotto.png",
link: "recipe.html"
},
{
name: "해물짬뽕",
ingredients: ["면", "해물", "고추기름", "양파"],
img: "food-image/seafood-jjamppong.png",
link: "recipe.html"
},
{
name: "닭갈비",
ingredients: ["닭다리살", "고추장", "양배추", "당근"],
img: "food-image/spicy-chicken-stew.png",
link: "recipe.html"
},
{
name: "부대찌개",
ingredients: ["햄", "소세지", "두부", "김치"],
img: "food-image/army-stew.png",
link: "recipe.html"
},
{
name: "잡채",
ingredients: ["당면", "소고기", "당근", "버섯"],
img: "food-image/japchae.png",
link: "recipe.html"
},
{
name: "미역국",
ingredients: ["미역", "소고기", "간장"],
img: "food-image/seaweed-soup.jpg",
link: "recipe.html"
}
];
// 체크된 재료로 음식 추천하기
function filterRecipes() {
const selected = Array.from(document.querySelectorAll('.subcategory input:checked'))
.map(input => input.parentElement.textContent.trim());
const matched = foodData.filter(food =>
selected.every(sel => food.ingredients.includes(sel))
);
const resultBox = document.getElementById("search-result");
resultBox.innerHTML = ""; // 초기화
if (matched.length === 0) {
resultBox.innerHTML = "<br><p>조건에 맞는 음식이 없습니다.</p>";
return;
}
matched.forEach(food => {
const div = document.createElement("div");
div.className = "food-card";
div.innerHTML = `
<a href="${food.link}">
<img src="${food.img}" alt="${food.name}">
<p>${food.name}</p>
</a>`;
resultBox.appendChild(div);
});
}
// 모든 체크박스에 이벤트 리스너 추가
window.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.subcategory input[type=checkbox]').forEach(chk => {
chk.addEventListener('change', filterRecipes);
});
});
</script>
</head>
<body>
<div class="container"> <!-- 상단 헤더 -->
<header>
<div class="logo"><a href="main.html"><img class="logo-image" src="icon-image/Logo.png" alt="잔쿡"></a></div> <!-- 왼쪽 로고 -->
<div class="search-box">
<input type="text" placeholder="재료를 넣어주세요..." />
</div>
<div class="icons">
<a href="/signup" title="회원가입"><img src="icon-image/014-add.png" alt="회원가입"></a>
<a href="/login" title="로그인"><img src="icon-image/015-user-1.png" alt="로그인"></a>
</div>
</header>
<!-- 메뉴 바 -->
<nav>
<ul class="nav-menu">
<li><a href="#">종류별 음식</a></li>
<li><a href="ingredients.html">재료로 검색</a></li>
<li><a href="#">초보용 음식</a></li>
<li><a href="#">조리 시간별</a></li>
</ul>
</nav>
<!-- 재료 카테고리 (원형 아이콘 형태) -->
<div class="category-icons">
<button onclick="toggleSub('meat')">
<img src="icon-image/002-beef.png" alt="소고기"><br>
<span>소고기</span>
</button>
<button onclick="toggleSub('pork')">
<img src="icon-image/003-pork.png" alt="돼지고기"><br>
<span>돼지고기</span>
</button>
<button onclick="toggleSub('chicken')">
<img src="icon-image/001-hen.png" alt="닭고기"><br>
<span>닭고기</span>
</button>
<button onclick="toggleSub('veggie')">
<img src="icon-image/005-vegetable.png" alt="채소류"><br>
<span>채소류</span>
</button>
<button onclick="toggleSub('seafood')">
<img src="icon-image/008-seafood.png" alt="해물류"><br>
<span>해물류</span>
</button>
<button onclick="toggleSub('noodle')">
<img src="icon-image/spaghetti.png" alt="면류"><br>
<span>면류</span>
</button>
<button onclick="toggleSub('noodle')">
<img src="icon-image/bread.png" alt="곡류"><br>
<span>곡류</span>
</button>
<button onclick="toggleSub('dairy')">
<img src="icon-image/010-dairy-products.png" alt="유제품"><br>
<span>유제품</span>
</button>
<button onclick="toggleSub('mushroom')">
<img src="icon-image/006-mushrooms.png" alt="버섯류"><br>
<span>버섯류</span>
</button>
<button onclick="toggleSub('etc')">
<img src="icon-image/007-seasoning.png" alt="기타타"><br>
<span>기타</span>
</button>
</div>
<!-- 상세 재료 선택창 -->
<div class="subcategory" id="meat">
<div class="subcategory-title">소고기 종류</div>
<label><input type="checkbox"> 소고기</label>
<label><input type="checkbox"> 양지</label>
<label><input type="checkbox"> 목심</label>
<label><input type="checkbox"> 등심</label>
<label><input type="checkbox"> 안심</label>
<label><input type="checkbox"> 갈비</label>
<label><input type="checkbox"> 차돌박이</label>
<label><input type="checkbox"> 사태</label>
<label><input type="checkbox"> 우둔살</label>
</div>
<div class="subcategory" id="pork">
<div class="subcategory-title">돼지고기 종류</div>
<label><input type="checkbox"> 돼지고기</label>
<label><input type="checkbox"> 등심</label>
<label><input type="checkbox"> 안심</label>
<label><input type="checkbox"> 삼겹살</label>
<label><input type="checkbox"> 목살</label>
<label><input type="checkbox"> 앞다리살</label>
<label><input type="checkbox"> 갈비살</label>
<label><input type="checkbox"> 항정살</label>
<label><input type="checkbox"> 가브리살</label>
</div>
<div class="subcategory" id="chicken">
<div class="subcategory-title">닭고기 종류</div>
<label><input type="checkbox"> 닭고기</label>
<label><input type="checkbox"> 닭안심</label>
<label><input type="checkbox"> 닭가슴살</label>
<label><input type="checkbox"> 닭다리살</label>
<label><input type="checkbox"> 통닭</label>
<label><input type="checkbox"> 닭날개</label>
<label><input type="checkbox"> 닭근위</label>
</div>
<div class="subcategory" id="veggie">
<div class="subcategory-title">채소류</div>
<label><input type="checkbox"> 당근</label>
<label><input type="checkbox"> 브로콜리</label>
<label><input type="checkbox"> 양파</label>
<label><input type="checkbox"> 대파</label>
<label><input type="checkbox"> 호박</label>
<label><input type="checkbox"> 감자</label>
<label><input type="checkbox"> 고구마</label>
<label><input type="checkbox"> 배추</label>
</div>
<div class="subcategory" id="seafood">
<div class="subcategory-title">해물류</div>
<label><input type="checkbox"> 고등어</label>
<label><input type="checkbox"> 굴비</label>
<label><input type="checkbox"> 장어</label>
<label><input type="checkbox"> 연어</label>
<label><input type="checkbox"> 오징어</label>
<label><input type="checkbox"> 새우</label>
<label><input type="checkbox"> 홍합</label>
<label><input type="checkbox"> 바지락</label>
<label><input type="checkbox"> 문어</label>
<label><input type="checkbox"> 게</label>
</div>
<div class="subcategory" id="noodle">
<div class="subcategory-title">면류</div>
<label><input type="checkbox"> 우동면</label>
<label><input type="checkbox"> 스파게티면</label>
<label><input type="checkbox"> 라면사리</label>
<label><input type="checkbox"> 소면</label>
<label><input type="checkbox"> 냉면사리</label>
</div>
<div class="subcategory" id="dairy">
<div class="subcategory-title">유제품</div>
<label><input type="checkbox"> 우유</label>
<label><input type="checkbox"> 치즈</label>
<label><input type="checkbox"> 버터</label>
<label><input type="checkbox"> 생크림</label>
<label><input type="checkbox"> 요거트</label>
<label><input type="checkbox"> 계란</label>
</div>
<div class="subcategory" id="grain">
<div class="subcategory-title">곡류</div>
<label><input type="checkbox"> 밥</label>
<label><input type="checkbox"> 보리</label>
<label><input type="checkbox"> 귀리</label>
<label><input type="checkbox"> 현미</label>
<label><input type="checkbox"> 찹쌀</label>
<label><input type="checkbox"> 빵</label>
</div>
<div class="subcategory" id="mushroom">
<div class="subcategory-title">버섯류</div>
<label><input type="checkbox"> 표고버섯</label>
<label><input type="checkbox"> 느타리버섯</label>
<label><input type="checkbox"> 새송이버섯</label>
<label><input type="checkbox"> 팽이버섯</label>
<label><input type="checkbox"> 양송이버섯</label>
</div>
<div class="subcategory" id="etc">
<div class="subcategory-title">기타 / 양념</div>
<label><input type="checkbox"> 고추장</label>
<label><input type="checkbox"> 된장</label>
<label><input type="checkbox"> 간장</label>
<label><input type="checkbox"> 설탕</label>
<label><input type="checkbox"> 참기름</label>
<label><input type="checkbox"> 마늘</label>
<label><input type="checkbox"> 생강</label>
<label><input type="checkbox"> 소금</label>
<label><input type="checkbox"> 식초</label>
<label><input type="checkbox"> 후추</label>
<label><input type="checkbox"> 고춧가루</label>
<label><input type="checkbox"> 식용유</label>
</div>
<!-- [1] 검색 결과 표시 영역 추가 -->
<h2>검색 결과</h2>
<div id="search-result" class="search-result">
<!-- 여기에 추천 음식 카드가 렌더링됨 -->
</div>
</body>
</html>