You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
858 B
JavaScript
42 lines
858 B
JavaScript
import { Layout } from "./components/layout.js"
|
|
import { Project } from "./components/project.js"
|
|
|
|
customElements.define('m-layout', Layout)
|
|
customElements.define('m-project', Project)
|
|
|
|
class Setup {
|
|
async run() {
|
|
navigator.serviceWorker
|
|
.addEventListener('controllerchange', () => {
|
|
if (this.registration.active) {
|
|
window.location.reload(true)
|
|
}
|
|
})
|
|
await this.register()
|
|
this.load()
|
|
}
|
|
|
|
async register() {
|
|
try {
|
|
this.registration =
|
|
await navigator.serviceWorker.register(
|
|
'/sw.js',
|
|
{scope: '/'}
|
|
)
|
|
} catch (err) {
|
|
console.error(
|
|
'error registering service worker', err
|
|
)
|
|
}
|
|
}
|
|
|
|
load() {
|
|
if (this.registration.active) {
|
|
document.body.appendChild(
|
|
document.createElement('m-layout')
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
new Setup().run() |