mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
review page functionality
This commit is contained in:
parent
d72e8ea601
commit
365e701924
@ -25,6 +25,9 @@
|
|||||||
<form id="new-food-entry">
|
<form id="new-food-entry">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Photo:</legend>
|
<legend>Photo:</legend>
|
||||||
|
<label>Your Image
|
||||||
|
<input type="file" name="reviewImg" accept="image/png, image/gif, image/jpeg" />
|
||||||
|
</label>
|
||||||
<label for="image-src">
|
<label for="image-src">
|
||||||
Source:
|
Source:
|
||||||
<input type="text" id="imgSrc" name="imgSrc">
|
<input type="text" id="imgSrc" name="imgSrc">
|
||||||
|
16
review.html
Normal file
16
review.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Food Journal</title>
|
||||||
|
|
||||||
|
<script src="/source/assets/scripts/reviewpage.js" type="module"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -124,6 +124,24 @@ class ReviewCard extends HTMLElement {
|
|||||||
mealLabel.setAttribute('class','meal-name');
|
mealLabel.setAttribute('class','meal-name');
|
||||||
mealLabel.innerHTML = data['mealName'];
|
mealLabel.innerHTML = data['mealName'];
|
||||||
|
|
||||||
|
//review page link
|
||||||
|
//giving it functionality to save the review card's info to session storage for loading the review page
|
||||||
|
let reviewLink = document.createElement('a');
|
||||||
|
reviewLink.setAttribute('href','./review.html')
|
||||||
|
reviewLink.innerHTML = 'review page'
|
||||||
|
reviewLink.addEventListener('click', () => {
|
||||||
|
sessionStorage.clear();
|
||||||
|
let currReview = {
|
||||||
|
"imgSrc": data['imgSrc'],
|
||||||
|
"imgAlt": data['imgAlt'],
|
||||||
|
"mealName": data['mealName'],
|
||||||
|
"restaurant": data['restaurant'],
|
||||||
|
"rating": data['rating'],
|
||||||
|
"tags": data['tags']
|
||||||
|
}
|
||||||
|
sessionStorage.setItem('currReview', JSON.stringify(currReview));
|
||||||
|
});
|
||||||
|
|
||||||
let restaurantLabel = document.createElement('label');
|
let restaurantLabel = document.createElement('label');
|
||||||
restaurantLabel.setAttribute('class','restaurant-name');
|
restaurantLabel.setAttribute('class','restaurant-name');
|
||||||
restaurantLabel.innerHTML = data['restaurant'];
|
restaurantLabel.innerHTML = data['restaurant'];
|
||||||
@ -148,6 +166,7 @@ class ReviewCard extends HTMLElement {
|
|||||||
|
|
||||||
articleEl.append(mealImg);
|
articleEl.append(mealImg);
|
||||||
articleEl.append(mealLabel);
|
articleEl.append(mealLabel);
|
||||||
|
articleEl.append(reviewLink)
|
||||||
articleEl.append(restaurantLabel);
|
articleEl.append(restaurantLabel);
|
||||||
articleEl.append(ratingDiv);
|
articleEl.append(ratingDiv);
|
||||||
articleEl.append(tagContainer);
|
articleEl.append(tagContainer);
|
||||||
|
10
source/assets/scripts/ReviewPage.js
Normal file
10
source/assets/scripts/ReviewPage.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Run the init() function when the page has loaded
|
||||||
|
window.addEventListener('DOMContentLoaded', init);
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
let result = sessionStorage.getItem('currReview')
|
||||||
|
|
||||||
|
let main = document.querySelector('main');
|
||||||
|
|
||||||
|
main.innerHTML = result
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user