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 (tagField.value.length > 0) {
|
||||
let tagSetVal = tagField.value.toLowerCase();
|
||||
let tagSetVal = tagField.value.toLocaleLowerCase();
|
||||
if (!tagSet.has(tagSetVal)) {
|
||||
let tagLabel = document.createElement("label");
|
||||
tagLabel.innerHTML = tagField.value;
|
||||
|
@ -105,7 +105,7 @@ function setupUpdate() {
|
||||
|
||||
let tagSetVal;
|
||||
for (let i = 0; i < currReview["tags"].length; i++) {
|
||||
tagSetVal = currReview["tags"][i].toLowerCase();
|
||||
tagSetVal = currReview["tags"][i].toLocaleLowerCase();
|
||||
tagSet.add(tagSetVal);
|
||||
let newTag = document.createElement("label");
|
||||
newTag.setAttribute("class", "tag");
|
||||
@ -250,7 +250,7 @@ function setupUpdate() {
|
||||
tagAddBtn.addEventListener("click", () => {
|
||||
let tagField = document.getElementById("tag-form");
|
||||
if (tagField.value.length > 0) {
|
||||
let tagSetVal = tagField.value.toLowerCase();
|
||||
let tagSetVal = tagField.value.toLocaleLowerCase();
|
||||
if (!tagSet.has(tagSetVal)) {
|
||||
let tagLabel = document.createElement("label");
|
||||
tagLabel.innerHTML = tagField.value;
|
||||
|
@ -101,8 +101,8 @@ export function updateReviewToStorage(ID, review) {
|
||||
let repeatedTags = review["tags"].filter((x) => oldReview["tags"].includes(x));
|
||||
let tagArr = [];
|
||||
for (let i in repeatedTags) {
|
||||
tagArr = JSON.parse(localStorage.getItem(`!${repeatedTags[i]}`.toLocaleLowerCase()));
|
||||
if (tagArr.length == 1) {
|
||||
tagArr = JSON.parse(localStorage.getItem(`!${repeatedTags[i].toLocaleLowerCase()}`));
|
||||
if (tagArr.length !== 1) {
|
||||
for (let j in tagArr) {
|
||||
if (tagArr[j] == ID) {
|
||||
tagArr.splice(j, 1);
|
||||
@ -110,7 +110,7 @@ export function updateReviewToStorage(ID, review) {
|
||||
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) {
|
||||
for (let i in deletedTags) {
|
||||
//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));
|
||||
for (let j in tagArr) {
|
||||
if (tagArr[j] == ID) {
|
||||
@ -193,7 +193,7 @@ function deleteTagsFromStorage(ID, deletedTags) {
|
||||
*/
|
||||
function addTagsToStorage(ID, addedTags) {
|
||||
for (let i in addedTags) {
|
||||
let tagName = "!" + addedTags[i].toLowerCase();
|
||||
let tagName = "!" + addedTags[i].toLocaleLowerCase();
|
||||
let tagArr = JSON.parse(localStorage.getItem(tagName));
|
||||
if (!tagArr) {
|
||||
tagArr = [];
|
||||
@ -243,7 +243,7 @@ export function getIDsFromStorage() {
|
||||
* @returns {number[]} list of IDs of reviews that all contain the specified tag by recency
|
||||
*/
|
||||
export function getIDsByTag(tag) {
|
||||
let tagArr = JSON.parse(localStorage.getItem("!" + tag.toLowerCase()));
|
||||
let tagArr = JSON.parse(localStorage.getItem("!" + tag.toLocaleLowerCase()));
|
||||
if (!tagArr) {
|
||||
tagArr = [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user