-
Notifications
You must be signed in to change notification settings - Fork 1
/
search3.html
193 lines (167 loc) · 6.74 KB
/
search3.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>eatHarmony</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" type="image/png" href="http://eatharmony.gdhacks.com/images/eHarmonyfavicon.png">
<script src="superslides/dist/jquery.superslides.js" type="text/javascript"></script>
<script type='text/javascript'>
<!-- document.getElementById(skdjgh 'hostname' ).innerText = window.location.hostname; -->
$("form").ready(function(){
$("form").keypress(function(e) {
if(e.which == 13) {
e.preventDefault();
var ingreds = $("#search").val();
var ingredients = ingreds.split(',');
var url = parse(ingredients);
var ClassRecipe= function(data){
this.id=data.id;
this.ingredients=data.ingredients;
this.recipeName=data.recipeName;
this.image=data.smallImageUrls;
this.time=data.totalTimeInSeconds;
};
$.ajax({dataType: "jsonp",
url: url,
success: function(contents){
debugger;
var recipeNumber= contents.totalMatchCount;
var recipeArray= new Array();
for (var i=0; i<6; i++) {
var singleRecipe=new ClassRecipe(contents.matches[i]);
recipeArray.push(singleRecipe);
}
displayRecipes(recipeArray);},
error: function(report, a, b){console.log(b);}
});
$(".wrap").animate({'margin-top': '0'}, 2000);
$(".logo").animate({'height':'50px','width':'80%','padding-top':'20px','padding-bottom':'0px'}, 1000);
$(".bottomBar").animate({'padding-bottom':'0px'},2000);
$("#slides").slideDown();
$("h4").fadeOut();
/*$("form").animate({top: $(document).height()/2}, 2000);*/
}
});
});
var titles = new Array("r1","r2","r3","r4","r5","r6");
var images = new Array("i1","i2","i3","i4","i5","i6");
var ingred = new Array("recipe1","recipe2","recipe3","recipe4","recipe5","recipe6");
function displayRecipes(recipeArray)
{
for (var i = 0; i < 6; i++)
{
var rec = recipeArray[i];
console.log(recipeArray[i]);
document.getElementById(titles[i]).innerHTML=rec.recipeName;
var ing = rec.ingredients;
var text = ""
for (var j = 0; j < ing.length; j++)
{
text = text + ing[j] + ", "
}
if (ingred.length > 0)
{
document.getElementById(ingred[i]).innerHTML=text;
document.getElementById(images[i]).src = rec.image[0];
$(function() {
$(images[i]).width(200);
});
}
}
console.log(rec)
}
function parse(ingred)
{
var api = 'http://api.yummly.com/v1/api/recipes?_app_id=0f21d51f&_app_key=35ffecab7995ec9425116d3cd465713f&allowedIngredient[]='
for (var i = 0; i < ingred.length-1; i++)
{
var rec = ingred[i].trimLeft();
rec = rec.trimRight();
api = api + rec + '&allowedIngredient[]='
}
rec = ingred[ingred.length-1].trimLeft();
rec = rec.trimRight();
api = api + rec
return api
}
$(function() {
$("#slides").superslides({
hashchange: true,
animation_speed: 'slow' , pagination:false
});
});
</script>
</head>
<body>
<div class="wrap text-center">
<div class = "logo">
<a href="http://eatharmony.gdhacks.com/searchtest.html"><img src="images/EatHarmonyLogo.png" alt=""></a>
</div>
<h4 >
Are your single ingredients ready to mingle?
</h4>
<div id="slides">
<div class="slides-container">
debugger;
<div class="resultContainer">
<div class="resultDiv">
<span id = "r1"></span><br />
<img id = "i1"></span><br />
<span id = "recipe1"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
<div class="resultDiv">
<span id = "r2"></span><br />
<img id = "i2"></span><br />
<span id = "recipe2"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
<div class="resultDiv">
<span id = "r3"></span><br />
<img id = "i3"></span><br />
<span id = "recipe3"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
</div>
<div class="resultContainer">
<div class="resultDiv">
<span id = "r4"></span><br />
<img id = "i4"></span><br />
<span id = "recipe4"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
<div class="resultDiv">
<span id = "r5"></span><br />
<img id = "i5"></span><br />
<span id = "recipe5"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
<div class="resultDiv">
<span id = "r6">
<img id = "i6"></span><br />
<span id = "r6"></span><br />
<span id = "recipe6"></span><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>
</div>
<nav class="slides-navigation">
<a href="#" class="next">
>
</a>
<a href="#" class="prev">
<
</a>
</nav>
</div>
</div>
<div id="bottomBar">
<hr>
<form>
<span><input type="text" id = "search" class="search rounded" placeholder="e.g. bananas, spinach,..."></span>
</form>
</div>
</body>
</html>