Skip to content

Commit

Permalink
Merge pull request #7 from niivue/feature/pwd
Browse files Browse the repository at this point in the history
add basic pwa support
  • Loading branch information
neurolabusc authored Jan 8, 2025
2 parents e2ca1ce + fbb42d0 commit 5fdde7f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./niivue.css" />
<link rel="manifest" href="./manifest.json" />
<title>brain2print</title>
</head>

Expand Down
24 changes: 24 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ const pipelinesBaseUrl = new URL(`${viteBaseUrl}pipelines`, document.location.or
setCuberillePipelinesUrl(pipelinesBaseUrl)
setMeshFiltersPipelinesUrl(pipelinesBaseUrl)

self.addEventListener("install", (event) => {
event.waitUntil(
caches.open("app-static-v1").then((cache) => {
return cache.addAll([
"./",
"./index.html",
"./manifest.json",
"./models",
"./pipelines",
"./assets",
"./t1_crop.nii.gz",
"./niivue.css"]);
})
);
});

self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});

async function main() {
const niimath = new Niimath()
await niimath.init()
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "brain2print",
"short_name": "brain2print",
"start_url": "./index.html",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#333333",
"icons": [
{
"src": "icon.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icon.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

0 comments on commit 5fdde7f

Please sign in to comment.