Skip to content

Commit

Permalink
added botw 1.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcrobledo committed Apr 30, 2019
1 parent 7d6f398 commit ae8ac09
Show file tree
Hide file tree
Showing 28 changed files with 1,068 additions and 382 deletions.
100 changes: 77 additions & 23 deletions final-fantasy-explorers/_cache_service_worker.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,84 @@
/*
original: https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Cache Service Worker template by mrc 2019
mostly based in:
https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
https://github.com/chriscoyier/Simple-Offline-Site/blob/master/js/service-worker.js
https://gist.github.com/kosamari/7c5d1e8449b2fbc97d372675f16b566e
Note for GitHub Pages:
there can be an unexpected behaviour (cache not updating) when site is accessed from
https://user.github.io/repo/ (without index.html) in some browsers (Firefox)
use absolute paths if hosted in GitHub Pages in order to avoid it
also invoke sw with an absolute path:
navigator.serviceWorker.register('/repo/_cache_service_worker.js', {scope: '/repo/'})
*/


const PRECACHE = 'precache-editor-ffexplorers-v2';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'database.js',
'favicon.png',
'final-fantasy-explorers.js',
'icons.png',
'../savegame-editor.js',
'../savegame-editor.css'
/* MOD: fix old caches for mrc */
caches.keys().then(function(cacheNames){
for(var i=0; i<cacheNames.length; i++){
if(
cacheNames[i]==='runtime' ||
/^precache-\w+$/.test(cacheNames[i]) ||
/^precache-editor-([\w\+]+)-\w+$/.test(cacheNames[i]) ||
/^v?\d+\w?$/.test(cacheNames[i])
){
console.log('deleting old cache: '+cacheNames[i]);
caches.delete(cacheNames[i]);
}
}
});

var PRECACHE_ID='final-fantasy-explorers-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/final-fantasy-explorers/','/savegame-editors/final-fantasy-explorers/index.html',
'/savegame-editors/final-fantasy-explorers/database.js',
'/savegame-editors/final-fantasy-explorers/favicon.png',
'/savegame-editors/final-fantasy-explorers/final-fantasy-explorers.js',
'/savegame-editors/final-fantasy-explorers/icons.png',
'/savegame-editors/savegame-editor.js',
'/savegame-editors/savegame-editor.css'
];


self.addEventListener('install', event => {event.waitUntil(caches.open(PRECACHE).then(cache => cache.addAll(PRECACHE_URLS)).then(self.skipWaiting()));});self.addEventListener('activate', event => {const currentCaches = [PRECACHE, RUNTIME];event.waitUntil(caches.keys().then(cacheNames => {return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));}).then(cachesToDelete => {return Promise.all(cachesToDelete.map(cacheToDelete => {return caches.delete(cacheToDelete);}));}).then(() => self.clients.claim()));});self.addEventListener('fetch', event => {if (event.request.url.startsWith(self.location.origin)) {event.respondWith(caches.match(event.request).then(cachedResponse => {if (cachedResponse) {return cachedResponse;}return caches.open(RUNTIME).then(cache => {return fetch(event.request).then(response => {return cache.put(event.request, response.clone()).then(() => {return response;});});});}));}});

// install event (fired when sw is first installed): opens a new cache
self.addEventListener('install', evt => {
evt.waitUntil(
caches.open('precache-'+PRECACHE_ID+'-'+PRECACHE_VERSION)
.then(cache => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting())
);
});


// activate event (fired when sw is has been successfully installed): cleans up old outdated caches
self.addEventListener('activate', evt => {
evt.waitUntil(
caches.keys().then(cacheNames => {
return cacheNames.filter(cacheName => (cacheName.startsWith('precache-'+PRECACHE_ID+'-') && !cacheName.endsWith('-'+PRECACHE_VERSION)));
}).then(cachesToDelete => {
return Promise.all(cachesToDelete.map(cacheToDelete => {
console.log('delete '+cacheToDelete);
return caches.delete(cacheToDelete);
}));
}).then(() => self.clients.claim())
);
});


// fetch event (fired when requesting a resource): returns cached resource when possible
self.addEventListener('fetch', evt => {
if(evt.request.url.startsWith(self.location.origin)){ //skip cross-origin requests
evt.respondWith(
caches.match(evt.request).then(cachedResource => {
if (cachedResource) {
return cachedResource;
}else{
return fetch(evt.request);
}
})
);
}
});
4 changes: 2 additions & 2 deletions final-fantasy-explorers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
var FORCE_HTTPS=true;
window.addEventListener('load',function(){
if(location.protocol==='http:' && FORCE_HTTPS)
location.href=window.location.href.replace('http:','https:');
location.replace(window.location.href.replace('http:','https:'));
else if(location.protocol==='https:' && 'serviceWorker' in navigator)
navigator.serviceWorker.register('_cache_service_worker.js');
navigator.serviceWorker.register('/savegame-editors/final-fantasy-explorers/_cache_service_worker.js', {scope: '/savegame-editors/final-fantasy-explorers/'});
}, false);
--></script>
<style type="text/css"><!--
Expand Down
96 changes: 75 additions & 21 deletions hyrule-warriors/_cache_service_worker.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,82 @@
/*
original: https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Cache Service Worker template by mrc 2019
mostly based in:
https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
https://github.com/chriscoyier/Simple-Offline-Site/blob/master/js/service-worker.js
https://gist.github.com/kosamari/7c5d1e8449b2fbc97d372675f16b566e
Note for GitHub Pages:
there can be an unexpected behaviour (cache not updating) when site is accessed from
https://user.github.io/repo/ (without index.html) in some browsers (Firefox)
use absolute paths if hosted in GitHub Pages in order to avoid it
also invoke sw with an absolute path:
navigator.serviceWorker.register('/repo/_cache_service_worker.js', {scope: '/repo/'})
*/


const PRECACHE = 'precache-editor-hwarriors-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'hyrule-warriors.js',
'../savegame-editor.js',
'../savegame-editor.css'
/* MOD: fix old caches for mrc */
caches.keys().then(function(cacheNames){
for(var i=0; i<cacheNames.length; i++){
if(
cacheNames[i]==='runtime' ||
/^precache-\w+$/.test(cacheNames[i]) ||
/^precache-editor-([\w\+]+)-\w+$/.test(cacheNames[i]) ||
/^v?\d+\w?$/.test(cacheNames[i])
){
console.log('deleting old cache: '+cacheNames[i]);
caches.delete(cacheNames[i]);
}
}
});

var PRECACHE_ID='hyrule-warriors-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/hyrule-warriors/','/savegame-editors/hyrule-warriors/index.html',
'/savegame-editors/hyrule-warriors/favicon.png',
'/savegame-editors/hyrule-warriors/hyrule-warriors.js',
'/savegame-editors/savegame-editor.js',
'/savegame-editors/savegame-editor.css'
];


self.addEventListener('install', event => {event.waitUntil(caches.open(PRECACHE).then(cache => cache.addAll(PRECACHE_URLS)).then(self.skipWaiting()));});self.addEventListener('activate', event => {const currentCaches = [PRECACHE, RUNTIME];event.waitUntil(caches.keys().then(cacheNames => {return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));}).then(cachesToDelete => {return Promise.all(cachesToDelete.map(cacheToDelete => {return caches.delete(cacheToDelete);}));}).then(() => self.clients.claim()));});self.addEventListener('fetch', event => {if (event.request.url.startsWith(self.location.origin)) {event.respondWith(caches.match(event.request).then(cachedResponse => {if (cachedResponse) {return cachedResponse;}return caches.open(RUNTIME).then(cache => {return fetch(event.request).then(response => {return cache.put(event.request, response.clone()).then(() => {return response;});});});}));}});

// install event (fired when sw is first installed): opens a new cache
self.addEventListener('install', evt => {
evt.waitUntil(
caches.open('precache-'+PRECACHE_ID+'-'+PRECACHE_VERSION)
.then(cache => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting())
);
});


// activate event (fired when sw is has been successfully installed): cleans up old outdated caches
self.addEventListener('activate', evt => {
evt.waitUntil(
caches.keys().then(cacheNames => {
return cacheNames.filter(cacheName => (cacheName.startsWith('precache-'+PRECACHE_ID+'-') && !cacheName.endsWith('-'+PRECACHE_VERSION)));
}).then(cachesToDelete => {
return Promise.all(cachesToDelete.map(cacheToDelete => {
console.log('delete '+cacheToDelete);
return caches.delete(cacheToDelete);
}));
}).then(() => self.clients.claim())
);
});


// fetch event (fired when requesting a resource): returns cached resource when possible
self.addEventListener('fetch', evt => {
if(evt.request.url.startsWith(self.location.origin)){ //skip cross-origin requests
evt.respondWith(
caches.match(evt.request).then(cachedResource => {
if (cachedResource) {
return cachedResource;
}else{
return fetch(evt.request);
}
})
);
}
});
4 changes: 2 additions & 2 deletions hyrule-warriors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
var FORCE_HTTPS=true;
window.addEventListener('load',function(){
if(location.protocol==='http:' && FORCE_HTTPS)
location.href=window.location.href.replace('http:','https:');
location.replace(window.location.href.replace('http:','https:'));
else if(location.protocol==='https:' && 'serviceWorker' in navigator)
navigator.serviceWorker.register('_cache_service_worker.js');
navigator.serviceWorker.register('/savegame-editors/hyrule-warriors/_cache_service_worker.js', {scope: '/savegame-editors/hyrule-warriors/'});
}, false);
--></script>
</head>
Expand Down
97 changes: 75 additions & 22 deletions kid-icarus-uprising/_cache_service_worker.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,82 @@
/*
original: https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Cache Service Worker template by mrc 2019
mostly based in:
https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
https://github.com/chriscoyier/Simple-Offline-Site/blob/master/js/service-worker.js
https://gist.github.com/kosamari/7c5d1e8449b2fbc97d372675f16b566e
Note for GitHub Pages:
there can be an unexpected behaviour (cache not updating) when site is accessed from
https://user.github.io/repo/ (without index.html) in some browsers (Firefox)
use absolute paths if hosted in GitHub Pages in order to avoid it
also invoke sw with an absolute path:
navigator.serviceWorker.register('/repo/_cache_service_worker.js', {scope: '/repo/'})
*/


const PRECACHE = 'precache-editor-kiuprising-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'kid-icarus-uprising.js',
'icons.png',
'../savegame-editor.js',
'../savegame-editor.css'
/* MOD: fix old caches for mrc */
caches.keys().then(function(cacheNames){
for(var i=0; i<cacheNames.length; i++){
if(
cacheNames[i]==='runtime' ||
/^precache-\w+$/.test(cacheNames[i]) ||
/^precache-editor-([\w\+]+)-\w+$/.test(cacheNames[i]) ||
/^v?\d+\w?$/.test(cacheNames[i])
){
console.log('deleting old cache: '+cacheNames[i]);
caches.delete(cacheNames[i]);
}
}
});

var PRECACHE_ID='kid-icarus-uprising-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/kid-icarus-uprising/','/savegame-editors/kid-icarus-uprising/index.html',
'/savegame-editors/kid-icarus-uprising/favicon.png',
'/savegame-editors/kid-icarus-uprising/kid-icarus-uprising.js',
'/savegame-editors/savegame-editor.js',
'/savegame-editors/savegame-editor.css'
];


self.addEventListener('install', event => {event.waitUntil(caches.open(PRECACHE).then(cache => cache.addAll(PRECACHE_URLS)).then(self.skipWaiting()));});self.addEventListener('activate', event => {const currentCaches = [PRECACHE, RUNTIME];event.waitUntil(caches.keys().then(cacheNames => {return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));}).then(cachesToDelete => {return Promise.all(cachesToDelete.map(cacheToDelete => {return caches.delete(cacheToDelete);}));}).then(() => self.clients.claim()));});self.addEventListener('fetch', event => {if (event.request.url.startsWith(self.location.origin)) {event.respondWith(caches.match(event.request).then(cachedResponse => {if (cachedResponse) {return cachedResponse;}return caches.open(RUNTIME).then(cache => {return fetch(event.request).then(response => {return cache.put(event.request, response.clone()).then(() => {return response;});});});}));}});

// install event (fired when sw is first installed): opens a new cache
self.addEventListener('install', evt => {
evt.waitUntil(
caches.open('precache-'+PRECACHE_ID+'-'+PRECACHE_VERSION)
.then(cache => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting())
);
});


// activate event (fired when sw is has been successfully installed): cleans up old outdated caches
self.addEventListener('activate', evt => {
evt.waitUntil(
caches.keys().then(cacheNames => {
return cacheNames.filter(cacheName => (cacheName.startsWith('precache-'+PRECACHE_ID+'-') && !cacheName.endsWith('-'+PRECACHE_VERSION)));
}).then(cachesToDelete => {
return Promise.all(cachesToDelete.map(cacheToDelete => {
console.log('delete '+cacheToDelete);
return caches.delete(cacheToDelete);
}));
}).then(() => self.clients.claim())
);
});


// fetch event (fired when requesting a resource): returns cached resource when possible
self.addEventListener('fetch', evt => {
if(evt.request.url.startsWith(self.location.origin)){ //skip cross-origin requests
evt.respondWith(
caches.match(evt.request).then(cachedResource => {
if (cachedResource) {
return cachedResource;
}else{
return fetch(evt.request);
}
})
);
}
});
4 changes: 2 additions & 2 deletions kid-icarus-uprising/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
var FORCE_HTTPS=true;
window.addEventListener('load',function(){
if(location.protocol==='http:' && FORCE_HTTPS)
location.href=window.location.href.replace('http:','https:');
location.replace(window.location.href.replace('http:','https:'));
else if(location.protocol==='https:' && 'serviceWorker' in navigator)
navigator.serviceWorker.register('_cache_service_worker.js');
navigator.serviceWorker.register('/savegame-editors/kid-icarus-uprising/_cache_service_worker.js', {scope: '/savegame-editors/kid-icarus-uprising/'});
}, false);
--></script>
</head>
Expand Down
Loading

0 comments on commit ae8ac09

Please sign in to comment.