mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
default img if img fails to load
This commit is contained in:
parent
1db54e9f7a
commit
52bc6a27a4
@ -138,12 +138,11 @@ class ReviewCard extends HTMLElement {
|
|||||||
let mealImg = document.createElement("img");
|
let mealImg = document.createElement("img");
|
||||||
mealImg.setAttribute("id", "a-mealImg");
|
mealImg.setAttribute("id", "a-mealImg");
|
||||||
mealImg.setAttribute("alt","Meal Photo Corrupted");
|
mealImg.setAttribute("alt","Meal Photo Corrupted");
|
||||||
if(data["mealImg"] != ""){
|
mealImg.setAttribute("src",data["mealImg"]);
|
||||||
mealImg.setAttribute("src",data["mealImg"]);
|
mealImg.addEventListener("error", function(e) {
|
||||||
}
|
|
||||||
else{
|
|
||||||
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
||||||
}
|
e.onerror = null;
|
||||||
|
});
|
||||||
|
|
||||||
//meal name setup
|
//meal name setup
|
||||||
let mealLabel = document.createElement("label");
|
let mealLabel = document.createElement("label");
|
||||||
|
@ -16,12 +16,11 @@ function setupInfo(){
|
|||||||
|
|
||||||
//meal image
|
//meal image
|
||||||
let mealImg = document.getElementById("d-mealImg");
|
let mealImg = document.getElementById("d-mealImg");
|
||||||
if(currReview["mealImg"] != ""){
|
mealImg.setAttribute("src",currReview["mealImg"]);
|
||||||
mealImg.setAttribute("src",currReview["mealImg"]);
|
mealImg.addEventListener("error", function(e) {
|
||||||
}
|
|
||||||
else{
|
|
||||||
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
||||||
}
|
e.onerror = null;
|
||||||
|
});
|
||||||
|
|
||||||
//meal name
|
//meal name
|
||||||
let mealLabel = document.getElementById("d-mealName");
|
let mealLabel = document.getElementById("d-mealName");
|
||||||
@ -78,7 +77,6 @@ function setupUpdate(){
|
|||||||
|
|
||||||
//Set value of each input element to current's values
|
//Set value of each input element to current's values
|
||||||
document.getElementById("mealImg").defaultValue = currReview["mealImg"];
|
document.getElementById("mealImg").defaultValue = currReview["mealImg"];
|
||||||
document.getElementById("imgAlt").defaultValue = currReview["imgAlt"];
|
|
||||||
document.getElementById("mealName").defaultValue = currReview["mealName"];
|
document.getElementById("mealName").defaultValue = currReview["mealName"];
|
||||||
document.getElementById("comments").textContent = currReview["comments"];
|
document.getElementById("comments").textContent = currReview["comments"];
|
||||||
document.getElementById("s" + `${currReview["rating"]}`).checked = true;
|
document.getElementById("s" + `${currReview["rating"]}`).checked = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user