Merge Conflicts

This commit is contained in:
Kara Hoagland 2022-11-12 14:20:25 -08:00
commit 74f3bdde19
3 changed files with 56 additions and 6 deletions

16
review.html Normal file
View 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>
<h1>Current Review:</h1>
<main>
</main>
</body>
</html>

View File

@ -116,12 +116,12 @@ class ReviewCard extends HTMLElement {
* @param {Object} data - The data to pass into the <review-card>, must be of the * @param {Object} data - The data to pass into the <review-card>, must be of the
* following format: * following format:
* { * {
* "comments": "string",
* "imgAlt": "string",
* "mealImg": "string", * "mealImg": "string",
* "imgAlt": "string",
* "mealName": "string", * "mealName": "string",
* "restaurant": "string", * "comments": "string",
* "rating": number, * "rating": number,
* "restaurant": "string",
* "tags": string array * "tags": string array
* } * }
*/ */
@ -147,6 +147,26 @@ class ReviewCard extends HTMLElement {
mealLabel.innerHTML = data['mealName']; mealLabel.innerHTML = data['mealName'];
//restaurant name setup //restaurant name setup
/*
//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'],
"comments": data['comments'],
"rating": data['rating'],
"tags": data['tags']
}
sessionStorage.setItem('currReview', JSON.stringify(currReview));
});
*/
let restaurantLabel = document.createElement('label'); let restaurantLabel = document.createElement('label');
restaurantLabel.setAttribute('id', 'a-restaurant'); restaurantLabel.setAttribute('id', 'a-restaurant');
restaurantLabel.setAttribute('class','restaurant-name'); restaurantLabel.setAttribute('class','restaurant-name');
@ -184,6 +204,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);
@ -202,12 +223,12 @@ class ReviewCard extends HTMLElement {
* @return {Object} data - The data from the <review-card>, of the * @return {Object} data - The data from the <review-card>, of the
* following format: * following format:
* { * {
* "comments": "string",
* "imgAlt": "string",
* "mealImg": "string", * "mealImg": "string",
* "imgAlt": "string",
* "mealName": "string", * "mealName": "string",
* "restaurant": "string", * "comments": "string",
* "rating": number, * "rating": number,
* "restaurant": "string",
* "tags": string array * "tags": string array
* } * }
*/ */

View File

@ -0,0 +1,13 @@
// 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
let p = document.createElement('p')
p.innerHTML = JSON.parse(result)['comments']
main.append(p)
}