lowercase tag fix part2

This commit is contained in:
Kara Hoagland 2022-12-02 18:31:26 -08:00
parent 793e7891b3
commit 9e20782c07
3 changed files with 9 additions and 9 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 = [];
}