Skip to content

Commit 935d4ba

Browse files
committed
Reset repository due to issues
- Signed-off commits were missing - Dumb pseudo was used in history - Change of email from Gmail to self-hosted mail has been fucked up Signed-off-by: Pierre-Yves Lapersonne <dev@pylapersonne.info>
1 parent e95c2f9 commit 935d4ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+73719
-0
lines changed

build/manifest.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"short_name": "Tips'n'tools",
3+
"name": "Tips'n'tools (v14.3.3) - for macOS",
4+
"description": "Your own cache of references and tools",
5+
"icons": [
6+
{
7+
"src": "webapp/pictures/logo-96.png",
8+
"sizes": "96x96",
9+
"type": "image/png"
10+
},
11+
{
12+
"src": "webapp/pictures/logo-144.png",
13+
"sizes": "144x144",
14+
"type": "image/png"
15+
},
16+
{
17+
"src": "webapp/pictures/logo-192.png",
18+
"sizes": "192x192",
19+
"type": "image/png"
20+
}
21+
],
22+
"serviceworker": {
23+
"src": "./serviceworker.js",
24+
"scope": "/",
25+
"update_via_cache": "none"
26+
},
27+
"start_url": "./webapp.html",
28+
"display": "standalone",
29+
"orientation": "portrait",
30+
"dir": "auto",
31+
"lang": "en"
32+
}

build/serviceworker.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
MIT License
3+
Copyright (c) 2016-2018 Pierre-Yves Lapersonne (Mail: dev@pylapersonne.info)
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.
19+
*/
20+
/*
21+
✿✿✿✿ ʕ •ᴥ•ʔ/ ︻デ═一
22+
*/
23+
24+
/**
25+
* @file serviceworker.js
26+
* @brief A service worker to use as a cache system in case of missing Internet / data / network connection
27+
* Please note that you must serve this web app through HTTPS or localhost so as to use Service Workers.
28+
* @author Pierre-Yves Lapersonne
29+
* @version 2.1.0
30+
* @since 22/03/2018
31+
*/
32+
33+
"use strict";
34+
35+
let CACHE_NAME = 'tipsntools-cache-v3';
36+
let urlsToCache = [
37+
38+
'./',
39+
40+
'./webapp/styles/devices.css',
41+
'./webapp/styles/filter.css',
42+
'./webapp/styles/global.css',
43+
'./webapp/styles/header.css',
44+
'./webapp/styles/medias.css',
45+
'./webapp/styles/navigationButtons.css',
46+
'./webapp/styles/references.css',
47+
'./webapp/styles/socs.css',
48+
'./webapp/styles/tables.css',
49+
'./webapp/styles/tools.css',
50+
51+
'./webapp/pictures/favicon.png',
52+
'./webapp/pictures/logo.svg',
53+
'./webapp/pictures/navigation-down.svg',
54+
'./webapp/pictures/navigation-up.svg',
55+
56+
'./webapp/logic/adapter.js',
57+
'./webapp/logic/config.js',
58+
'./webapp/logic/strings.js',
59+
'./webapp/logic/glue.js',
60+
'./webapp/logic/indexeddb.js',
61+
'./webapp/logic/scrollButtons.js',
62+
'./webapp/logic/smoothScroll.js',
63+
'./webapp/logic/webworker.js',
64+
'./webapp/logic/window.js'
65+
66+
];
67+
68+
/**
69+
* When the Service Worker in installing
70+
*/
71+
self.addEventListener('install', function(event) {
72+
event.waitUntil(
73+
caches.open(CACHE_NAME).then(function(cache) {
74+
console.log('Service Worker: opened cache');
75+
return cache.addAll(urlsToCache);
76+
})
77+
);
78+
});
79+
80+
/**
81+
* When the Service Worker is fetching resources
82+
*/
83+
self.addEventListener('fetch', function(event) {
84+
event.respondWith(
85+
caches.match(event.request).then(function(response) {
86+
console.log('Service Worker: fetch something - '+event.request);
87+
// Cache hit - return response
88+
if (response) {
89+
return response;
90+
}
91+
// Clone it to consume the request 2 times (by cache and by browser)
92+
let fetchRequest = event.request.clone();
93+
console.log('Service Worker: fetch something - '+fetchRequest);
94+
return fetch(fetchRequest).then(
95+
function(response) {
96+
// Check if we received a valid response
97+
if(!response || response.status !== 200 || response.type !== 'basic') {
98+
console.log('Service Worker: fetch response '+response);
99+
return response;
100+
}
101+
// Clone it to consume the reponse 2 times (by cache and by browser)
102+
var responseToCache = response.clone();
103+
caches.open(CACHE_NAME).then(function(cache) {
104+
console.log('Service Worker: response to cache - '+responseToCache);
105+
cache.put(event.request, responseToCache);
106+
});
107+
return response;
108+
} // End of function(response)
109+
); // End of return fetch(fetchRequest).then
110+
})
111+
); // End of event.respondWith
112+
});

0 commit comments

Comments
 (0)