From 1ea739207bb8bbecc7a69cf414991bef88d306fe Mon Sep 17 00:00:00 2001 From: int00h5525 <38926894+int00h5525@users.noreply.github.com> Date: Thu, 7 Nov 2019 13:25:48 -0600 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Neale Pickett --- theme/moth-pwa.js | 3 ++- theme/moth.js | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/theme/moth-pwa.js b/theme/moth-pwa.js index ccef77b..780bd1d 100644 --- a/theme/moth-pwa.js +++ b/theme/moth-pwa.js @@ -1,7 +1,8 @@ function pwa_init() { if ('serviceWorker' in navigator) { navigator.serviceWorker.register("./sw.js").then(function(reg) { - }).catch(function(err) { + }) + .catch(err => { console.warn("Error while registering service worker", err) }) } else { diff --git a/theme/moth.js b/theme/moth.js index 5644cae..1e0eab1 100644 --- a/theme/moth.js +++ b/theme/moth.js @@ -127,13 +127,14 @@ function drawCacheButton(teamId) { headers.append("pragma", "no-cache") headers.append("cache-control", "no-cache") fetch("current_manifest.json?id=" + teamId, {method: "HEAD", headers: headers}) - .then( resp => { + .then(resp => { if (resp.ok) { cacher.style.disply = "initial" } else { cacher.style.display = "none" } - }).catch( ex => { + }) + .catch(ex => { cacher.style.display = "none" }) } @@ -149,17 +150,17 @@ async function fetchAll(teamId) { requests = [] requests.push( fetch("current_manifest.json?id=" + teamId, {headers: headers}) - .then( resp => { + .then(resp => { if (resp.ok) { resp.json() - .then( contents => { + .then(contents => { console.log("Processing manifest") for (let resource of contents) { if (resource == "puzzles.json") { continue } fetch(resource) - .then( e => { + .then(e => { console.log("Fetched " + resource) }) } @@ -182,7 +183,7 @@ async function fetchAll(teamId) { for (let puzzle of puzzles) { let url = "puzzle.html?cat=" + cat_name + "&points=" + puzzle[0] + "&pid=" + puzzle[1] requests.push( fetch(url) - .then( e => { + .then(e => { console.log("Fetched " + url) })) }