From 82aba63baf7f83dc0252d7d7ce4338130d85f269 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 1 Dec 2022 17:01:05 -0800 Subject: [PATCH] fix styling issue, fix bug in service worker and search URI Signed-off-by: Arthur Lu --- source/assets/scripts/ReviewDetails.js | 2 +- source/assets/scripts/localStorage.js | 2 +- source/assets/scripts/main.js | 6 +++--- source/sw.js | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/assets/scripts/ReviewDetails.js b/source/assets/scripts/ReviewDetails.js index c28b722..a60b5d6 100644 --- a/source/assets/scripts/ReviewDetails.js +++ b/source/assets/scripts/ReviewDetails.js @@ -102,7 +102,7 @@ function setupUpdate(){ let tagSetVal; for (let i = 0; i < currReview["tags"].length; i++) { - tagSetVal = currReview["tags"][i].toLowerCase() + tagSetVal = currReview["tags"][i].toLowerCase(); tagSet.add(tagSetVal); let newTag = document.createElement("label"); newTag.setAttribute("class","tag"); diff --git a/source/assets/scripts/localStorage.js b/source/assets/scripts/localStorage.js index 852d02c..093e711 100644 --- a/source/assets/scripts/localStorage.js +++ b/source/assets/scripts/localStorage.js @@ -89,7 +89,7 @@ export function updateReviewToStorage(ID, review){ //stars update recency if unchanged for (let i in starArr){ if(starArr[i] == ID) { - starArr.splice(i,1) + starArr.splice(i,1); starArr.push(ID); break; } diff --git a/source/assets/scripts/main.js b/source/assets/scripts/main.js index f746d6e..7f57f1b 100644 --- a/source/assets/scripts/main.js +++ b/source/assets/scripts/main.js @@ -48,7 +48,7 @@ function initFormHandler() { searchTag = null; searchField.value = ""; sortAndFilter(searchTag); - }) + }); //sort by selected method let sortMethod = document.getElementById("sort"); @@ -142,7 +142,7 @@ function loadReviews(index, reviewIDs){ moreBtn.setAttribute("id", "more-btn"); moreBtn.innerText = "Load More"; //if load more clicked, load 9 more - moreBtn.addEventListener("click", function(){loadReviews(index + 9, reviewIDs)}); + moreBtn.addEventListener("click", function(){loadReviews(index + 9, reviewIDs);}); reviewBox.append(moreBtn); } @@ -151,7 +151,7 @@ function loadReviews(index, reviewIDs){ const registerServiceWorker = async () => { if ("serviceWorker" in navigator) { try { - const registration = await navigator.serviceWorker.register("./sw.js", {scope: "./"}); + await navigator.serviceWorker.register("./sw.js", {scope: "./"}); } catch (error) { console.error(`Registration failed with ${error}`); } diff --git a/source/sw.js b/source/sw.js index 5c30f2e..20b1ca8 100644 --- a/source/sw.js +++ b/source/sw.js @@ -1,5 +1,6 @@ const CACHE_NAME = "food-journal-v1"; const ASSETS = [ + "/", "index.html", "ReviewDetails.html", "CreatePage.html", @@ -57,7 +58,7 @@ self.addEventListener("fetch", (event) => { // If there is not a network response, return the cached response // The ignoreVary option is used here to fix an issue where the service worker // would not serve certain requests unless the page was refreshed at least once - return cache.match(event.request, {ignoreVary: true}); + return cache.match(event.request, {ignoreVary: true, ignoreSearch: true}); }); })); });