Apply suggestions from code review

Co-Authored-By: Neale Pickett <neale@woozle.org>
This commit is contained in:
int00h5525 2019-11-07 13:25:48 -06:00 committed by GitHub
parent 3e079616c1
commit 1ea739207b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,8 @@
function pwa_init() { function pwa_init() {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.register("./sw.js").then(function(reg) { navigator.serviceWorker.register("./sw.js").then(function(reg) {
}).catch(function(err) { })
.catch(err => {
console.warn("Error while registering service worker", err) console.warn("Error while registering service worker", err)
}) })
} else { } else {

View File

@ -127,13 +127,14 @@ function drawCacheButton(teamId) {
headers.append("pragma", "no-cache") headers.append("pragma", "no-cache")
headers.append("cache-control", "no-cache") headers.append("cache-control", "no-cache")
fetch("current_manifest.json?id=" + teamId, {method: "HEAD", headers: headers}) fetch("current_manifest.json?id=" + teamId, {method: "HEAD", headers: headers})
.then( resp => { .then(resp => {
if (resp.ok) { if (resp.ok) {
cacher.style.disply = "initial" cacher.style.disply = "initial"
} else { } else {
cacher.style.display = "none" cacher.style.display = "none"
} }
}).catch( ex => { })
.catch(ex => {
cacher.style.display = "none" cacher.style.display = "none"
}) })
} }
@ -149,17 +150,17 @@ async function fetchAll(teamId) {
requests = [] requests = []
requests.push( fetch("current_manifest.json?id=" + teamId, {headers: headers}) requests.push( fetch("current_manifest.json?id=" + teamId, {headers: headers})
.then( resp => { .then(resp => {
if (resp.ok) { if (resp.ok) {
resp.json() resp.json()
.then( contents => { .then(contents => {
console.log("Processing manifest") console.log("Processing manifest")
for (let resource of contents) { for (let resource of contents) {
if (resource == "puzzles.json") { if (resource == "puzzles.json") {
continue continue
} }
fetch(resource) fetch(resource)
.then( e => { .then(e => {
console.log("Fetched " + resource) console.log("Fetched " + resource)
}) })
} }
@ -182,7 +183,7 @@ async function fetchAll(teamId) {
for (let puzzle of puzzles) { for (let puzzle of puzzles) {
let url = "puzzle.html?cat=" + cat_name + "&points=" + puzzle[0] + "&pid=" + puzzle[1] let url = "puzzle.html?cat=" + cat_name + "&points=" + puzzle[0] + "&pid=" + puzzle[1]
requests.push( fetch(url) requests.push( fetch(url)
.then( e => { .then(e => {
console.log("Fetched " + url) console.log("Fetched " + url)
})) }))
} }