-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
231 lines (178 loc) · 7.26 KB
/
script.js
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
function addItem(name){
var ul = document.getElementById("DList");
var li = document.createElement("li");
li.setAttribute('id',name);
li.appendChild(document.createTextNode(name));
ul.appendChild(li);
}
function removeItem(name){
var ul = document.getElementById("DList");
var item = document.getElementById(name);
ul.removeChild(item);
}
var dish = `
{
"recipes": [
{"name": "Roti",
"link": "https://www.cookwithmanali.com/roti-recipe/",
"ingredients": "wheat flour"},
{"name": "French Toast",
"link": "https://www.allrecipes.com/recipe/7016/french-toast-i/",
"ingredients": "bread;eggs;milk"},
{"name": "Veg Manchurian",
"link": "https://recipes.timesofindia.com/recipes/vegetable-manchurian/rs54507152.cms",
"ingredients": "cabbage;cauliflower;green beans;soy sauce;all purpose flour;bell peppers;capsicum;tomato ketchup;carrot;paneer;corn starch;onion"},
{"name": "Chilli Chicken",
"link": "https://recipes.timesofindia.com/recipes/chilli-chicken/rs53094926.cms",
"ingredients": "chicken;corn starc;egg;onion;soy sauce;vinegar;capsicum"},
{"name": "Potato Fry",
"link": "https://www.indianhealthyrecipes.com/tawa-aloo-potato-fry/",
"ingredients": "Potato;Garlic;Chillies"},
{"name": "Pav Bhaji",
"link": "https://recipes.timesofindia.com/recipes/pav-bhaji-by-pankaj-bhadouria/rs52416693.cms",
"ingredients": "Potato;onion;cauliflower;peas;beans;tomato;capsicum;carrot"},
{"name": "Aloo Paratha",
"link": "https://recipes.timesofindia.com/recipes/aloo-paratha/rs53109843.cms",
"ingredients": "Potato;ghee;onion;Wheat flour"},
{"name": "Bread pakora",
"link": "https://recipes.timesofindia.com/recipes/bread-pakora/rs53240499.cms",
"ingredients": "Bread;Potato;Gram flour"},
{"name": "Samosa",
"link": "https://recipes.timesofindia.com/recipes/samosa/rs61050397.cms",
"ingredients": "All purpose flour;Potato"},
{"name": "Gajar ka Halwa",
"link": "https://recipes.timesofindia.com/recipes/gajar-ka-halwa/rs53317590.cms",
"ingredients": "carrot;milk;sugar;nuts"},
{"name": "Chicken Biryani",
"link": "https://recipes.timesofindia.com/recipes/chicken-biryani/rs53096628.cms",
"ingredients": "Rice;Chicken;Onion;garlic;yoghurt;Ghee;Ginger"},
{"name": "Veg Biryani",
"link": "https://recipes.timesofindia.com/recipes/vegetable-biryani-by-pankaj-bhadouria/rs53098310.cms",
"ingredients": "Rice;Onion;Potato;Ghee;Beans;Yoghurt;Peas;Cauliflower;Carrot;Butter"},
{"name": "Shahi Paneer",
"link": "https://recipes.timesofindia.com/recipes/shahi-paneer/rs52446409.cms",
"ingredients": "paneer;tomato;onion;yoghurt;ghee;milk;nuts"},
{"name": "Momos",
"link": "https://www.vegrecipesofindia.com/veg-momos-recipe-vegetable-momos/",
"ingredients": "All purpose flour;onion;cabbage;capsicum;carrot;beans"},
{"name": "Gulab Jamun",
"link": "https://www.indianhealthyrecipes.com/gulab-jamun-recipe-using-milk-powder/",
"ingredients": "Milk Powder;All Purpose Flour;Sugar"},
{"name": "Egg Curry",
"link": "https://recipes.timesofindia.com/recipes/egg-curry/rs78894806.cms",
"ingredients": "onion;tomato;eggs"},
{"name": "Amritsari Kulcha",
"link": "https://recipes.timesofindia.com/recipes/amritsari-kulcha/rs62376759.cms ",
"ingredients": "all purpose flour;potato;baking powder;baking soda;curd;milk"},
{"name": "Dhokla",
"link": "https://foodviva.com/snacks-recipes/khaman-dhokla-recipe/",
"ingredients": "Gram flour;Lemon Juice;Yoghurt"},
{"name": "Instant Dosa",
"link": "https://hebbarskitchen.com/crisp-instant-dosa-recipe/",
"ingredients": "Semolina;Rice Flour;Wheat Flour;yoghurt;Baking Soda"},
{"name": "Coconut Chutney",
"link": "https://www.indianhealthyrecipes.com/coriander-coconut-chutney/",
"ingredients": "Coconut;Ginger;Coriander;Chillies"},
{"name": "Khichdi",
"link": "https://www.indianhealthyrecipes.com/dal-khichdi-recipe/",
"ingredients": "Moong;Ghee;Onion;Tomato;Rice"},
{"name": "Ras Malai",
"link": "https://recipes.timesofindia.com/recipes/ras-malai/rs53929101.cms",
"ingredients": "milk;sugar;saffron;nuts;pistacahios"},
{"name": "Medu Vada",
"link": "https://recipes.timesofindia.com/recipes/medu-vada/rs53281774.cms",
"ingredients": "urad dal;onion;peppericorn;asafoetida"},
{"name": "Dal Makhni",
"link": "https://recipes.timesofindia.com/recipes/dal-makhani-by-pankaj-bhadouria/rs53097626.cms",
"ingredients": "rajma;onion;tomato;urad dal"},
{"name": "Pasta",
"link": "https://www.indianhealthyrecipes.com/masala-pasta/",
"ingredients": "Pasta;Chillies;Garlic;Onion;Tomato;Capsicum"},
{"name": "Poha",
"link": "https://food.ndtv.com/recipe-chivda-poha-99033",
"ingredients": "poha;asafoetida;onion;potato"},
{"name": "Malai Kofta",
"link": "https://recipes.timesofindia.com/recipes/malai-kofta/rs53225025.cms",
"ingredients": "paneer;all purpose flour;corn starch;nuts;butter;cream;onion"},
{"name": "Raita",
"link": "https://www.indianhealthyrecipes.com/raita-recipes-biryani-pulao-kababs/",
"ingredients": "Yoghurt;Onion;Cucumber"},
{"name": "Bhatura",
"link": "https://www.yummytummyaarthi.com/chole-bhature-battura-how-to-make/",
"ingredients": "All purpose flour - Yoghurt - Milk - Oil"},
{"name": "Lachha Paratha",
"link": "https://www.tarladalal.com/lachha-paratha-how-to-make-lachha-paratha-181r",
"ingredients": "Wheat flour - ghee"},
{"name": "Omlette",
"link": "https://www.bbcgoodfood.com/recipes/basic-omelette",
"ingredients": "Egg - oil"},
{"name": "Half Fry Egg",
"link": "https://simmertoslimmer.com/half-fried-eggs/",
"ingredients": "Egg - oil"},
{"name": "Matar Paneer",
"link": "https://www.bawarchi.com/recipe/plain-matar-paneer-oetc6Hhgiegaf.html",
"ingredients": "Paneer - Peas - onion - tomato - Ginger - Garlic"},
{"name": "Nimbu Paani",
"link": "https://www.spiceupthecurry.com/nimbu-pani-recipe/",
"ingredients": "Lemon Juice"},
{"name": "Plain Rice",
"link": "https://vegecravings.com/plain-basmati-rice-recipe/",
"ingredients": "Rice"},
{"name": "Paneer Paratha",
"link": "https://hebbarskitchen.com/paneer-paratha-recipe/",
"ingredients": "Paneer - Wheat Flour"},
{"name": "Lassi",
"link": "https://www.allrecipes.com/recipe/20435/indian-lassi/",
"ingredients": "Yoghurt - Sugar"}
]
}
`;
var looper;
var looper2;
var totDish = JSON.parse(dish);
var dishFind = [];
var chosen = [];
var isFound =false;
$(document).ready(function(){
$(".row img").imgCheckbox({
onload: function(){
},
onclick: function(el){
var isChecked = el.hasClass("imgChked"),
imgEl = el.children()[0];
if(isChecked){
chosen.push(imgEl.name.toLocaleLowerCase());
addItem(imgEl.name);
}else{
chosen.splice(chosen.indexOf(imgEl.name.toLocaleLowerCase()), 1);
removeItem(imgEl.name);
}
console.log(chosen);
}
});
$(".button").click(function(){
for(looper of totDish["recipes"]){
//for(looper2 of chosen){
/*if((looper["ingredients"].toLocaleLowerCase().includes(looper2.toLocaleLowerCase()))){
console.log(looper["name"] + " have " + looper);
isFound = true;
}else{
isFound = false;
break;
}*/
var ings = looper["ingredients"].toLocaleLowerCase().split(";");
var i;
isFound = true;
for(i of ings){
if(chosen.indexOf(i) == -1){
console.log()
isFound = false;
break;
}
}
if(isFound)
dishFind.push(looper);
}
localStorage.setItem("recipe", JSON.stringify(dishFind));
})
});