Add functional service worker caching towards local first functionality,

fix favicon link issue in ReviewDetails.html
Co-authored-by: rheabhutada02 <rheabhutada02@users.noreply.github.com>

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu
2022-11-30 16:18:18 -08:00
parent fa7b8dc7f5
commit 3580941207
4 changed files with 60 additions and 2 deletions

View File

@@ -99,7 +99,7 @@ function setupUpdate(){
while (tagContainer.firstChild) {
tagContainer.removeChild(tagContainer.firstChild);
}
let tagSetVal = currReview["tags"][i].toLowerCase()
let tagSetVal = currReview["tags"][i].toLowerCase();
for (let i = 0; i < currReview["tags"].length; i++) {
tagSet.add(tagSetVal);
let newTag = document.createElement("label");

View File

@@ -40,3 +40,16 @@ function initFormHandler() {
window.location.assign("./CreatePage.html");
});
}
const registerServiceWorker = async () => {
if ("serviceWorker" in navigator) {
try {
const registration = await navigator.serviceWorker.register("./sw.js", {
scope: "./",
});
} catch (error) {
console.error(`Registration failed with ${error}`);
}
}
};
registerServiceWorker();