Añadir 'app.js'

file-group-page
bat 3 years ago
parent ef74216a80
commit e3358e81ef

@ -0,0 +1,36 @@
class Setup {
async run() {
await this.register()
const p = document.createElement("p")
p.innerText = this.serviceWorkerStatus
document.body.appendChild(p)
}
async register() {
this.serviceWorkerStatus = "unavailable"
if ("serviceWorker" in navigator) {
try {
this.registration = navigator.serviceWorker.register(
"/sw.js",
{scope: "/"}
)
if (this.registration.installing) {
this.serviceWorkerStatus = "installing"
} else if (this.registration.waiting) {
this.serviceWorkerStatus = "waiting"
} else if (this.registration.active) {
this.serviceWorkerStatus = "active"
} else {
this.serviceWorkerStatus = "unknown"
}
} catch (err) {
console.error("error registering service worker", err)
this.serviceWorkerStatus = "error"
}
} else {
console.error("serviceWorker not available")
}
}
}
new Setup().run()
Loading…
Cancel
Save