");
newH3.attr("class", "article-row-content-header");
newH3.text(response.drinks[i].strDrink);
divTitle.append(newH3);
divArray.push(divTitle);
var drinkId = response.drinks[i].idDrink;
drinkArray.push(drinkId)
}
//click function to initiate search when you click a drink to take you to the full details
$(".clickable").on("click", function () {
var clickedId = $(this).attr("id");
//function that takes the idea of first ajax and uses it to search a second ajax call by ID
function getInstructions(num) {
var drinkIngredients = "https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=" + num;
$.ajax({
url: drinkIngredients,
method: "GET"
}).then(function (data) {
divArray = [];
drinkArray = [];
$("#container").empty();
$("#container2").empty();
console.log(data);
var newerDiv = $("");
newerDiv.attr("class", "grid-x align-center")
$("#container2").append(newerDiv);
var drinkInfoDiv = $("");
drinkInfoDiv.attr("class", "medium-6 drink-info");
newerDiv.append(drinkInfoDiv);
var secondDiv = $("");
secondDiv.attr("class", "drink-name");
drinkInfoDiv.append(secondDiv);
var newerImg = $("");
newerImg.attr("src", data.drinks[0].strDrinkThumb);
newerImg.attr("class", "featured-drink")
secondDiv.append(newerImg);
var newerH3 = $("");
newerH3.attr("class", "drinkName");
newerH3.text(data.drinks[0].strDrink);
drinkInfoDiv.append(newerH3);
var newH5 = $("");
newH5.text("Ingredients:");
drinkInfoDiv.append(newH5);
var newUl = $("");
newUl.attr("class", "ingredients");
drinkInfoDiv.append(newUl);
var newLi = $("- ");
newLi.text(data.drinks[0].strIngredient1 + data.drinks[0].strMeasure1);
newUl.append(newLi);
for (var i = 2; i < 16; i++) {
if (data.drinks[0][`strIngredient${i}`]) {
var measure = ""
if (data.drinks[0][`strMeasure${i}`]) {
measure = data.drinks[0][`strMeasure${i}`]
}
var newLi = $("
- ");
newLi.text(data.drinks[0][`strIngredient${i}`] + " " + measure);
newUl.append(newLi);
}
}
var newerH5 = $("
");
newerH5.text("Glass typically used:");
drinkInfoDiv.append(newerH5);
var glassType = $("");
glassType.attr("class", "ingredients");
drinkInfoDiv.append(glassType);
var glassLi = $("- ");
glassLi.text(data.drinks[0].strGlass);
glassType.append(glassLi);
var instructionsH5 = $("
");
instructionsH5.text("Instructions:")
drinkInfoDiv.append(instructionsH5);
var detailedInstructions = $("
");
detailedInstructions.attr("class", "instructions");
detailedInstructions.text(data.drinks[0].strInstructions);
drinkInfoDiv.append(detailedInstructions);
});
}
getInstructions(clickedId);
})
function getInstructions(drinkId, num) {
var drinkIngredients = "https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=" + drinkId;
$.ajax({
url: drinkIngredients,
method: "GET"
}).then(function (data) {
//console.log(data);
var lastUl = $("
");
lastUl.attr("class", "ingredients");
for (var i = 1; i < 16; i++) {
if (data.drinks[0][`strIngredient${i}`]) {
var measure = ""
if (data.drinks[0][`strMeasure${i}`]) {
measure = data.drinks[0][`strMeasure${i}`]
}
var lastLi = $("- ");
lastLi.text(measure + " " + data.drinks[0][`strIngredient${i}`]);
lastUl.append(lastLi);
}
}
(divArray[num]).append(lastUl);
});
}
for (let i = 0; i < drinkArray.length; i++) {
getInstructions(drinkArray[i], [i]);
}
});
};
}).keydown(function (event) {
if (event.which == 13) {
event.preventDefault();
}
});
$("#btnMixMe").on("click submit", function search() {
divArray = [];
drinkArray = [];
$("#container").empty();
$("#container2").empty();
$(".meetMixMe").empty();
$(meetMixMe).empty();
var ingredient = $("#tempSearchBar").val().trim();
var queryURL = "https://www.thecocktaildb.com/api/json/v1/1/filter.php?i=" +
ingredient;
$.ajax({
url: queryURL,
method: "GET"
}).then(function (response) {
console.log(response);
if (response == "") {
$("#tempSearchBar").val("Not a valid ingredient, please try again")
$("#tempSearchBar").attr("class", "error");
} else
$("#tempSearchBar").attr("class", "errorFix");
for (var i = 0; i < response.drinks.length; i++) {
var newDiv = $("
");
newerH3.attr("class", "drinkName");
newerH3.text(data.drinks[0].strDrink);
drinkInfoDiv.append(newerH3);
var newH5 = $("");
newH5.text("Ingredients:");
drinkInfoDiv.append(newH5);
var newUl = $("");
newUl.attr("class", "ingredients");
drinkInfoDiv.append(newUl);
var newLi = $("- ");
newLi.text(data.drinks[0].strIngredient1 + data.drinks[0].strMeasure1);
newUl.append(newLi);
for (var i = 2; i < 16; i++) {
if (data.drinks[0][`strIngredient${i}`]) {
var measure = ""
if (data.drinks[0][`strMeasure${i}`]) {
measure = data.drinks[0][`strMeasure${i}`]
}
var newLi = $("
- ");
newLi.text(data.drinks[0][`strIngredient${i}`] + " " + measure);
newUl.append(newLi);
}
}
var newerH5 = $("
");
newerH5.text("Glass typically used:");
drinkInfoDiv.append(newerH5);
var glassType = $("");
glassType.attr("class", "ingredients");
drinkInfoDiv.append(glassType);
var glassLi = $("- ");
glassLi.text(data.drinks[0].strGlass);
glassType.append(glassLi);
var instructionsH5 = $("
");
instructionsH5.text("Instructions:")
drinkInfoDiv.append(instructionsH5);
var detailedInstructions = $("
");
detailedInstructions.attr("class", "instructions");
detailedInstructions.text(data.drinks[0].strInstructions);
drinkInfoDiv.append(detailedInstructions);
});
}
getInstructions(clickedId);
})
function getInstructions(drinkId, num) {
var drinkIngredients = "https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=" + drinkId;
$.ajax({
url: drinkIngredients,
method: "GET"
}).then(function (data) {
//console.log(data);
var lastUl = $("
");
lastUl.attr("class", "ingredients");
for (var i = 1; i < 16; i++) {
if (data.drinks[0][`strIngredient${i}`]) {
var measure = ""
if (data.drinks[0][`strMeasure${i}`]) {
measure = data.drinks[0][`strMeasure${i}`]
}
var lastLi = $("- ");
lastLi.text(measure + " " + data.drinks[0][`strIngredient${i}`]);
lastUl.append(lastLi);
}
}
(divArray[num]).append(lastUl);
});
}
for (let i = 0; i < drinkArray.length; i++) {
getInstructions(drinkArray[i], [i]);
}
});
};
}).keydown(function (event) {
if (event.which == 13) {
event.preventDefault();
}
});
$("#btnMixMe").on("click submit", function search() {
divArray = [];
drinkArray = [];
$("#container").empty();
$("#container2").empty();
$(".meetMixMe").empty();
$(meetMixMe).empty();
var ingredient = $("#tempSearchBar").val().trim();
var queryURL = "https://www.thecocktaildb.com/api/json/v1/1/filter.php?i=" +
ingredient;
$.ajax({
url: queryURL,
method: "GET"
}).then(function (response) {
console.log(response);
if (response == "") {
$("#tempSearchBar").val("Not a valid ingredient, please try again")
$("#tempSearchBar").attr("class", "error");
} else
$("#tempSearchBar").attr("class", "errorFix");
for (var i = 0; i < response.drinks.length; i++) {
var newDiv = $("
- ");
newUl.attr("class", "ingredients");
drinkInfoDiv.append(newUl);
var newLi = $("
- "); newLi.text(data.drinks[0].strIngredient1 + data.drinks[0].strMeasure1); newUl.append(newLi); for (var i = 2; i < 16; i++) { if (data.drinks[0][`strIngredient${i}`]) { var measure = "" if (data.drinks[0][`strMeasure${i}`]) { measure = data.drinks[0][`strMeasure${i}`] } var newLi = $("
- ");
newLi.text(data.drinks[0][`strIngredient${i}`] + " " + measure);
newUl.append(newLi);
}
}
var newerH5 = $("
"); newerH5.text("Glass typically used:"); drinkInfoDiv.append(newerH5); var glassType = $("
- ");
glassType.attr("class", "ingredients");
drinkInfoDiv.append(glassType);
var glassLi = $("
- ");
glassLi.text(data.drinks[0].strGlass);
glassType.append(glassLi);
var instructionsH5 = $("
"); instructionsH5.text("Instructions:") drinkInfoDiv.append(instructionsH5); var detailedInstructions = $("
"); detailedInstructions.attr("class", "instructions"); detailedInstructions.text(data.drinks[0].strInstructions); drinkInfoDiv.append(detailedInstructions); }); } getInstructions(clickedId); }) function getInstructions(drinkId, num) { var drinkIngredients = "https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=" + drinkId; $.ajax({ url: drinkIngredients, method: "GET" }).then(function (data) { //console.log(data); var lastUl = $("
- ");
lastUl.attr("class", "ingredients");
for (var i = 1; i < 16; i++) {
if (data.drinks[0][`strIngredient${i}`]) {
var measure = ""
if (data.drinks[0][`strMeasure${i}`]) {
measure = data.drinks[0][`strMeasure${i}`]
}
var lastLi = $("
- "); lastLi.text(measure + " " + data.drinks[0][`strIngredient${i}`]); lastUl.append(lastLi); } } (divArray[num]).append(lastUl); }); } for (let i = 0; i < drinkArray.length; i++) { getInstructions(drinkArray[i], [i]); } }); }; }).keydown(function (event) { if (event.which == 13) { event.preventDefault(); } }); $("#btnMixMe").on("click submit", function search() { divArray = []; drinkArray = []; $("#container").empty(); $("#container2").empty(); $(".meetMixMe").empty(); $(meetMixMe).empty(); var ingredient = $("#tempSearchBar").val().trim(); var queryURL = "https://www.thecocktaildb.com/api/json/v1/1/filter.php?i=" + ingredient; $.ajax({ url: queryURL, method: "GET" }).then(function (response) { console.log(response); if (response == "") { $("#tempSearchBar").val("Not a valid ingredient, please try again") $("#tempSearchBar").attr("class", "error"); } else $("#tempSearchBar").attr("class", "errorFix"); for (var i = 0; i < response.drinks.length; i++) { var newDiv = $("
- ");
glassLi.text(data.drinks[0].strGlass);
glassType.append(glassLi);
var instructionsH5 = $("