mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
fix linting in js
This commit is contained in:
parent
89b7319dd8
commit
3422f584f9
@ -3,10 +3,10 @@ import { newReviewToStorage } from "./localStorage.js";
|
|||||||
window.addEventListener("DOMContentLoaded", init);
|
window.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
// get next id
|
// get next id
|
||||||
|
|
||||||
// creates the key
|
// creates the key
|
||||||
initFormHandler();
|
initFormHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ function initFormHandler() {
|
|||||||
let nextReviewId = newReviewToStorage(reviewObject);
|
let nextReviewId = newReviewToStorage(reviewObject);
|
||||||
sessionStorage.setItem("currID", JSON.stringify(nextReviewId));
|
sessionStorage.setItem("currID", JSON.stringify(nextReviewId));
|
||||||
|
|
||||||
window.location.assign('./ReviewDetails.html');
|
window.location.assign("./ReviewDetails.html");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -132,18 +132,18 @@ class ReviewCard extends HTMLElement {
|
|||||||
let articleEl = this.shadowEl.querySelector("article");
|
let articleEl = this.shadowEl.querySelector("article");
|
||||||
|
|
||||||
// setting the article elements for the review card
|
// setting the article elements for the review card
|
||||||
this.reviewID = data["reviewID"];
|
this.reviewID = data["reviewID"];
|
||||||
|
|
||||||
//image setup
|
//image setup
|
||||||
let mealImg = document.createElement("img");
|
let mealImg = document.createElement("img");
|
||||||
mealImg.setAttribute("id", "a-mealImg");
|
mealImg.setAttribute("id", "a-mealImg");
|
||||||
mealImg.setAttribute("alt",data["imgAlt"]);
|
mealImg.setAttribute("alt",data["imgAlt"]);
|
||||||
if(data["mealImg"] != ""){
|
if(data["mealImg"] != ""){
|
||||||
mealImg.setAttribute("src",data["mealImg"]);
|
mealImg.setAttribute("src",data["mealImg"]);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
mealImg.setAttribute("src", "./assets/images/icons/plate_with_cutlery.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
//meal name setup
|
//meal name setup
|
||||||
let mealLabel = document.createElement("label");
|
let mealLabel = document.createElement("label");
|
||||||
@ -187,7 +187,7 @@ class ReviewCard extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//adding final ID to data!
|
//adding final ID to data!
|
||||||
|
|
||||||
articleEl.append(mealImg);
|
articleEl.append(mealImg);
|
||||||
articleEl.append(mealLabel);
|
articleEl.append(mealLabel);
|
||||||
@ -223,7 +223,7 @@ class ReviewCard extends HTMLElement {
|
|||||||
let dataContainer = {};
|
let dataContainer = {};
|
||||||
|
|
||||||
// getting the article elements for the review card
|
// getting the article elements for the review card
|
||||||
dataContainer["reviewID"] = this.reviewID;
|
dataContainer["reviewID"] = this.reviewID;
|
||||||
|
|
||||||
//get image
|
//get image
|
||||||
let mealImg = this.shadowEl.getElementById("a-mealImg");
|
let mealImg = this.shadowEl.getElementById("a-mealImg");
|
||||||
|
@ -15,7 +15,7 @@ function setupDelete(){
|
|||||||
deleteBtn.addEventListener("click", function(){
|
deleteBtn.addEventListener("click", function(){
|
||||||
if(window.confirm("Are you sure you want to delete this entry?")){
|
if(window.confirm("Are you sure you want to delete this entry?")){
|
||||||
deleteReviewFromStorage(currID);
|
deleteReviewFromStorage(currID);
|
||||||
sessionStorage.removeItem('currID');
|
sessionStorage.removeItem("currID");
|
||||||
window.location.assign("./index.html");
|
window.location.assign("./index.html");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -52,8 +52,8 @@ export function deleteReviewFromStorage(ID){
|
|||||||
for (let i in activeIDS) {
|
for (let i in activeIDS) {
|
||||||
if (activeIDS[i] == ID) {
|
if (activeIDS[i] == ID) {
|
||||||
activeIDS.splice(i,1);
|
activeIDS.splice(i,1);
|
||||||
localStorage.setItem('activeIDS', JSON.stringify(activeIDS));
|
localStorage.setItem("activeIDS", JSON.stringify(activeIDS));
|
||||||
localStorage.removeItem(`review${ID}`)
|
localStorage.removeItem(`review${ID}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ export function getAllReviewsFromStorage() {
|
|||||||
}
|
}
|
||||||
//iterate thru activeIDS
|
//iterate thru activeIDS
|
||||||
let activeIDS = JSON.parse(localStorage.getItem("activeIDS"));
|
let activeIDS = JSON.parse(localStorage.getItem("activeIDS"));
|
||||||
let reviews = []
|
let reviews = [];
|
||||||
for (let i = 0; i < activeIDS.length; i++) {
|
for (let i = 0; i < activeIDS.length; i++) {
|
||||||
let currReview = JSON.parse(localStorage.getItem(`review${activeIDS[i]}`));
|
let currReview = JSON.parse(localStorage.getItem(`review${activeIDS[i]}`));
|
||||||
reviews.push(currReview);
|
reviews.push(currReview);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {strict as assert} from "node:assert";
|
import {strict as assert} from "node:assert";
|
||||||
import {describe, it, beforeEach} from "mocha";
|
import {describe, it, before, after} from "mocha";
|
||||||
import {newReviewToStorage, getReviewFromStorage, updateReviewToStorage, deleteReviewFromStorage, getAllReviewsFromStorage} from "./localStorage.js";
|
import {newReviewToStorage, getReviewFromStorage, updateReviewToStorage, deleteReviewFromStorage, getAllReviewsFromStorage} from "./localStorage.js";
|
||||||
|
|
||||||
describe("test app localStorage interaction", () => {
|
describe("test app localStorage interaction", () => {
|
||||||
@ -49,7 +49,7 @@ describe("test app localStorage interaction", () => {
|
|||||||
"restaurant": `sample restaurant ${i}`,
|
"restaurant": `sample restaurant ${i}`,
|
||||||
"rating": i,
|
"rating": i,
|
||||||
"tags": [`tag ${3*i}`, `tag ${3*i + 1}`, `tag ${3*i + 2}`]
|
"tags": [`tag ${3*i}`, `tag ${3*i + 1}`, `tag ${3*i + 2}`]
|
||||||
}
|
};
|
||||||
|
|
||||||
newReviewToStorage(new_review);
|
newReviewToStorage(new_review);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ describe("test app localStorage interaction", () => {
|
|||||||
"restaurant": `updated sample restaurant ${i}`,
|
"restaurant": `updated sample restaurant ${i}`,
|
||||||
"rating": i*2+i,
|
"rating": i*2+i,
|
||||||
"tags": [`tag ${3*i}`, `tag ${3*i + 1}`, `tag ${3*i + 2}`]
|
"tags": [`tag ${3*i}`, `tag ${3*i + 1}`, `tag ${3*i + 2}`]
|
||||||
}
|
};
|
||||||
new_review.reviewID = i;
|
new_review.reviewID = i;
|
||||||
|
|
||||||
reviews[i] = new_review;
|
reviews[i] = new_review;
|
||||||
|
Loading…
Reference in New Issue
Block a user