forked from IBMHACK/IBMHACK.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (65 loc) · 2.18 KB
/
index.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
<html>
<header>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script type="text/javascript" src="food-processing.js"></script>
</header>
<body>
<h1 id="leftover">Leftovers</h1>
<input type="text" id="inText" value="What was your leftovers?" onfocus="if (this.value=='What was your leftovers?') this.value='';">
<div id="g1">
<button class="buttonz" id="clearButton" onclick="clearFields()">Clear list</button>
<button class="buttonz" id="addButton" onclick="addItem()">Add item</button>
<button class="buttonz" id="Submit" onclick="submitLeftovers()">Cooking time!</button>
</div>
<h2 id="FoodNames"></h2>
<div id="Foodlist">
</div>
<div id=="ingredients">
<h2>Ingredients</h2>
<ol id="content">Empty</ol>
</div>
<!-- Javascript for buttons and textfield -->
<script type="text/javascript">
var desc=[];
function refreshWord(){
var word="";
for(i=0;i<desc.length;i++){
word+= "<li>"+desc[i]+"</li>";
}
if(desc.length==0) word = "Empty";
document.getElementById("content").innerHTML = word;
}
function addItem() {
var newWord = document.getElementById("inText").value;
desc.push(newWord);
refreshWord();
document.getElementById("inText").value = "";
}
function clearFields(){
desc=[];
refreshWord();
}
function submitLeftovers(){
document.getElementById("FoodNames").value = "Food Name";
fetch(desc, printres);
}
var printres = function(results){
var listoffood = "";
for(j=0;j<results.length;j++){
var title = results[j].title;
var thumb = results[j].thumbnail;
var ingre = results[j].ingredients;
listoffood = listoffood + "<div class=\"FoodItem\">"+
"<h3 id=\"FoodTitle\">"+ title +"</h3>" +
"<img id=\"FoodImg\" src=\"" +thumb+ "\"/>"+
"<p id=\"FoodIngredients\">"+ ingre +"</p>" +
+"</div>";
}
document.getElementById("Foodlist").innerHTML = listoffood;
}
</script>
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>