Skip to content

Commit

Permalink
pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
kaheetonaa committed Oct 18, 2024
1 parent f6c007a commit 5cc66b1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
Binary file added icon/icon-ori.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="pwa-capable" content="yes">
<link rel="manifest" href="manifest.webmanifest">
<title>iD</title>
Expand Down Expand Up @@ -175,6 +174,11 @@ <h2>Open sandbox editting in JOSM</h2>
<div id='id-container'></div>

<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('sw.js')
.then(() => { console.log('Service Worker Registered'); });
}
var container = document.getElementById('id-container');
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
Expand Down
41 changes: 12 additions & 29 deletions manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
{
"name": "EuthMappers iDSandbox4All",
"short_name": "iDSandbox4All",
"scope": "./",
"start_url": "index.html",
"background_color": "purple",
"description": "idEditor for Sandbox4All",
"display": "fullscreen",
"icons": [
{
"src": "public/apple-touch-icon.png",
"sizes": "180x180",
"type": "image/png"
},
{
"src": "public/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "public/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "public/maskable_icon_x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
}
{
"src": "icon/icon.png",
"sizes": "192x192",
"type": "image/png"
}
],
"theme_color": "#62cbec",
"background_color": "#62cbec",
"display": "standalone"
}
"name": "Sandbox4All",
"short_name": "Sandbox4All",
"start_url": "index.html"
}
17 changes: 17 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open('iDSandbox4All').then((cache) => cache.addAll([
'index.html',
'icon/icon.png',
'dist/iD.js',
'dist/iD.css',
])),
);
});

self.addEventListener('fetch', (e) => {
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request)),
);
});

0 comments on commit 5cc66b1

Please sign in to comment.