Skip to content

Commit 3bc4627

Browse files
committed
Add PWA
1 parent 3c9912c commit 3bc4627

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

fodte.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,10 @@ document.addEventListener('DOMContentLoaded', function () {
164164
document.body.addEventListener('dragleave', function (e) {
165165
document.body.classList.remove('hover');
166166
});
167+
});
168+
169+
window.addEventListener('load', function() {
170+
if(location.protocol !== 'file:') {
171+
navigator.serviceWorker.register('sw.js');
172+
}
167173
});

manifest.webmanifest

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Fodte",
3+
"short_name": "Fodte",
4+
"description": "Fodte (Form Odt Exporter) est un outil permettant d'extraire le contenu des champs de formulaires de documents Libreoffice Writer et d'en générer un fichier tableur (csv).",
5+
"start_url": "index.html",
6+
"display": "standalone",
7+
"icons": [
8+
{
9+
"src": "icon.svg",
10+
"sizes": "144x144"
11+
}
12+
]
13+
}

sw.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
self.addEventListener('install', (event) => {
2+
event.waitUntil(
3+
caches.open('Fodte').then((cache) => {
4+
return cache.addAll([
5+
'./',
6+
'./index.html',
7+
'./style.css',
8+
'./fodte.js',
9+
'./Forms_Element.class.js',
10+
'./lib/jszip.min.js',
11+
'./lib/csv.min.js',
12+
'./icon.svg',
13+
]);
14+
})
15+
);
16+
});
17+
18+
self.addEventListener('fetch', function(event) {
19+
event.respondWith(
20+
fetch(event.request).catch(function() {
21+
return caches.match(event.request);
22+
})
23+
);
24+
});

0 commit comments

Comments
 (0)