-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bithalo
committed
Sep 6, 2024
1 parent
31d0358
commit 09d0df0
Showing
8 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"author": "BitBay", | ||
"name": "BitBay Decentralized Markets", | ||
"short_name": "BitBay", | ||
"description": "Decentralized Markets", | ||
"orientation": "portrait", | ||
"start_url": "/Ethalo/", | ||
"scope": "/Ethalo/", | ||
"display": "fullscreen", | ||
"background_color": "#808080", | ||
"theme_color": "#000000", | ||
"icons": [ | ||
{ | ||
"src": "/Ethalo/bitbay.png", | ||
"sizes": "48x48 72x72 96x96 128x128 192x192 256x256 512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"manifest_version": 1, | ||
"version": "0.1", | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]" | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
Cache Strategy: cacheAll (boolean flag) | ||
1) cacheAll = true => Cache all requests in urlsToCache list and all further requests | ||
2) cacheAll = false => Cache only all requests in urlsToCache list | ||
*/ | ||
var cacheAll = true; | ||
var CACHE_NAME = 'webapk-cache'; | ||
var urlsToCache = [ | ||
'./index.html', | ||
'./all.min.css', | ||
'./axios.min.js', | ||
'./bignumber.min.js', | ||
'./cryptico.min.js', | ||
'./crypto-js.js', | ||
'./crypto-sha256.js', | ||
'./DDEABI.js', | ||
'./ERC20.js', | ||
'./faq.js', | ||
'./jdenticon.min.js', | ||
'./lottie-player.js', | ||
'./open-sans.css', | ||
'./purify.js', | ||
'./simple-scrollbar.css', | ||
'./simple-scrollbar.min.js', | ||
'./sweetalert211.js', | ||
'./translate.js', | ||
'./web3.min.js' | ||
]; | ||
|
||
var urlsNotToCache = [ | ||
// Urls that don't need to be cached can be added here explicitly | ||
]; | ||
|
||
// Install Event | ||
self.addEventListener('install', function(event) { | ||
console.log("[SW] install event: ",event); | ||
// Perform install steps | ||
event.waitUntil( | ||
caches.open(CACHE_NAME).then( | ||
function(cache) { | ||
console.log('[SW] Opened cache: ',cache); | ||
return cache.addAll(urlsToCache); | ||
} | ||
) | ||
); | ||
}); | ||
|
||
|
||
// Fetch Event | ||
self.addEventListener('fetch', function(event) { | ||
console.log("[SW] fetch event: ",event); | ||
event.respondWith( | ||
caches.match(event.request).then( | ||
function(response) { | ||
// Cache hit - return response | ||
if (response) return response; | ||
// What cache strategy should be used? => cacheAll (boolean flag) | ||
else if (!cacheAll || urlsNotToCache.indexOf(event.request) !== -1) return fetch(event.request); | ||
else { | ||
fetch(event.request).then( | ||
// Try to cache new requests directly | ||
function(response) { | ||
// Check if we received a valid response | ||
if(!response || response.status !== 200 || response.type !== 'basic') return response; | ||
// IMPORTANT: Clone the response. A response is a stream | ||
// and because we want the browser to consume the response | ||
// as well as the cache consuming the response, we need | ||
// to clone it so we have two streams. | ||
var responseToCache = response.clone(); | ||
caches.open(CACHE_NAME).then( | ||
function(cache) { | ||
cache.put(event.request, responseToCache); | ||
} | ||
); | ||
return response; | ||
} | ||
); | ||
} | ||
} | ||
) | ||
); | ||
}); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.