mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 05:34:44 +00:00
lowercase tag fix part2
This commit is contained in:
parent
793e7891b3
commit
9e20782c07
@ -154,7 +154,7 @@ function initFormHandler() {
|
|||||||
|
|
||||||
// If there is a tag, it'll display the tag
|
// If there is a tag, it'll display the tag
|
||||||
if (tagField.value.length > 0) {
|
if (tagField.value.length > 0) {
|
||||||
let tagSetVal = tagField.value.toLowerCase();
|
let tagSetVal = tagField.value.toLocaleLowerCase();
|
||||||
if (!tagSet.has(tagSetVal)) {
|
if (!tagSet.has(tagSetVal)) {
|
||||||
let tagLabel = document.createElement("label");
|
let tagLabel = document.createElement("label");
|
||||||
tagLabel.innerHTML = tagField.value;
|
tagLabel.innerHTML = tagField.value;
|
||||||
|
@ -105,7 +105,7 @@ function setupUpdate() {
|
|||||||
|
|
||||||
let tagSetVal;
|
let tagSetVal;
|
||||||
for (let i = 0; i < currReview["tags"].length; i++) {
|
for (let i = 0; i < currReview["tags"].length; i++) {
|
||||||
tagSetVal = currReview["tags"][i].toLowerCase();
|
tagSetVal = currReview["tags"][i].toLocaleLowerCase();
|
||||||
tagSet.add(tagSetVal);
|
tagSet.add(tagSetVal);
|
||||||
let newTag = document.createElement("label");
|
let newTag = document.createElement("label");
|
||||||
newTag.setAttribute("class", "tag");
|
newTag.setAttribute("class", "tag");
|
||||||
@ -250,7 +250,7 @@ function setupUpdate() {
|
|||||||
tagAddBtn.addEventListener("click", () => {
|
tagAddBtn.addEventListener("click", () => {
|
||||||
let tagField = document.getElementById("tag-form");
|
let tagField = document.getElementById("tag-form");
|
||||||
if (tagField.value.length > 0) {
|
if (tagField.value.length > 0) {
|
||||||
let tagSetVal = tagField.value.toLowerCase();
|
let tagSetVal = tagField.value.toLocaleLowerCase();
|
||||||
if (!tagSet.has(tagSetVal)) {
|
if (!tagSet.has(tagSetVal)) {
|
||||||
let tagLabel = document.createElement("label");
|
let tagLabel = document.createElement("label");
|
||||||
tagLabel.innerHTML = tagField.value;
|
tagLabel.innerHTML = tagField.value;
|
||||||
|
@ -101,8 +101,8 @@ export function updateReviewToStorage(ID, review) {
|
|||||||
let repeatedTags = review["tags"].filter((x) => oldReview["tags"].includes(x));
|
let repeatedTags = review["tags"].filter((x) => oldReview["tags"].includes(x));
|
||||||
let tagArr = [];
|
let tagArr = [];
|
||||||
for (let i in repeatedTags) {
|
for (let i in repeatedTags) {
|
||||||
tagArr = JSON.parse(localStorage.getItem(`!${repeatedTags[i]}`.toLocaleLowerCase()));
|
tagArr = JSON.parse(localStorage.getItem(`!${repeatedTags[i].toLocaleLowerCase()}`));
|
||||||
if (tagArr.length == 1) {
|
if (tagArr.length !== 1) {
|
||||||
for (let j in tagArr) {
|
for (let j in tagArr) {
|
||||||
if (tagArr[j] == ID) {
|
if (tagArr[j] == ID) {
|
||||||
tagArr.splice(j, 1);
|
tagArr.splice(j, 1);
|
||||||
@ -110,7 +110,7 @@ export function updateReviewToStorage(ID, review) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem(`!${repeatedTags[i]}`, JSON.stringify(tagArr));
|
localStorage.setItem(`!${repeatedTags[i].toLocaleLowerCase()}`, JSON.stringify(tagArr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ export function deleteReviewFromStorage(ID) {
|
|||||||
function deleteTagsFromStorage(ID, deletedTags) {
|
function deleteTagsFromStorage(ID, deletedTags) {
|
||||||
for (let i in deletedTags) {
|
for (let i in deletedTags) {
|
||||||
//get local storage of each tag and remove id from tag list
|
//get local storage of each tag and remove id from tag list
|
||||||
let tagName = "!" + deletedTags[i].toLowerCase();
|
let tagName = "!" + deletedTags[i].toLocaleLowerCase();
|
||||||
let tagArr = JSON.parse(localStorage.getItem(tagName));
|
let tagArr = JSON.parse(localStorage.getItem(tagName));
|
||||||
for (let j in tagArr) {
|
for (let j in tagArr) {
|
||||||
if (tagArr[j] == ID) {
|
if (tagArr[j] == ID) {
|
||||||
@ -193,7 +193,7 @@ function deleteTagsFromStorage(ID, deletedTags) {
|
|||||||
*/
|
*/
|
||||||
function addTagsToStorage(ID, addedTags) {
|
function addTagsToStorage(ID, addedTags) {
|
||||||
for (let i in addedTags) {
|
for (let i in addedTags) {
|
||||||
let tagName = "!" + addedTags[i].toLowerCase();
|
let tagName = "!" + addedTags[i].toLocaleLowerCase();
|
||||||
let tagArr = JSON.parse(localStorage.getItem(tagName));
|
let tagArr = JSON.parse(localStorage.getItem(tagName));
|
||||||
if (!tagArr) {
|
if (!tagArr) {
|
||||||
tagArr = [];
|
tagArr = [];
|
||||||
@ -243,7 +243,7 @@ export function getIDsFromStorage() {
|
|||||||
* @returns {number[]} list of IDs of reviews that all contain the specified tag by recency
|
* @returns {number[]} list of IDs of reviews that all contain the specified tag by recency
|
||||||
*/
|
*/
|
||||||
export function getIDsByTag(tag) {
|
export function getIDsByTag(tag) {
|
||||||
let tagArr = JSON.parse(localStorage.getItem("!" + tag.toLowerCase()));
|
let tagArr = JSON.parse(localStorage.getItem("!" + tag.toLocaleLowerCase()));
|
||||||
if (!tagArr) {
|
if (!tagArr) {
|
||||||
tagArr = [];
|
tagArr = [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user