mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 05:34:44 +00:00
Documentation for ReviewDetails.js
This commit is contained in:
parent
ea41495e49
commit
58e4f6fdeb
@ -4,6 +4,9 @@ import {deleteReviewFromStorage, getReviewFromStorage, updateReviewToStorage} fr
|
|||||||
// Run the init() function when the page has loaded
|
// Run the init() function when the page has loaded
|
||||||
window.addEventListener("DOMContentLoaded", init);
|
window.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the relevant data to the details from local storage review.
|
||||||
|
*/
|
||||||
function init(){
|
function init(){
|
||||||
setupInfo();
|
setupInfo();
|
||||||
setupDelete();
|
setupDelete();
|
||||||
@ -51,6 +54,9 @@ function setupInfo(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up delete button to delete reveiw from storage and switch to homepage.
|
||||||
|
*/
|
||||||
function setupDelete(){
|
function setupDelete(){
|
||||||
let deleteBtn = document.getElementById("delete-btn");
|
let deleteBtn = document.getElementById("delete-btn");
|
||||||
let currID = JSON.parse(sessionStorage.getItem("currID"));
|
let currID = JSON.parse(sessionStorage.getItem("currID"));
|
||||||
@ -63,6 +69,9 @@ function setupDelete(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up update button to reveal form and update info in storage and the current page.
|
||||||
|
*/
|
||||||
function setupUpdate(){
|
function setupUpdate(){
|
||||||
let updateBtn = document.getElementById("update-btn");
|
let updateBtn = document.getElementById("update-btn");
|
||||||
let currID = JSON.parse(sessionStorage.getItem("currID"));
|
let currID = JSON.parse(sessionStorage.getItem("currID"));
|
||||||
@ -139,12 +148,11 @@ function setupUpdate(){
|
|||||||
|
|
||||||
//Take formdata values as newData when submit
|
//Take formdata values as newData when submit
|
||||||
form.addEventListener("submit", function(){
|
form.addEventListener("submit", function(){
|
||||||
/*
|
//We create reviewCard datea, replace it in in storage, and update tags
|
||||||
* User submits the form for their review.
|
|
||||||
* We create reviewCard and put in storage
|
|
||||||
*/
|
|
||||||
let formData = new FormData(form);
|
let formData = new FormData(form);
|
||||||
let newData = {};
|
let newData = {};
|
||||||
|
|
||||||
|
// Iterate through formData an add to newData
|
||||||
for (let [key, value] of formData) {
|
for (let [key, value] of formData) {
|
||||||
console.log(`${key}`);
|
console.log(`${key}`);
|
||||||
console.log(`${value}`);
|
console.log(`${value}`);
|
||||||
@ -175,6 +183,7 @@ function setupUpdate(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Adding tag to form functionality
|
||||||
let tagAddBtn = document.getElementById("tag-add-btn");
|
let tagAddBtn = document.getElementById("tag-add-btn");
|
||||||
tagAddBtn.addEventListener("click", ()=> {
|
tagAddBtn.addEventListener("click", ()=> {
|
||||||
let tagField = document.getElementById("tag-form");
|
let tagField = document.getElementById("tag-form");
|
||||||
|
Loading…
Reference in New Issue
Block a user