added botw 1.6 support

This commit is contained in:
marcrobledo
2019-04-30 19:40:57 +02:00
parent 7d6f3984d0
commit ae8ac09243
28 changed files with 1068 additions and 382 deletions

View File

@@ -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);
}
})
);
}
});

View File

@@ -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"><!--

View File

@@ -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);
}
})
);
}
});

View File

@@ -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>

View File

@@ -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);
}
})
);
}
});

View File

@@ -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>

View File

@@ -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-kirbyblow-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'kirbys-blowout-blast.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='kirbys-blowout-blast-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/kirbys-blowout-blast/','/savegame-editors/kirbys-blowout-blast/index.html',
'/savegame-editors/kirbys-blowout-blast/favicon.png',
'/savegame-editors/kirbys-blowout-blast/kirbys-blowout-blast.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);
}
})
);
}
});

View File

@@ -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/kirbys-blowout-blast/_cache_service_worker.js', {scope: '/savegame-editors/kirbys-blowout-blast/'});
}, false);
--></script>
</head>

View File

@@ -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-mk7-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'mario-kart-7.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='mario-kart-7-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/mario-kart-7/','/savegame-editors/mario-kart-7/index.html',
'/savegame-editors/mario-kart-7/favicon.png',
'/savegame-editors/mario-kart-7/mario-kart-7.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);
}
})
);
}
});

View File

@@ -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/mario-kart-7/_cache_service_worker.js', {scope: '/savegame-editors/mario-kart-7/'});
}, false);
--></script>
</head>

View File

@@ -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-picross3d2-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'picross-3d-round-2.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='picross-3d-round-2-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/picross-3d-round-2/','/savegame-editors/picross-3d-round-2/index.html',
'/savegame-editors/picross-3d-round-2/favicon.png',
'/savegame-editors/picross-3d-round-2/picross-3d-round-2.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);
}
})
);
}
});

View File

@@ -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/picross-3d-round-2/_cache_service_worker.js', {scope: '/savegame-editors/picross-3d-round-2/'});
}, false);
--></script>
</head>

View File

@@ -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-pokemonpicross-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'pokemon-picross.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='pokemon-picross-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/pokemon-picross/','/savegame-editors/pokemon-picross/index.html',
'/savegame-editors/pokemon-picross/favicon.png',
'/savegame-editors/pokemon-picross/pokemon-picross.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);
}
})
);
}
});

View File

@@ -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/pokemon-picross/_cache_service_worker.js', {scope: '/savegame-editors/pokemon-picross/'});
}, false);
--></script>
</head>

View File

@@ -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-pokemonshuffle-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'pokemon-shuffle.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='pokemon-shuffle-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/pokemon-shuffle/','/savegame-editors/pokemon-shuffle/index.html',
'/savegame-editors/pokemon-shuffle/favicon.png',
'/savegame-editors/pokemon-shuffle/pokemon-shuffle.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);
}
})
);
}
});

View File

@@ -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/pokemon-shuffle/_cache_service_worker.js', {scope: '/savegame-editors/pokemon-shuffle/'});
}, false);
--></script>
</head>

View File

@@ -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-rhythmheavenmix-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'rhythm-paradise-megamix.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='rhythm-paradise-megamix-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/rhythm-paradise-megamix/','/savegame-editors/rhythm-paradise-megamix/index.html',
'/savegame-editors/rhythm-paradise-megamix/favicon.png',
'/savegame-editors/rhythm-paradise-megamix/rhythm-paradise-megamix.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);
}
})
);
}
});

View File

@@ -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/rhythm-paradise-megamix/_cache_service_worker.js', {scope: '/savegame-editors/rhythm-paradise-megamix/'});
}, false);
--></script>
</head>

View File

@@ -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-streetpassplaza-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'streetpass-mii-plaza.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='streetpass-mii-plaza-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/streetpass-mii-plaza/','/savegame-editors/streetpass-mii-plaza/index.html',
'/savegame-editors/streetpass-mii-plaza/favicon.png',
'/savegame-editors/streetpass-mii-plaza/streetpass-mii-plaza.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);
}
})
);
}
});

View File

@@ -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/streetpass-mii-plaza/_cache_service_worker.js', {scope: '/savegame-editors/streetpass-mii-plaza/'});
}, false);
--></script>
</head>

View File

@@ -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-teamkirbyclashdx-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'favicon.png',
'team-kirby-clash-dx.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='team-kirby-clash-dx-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/team-kirby-clash-dx/','/savegame-editors/team-kirby-clash-dx/index.html',
'/savegame-editors/team-kirby-clash-dx/favicon.png',
'/savegame-editors/team-kirby-clash-dx/team-kirby-clash-dx.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);
}
})
);
}
});

View File

@@ -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/team-kirby-clash-dx/_cache_service_worker.js', {scope: '/savegame-editors/team-kirby-clash-dx/'});
}, false);
--></script>
</head>

View File

@@ -1,29 +1,83 @@
/*
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-zeldabotwmaster-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'zelda-botw-master.css',
'zelda-botw-master.js',
'hashes.js',
'favicon.png',
'../savegame-editor.js'
/* 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='zelda-botw-master-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/zelda-botw-master/','/savegame-editors/zelda-botw-master/index.html',
'/savegame-editors/zelda-botw-master/zelda-botw-master.css',
'/savegame-editors/zelda-botw-master/zelda-botw-master.js',
'/savegame-editors/zelda-botw-master/hashes.js',
'/savegame-editors/zelda-botw-master/favicon.png',
'/savegame-editors/savegame-editor.js'
];
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);
}
})
);
}
});

View File

@@ -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/zelda-botw-master/_cache_service_worker.js', {scope: '/savegame-editors/zelda-botw-master/'});
}, false);
--></script>
</head>

View File

@@ -1,5 +1,5 @@
/*
The legend of Zelda: Breath of the wild - Master editor v20190416
The legend of Zelda: Breath of the wild - Master editor v20190430
by Marc Robledo 2017-2019
*/
var currentEditingItem=0;
@@ -7,7 +7,7 @@ var currentEditingItem=0;
SavegameEditor={
Name:'The legend of Zelda: Breath of the wild (Master editor)',
Filename:'game_data.sav',
Version:20190416,
Version:20190430,
/* Constants */
@@ -15,10 +15,10 @@ SavegameEditor={
STRING_SIZE:0x20,
STRING64_SIZE:0x80,
/* v1.0 v1.1 v1.2 v1.3 kiosk v1.3.3 v1.4/v1.5 */
FILESIZE: [896976, 897160, 897112, 907824, 916576, 1020648, 1027208],
HEADER: [0x24e2, 0x24ee, 0x2588, 0x29c0, 0x2f8e, 0x3ef8, 0x471a],
VERSION: ['v1.0', 'v1.1', 'v1.2', 'v1.3', 'Kiosk', 'v1.3.3','v1.4/v1.5'],
//missing versions: 1.1.1, 1.1.2 and 1.4.1
VERSION: ['v1.0', 'v1.1', 'v1.2', 'v1.3', 'v1.3.1', 'Kiosk', 'v1.3.3','v1.3.4', 'v1.4', 'v1.5', 'v1.6'],
FILESIZE: [896976, 897160, 897112, 907824, 907824, 916576, 1020648, 1020648, 1027208, 1027208, 1027216],
HEADER: [0x24e2, 0x24ee, 0x2588, 0x29c0, 0x2a46, 0x2f8e, 0x3ef8, 0x3ef9, 0x471a, 0x471b, 0x471e]
},
HashFilters:[

View File

@@ -1,35 +1,89 @@
/*
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-zeldabotw-v1';
const RUNTIME = 'runtime';
const PRECACHE_URLS = [
'index.html','./',
'zelda-botw.css',
'zelda-botw.js',
'zelda-botw.data.js',
'zelda-botw.icons.js',
'zelda-botw.locations.js',
'favicon.png',
'assets/_blank.png',
'assets/logo.png',
'assets/bg_black.jpg',
'assets/bg_white.jpg',
'../savegame-editor.js'
/* 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='zelda-botw-editor';
var PRECACHE_VERSION='v1';
var PRECACHE_URLS=[
'/savegame-editors/zelda-botw/','/savegame-editors/zelda-botw/index.html',
'/savegame-editors/zelda-botw/zelda-botw.css',
'/savegame-editors/zelda-botw/zelda-botw.js',
'/savegame-editors/zelda-botw/zelda-botw.data.js',
'/savegame-editors/zelda-botw/zelda-botw.icons.js',
'/savegame-editors/zelda-botw/zelda-botw.locations.js',
'/savegame-editors/zelda-botw/favicon.png',
'/savegame-editors/zelda-botw/assets/_blank.png',
'/savegame-editors/zelda-botw/assets/logo.png',
'/savegame-editors/zelda-botw/assets/bg_black.jpg',
'/savegame-editors/zelda-botw/assets/bg_white.jpg',
'/savegame-editors/savegame-editor.js'
];
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);
}
})
);
}
});

View File

@@ -19,9 +19,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/zelda-botw/_cache_service_worker.js', {scope: '/savegame-editors/zelda-botw/'});
}, false);
--></script>
</head>

View File

@@ -1,5 +1,5 @@
/*
The legend of Zelda: Breath of the wild v20190415
The legend of Zelda: Breath of the wild v20190430
by Marc Robledo 2017-2019
*/
var currentEditingItem=0;
@@ -7,65 +7,57 @@ var currentEditingItem=0;
SavegameEditor={
Name:'The legend of Zelda: Breath of the wild',
Filename:'game_data.sav',
Version:20190128,
Version:20190430,
/* Constants */
Constants:{
MAX_ITEMS:410,
STRING_SIZE:0x80,
/* v1.0 v1.1 v1.2 v1.3 kiosk v1.3.3 v1.4/v1.5 */
FILESIZE: [896976, 897160, 897112, 907824, 916576, 1020648, 1027208],
HEADER: [0x24e2, 0x24ee, 0x2588, 0x29c0, 0x2f8e, 0x3ef8, 0x471a],
VERSION: ['v1.0', 'v1.1', 'v1.2', 'v1.3', 'Kiosk', 'v1.3.3','v1.4/v1.5'],
//missing versions: 1.1.1, 1.1.2 and 1.4.1
VERSION: ['v1.0', 'v1.1', 'v1.2', 'v1.3', 'v1.3.1', 'Kiosk', 'v1.3.3','v1.3.4', 'v1.4', 'v1.5', 'v1.6'],
FILESIZE: [896976, 897160, 897112, 907824, 907824, 916576, 1020648, 1020648, 1027208, 1027208, 1027216],
HEADER: [0x24e2, 0x24ee, 0x2588, 0x29c0, 0x2a46, 0x2f8e, 0x3ef8, 0x3ef9, 0x471a, 0x471b, 0x471e],
MAP_ICONS: 0x9383490e,
MAP_POS: 0xea9def3f,
ICON_TYPES:{SWORD: 27, BOW:28, SHIELD:29, POT:30, STAR:31, CHEST:32,SKULL:33,LEAF:34,TOWER:35}
},
/* Offsets */
OffsetsAll:{
/* hash v1.0 v1.1 v1.2 v1.3 kiosk v1.3.3 v1.4/v1.5 */
RUPEES: [0x23149bf8, 0x00e0a0, 0x00e110, 0x00e110, 0x00e678, 0x00f5a8, 0x00e730, 0x00eaf8],
MONS: [0xce7afed3, 0x0bc480, 0x0bc558, 0x0bc538, 0x0be728, 0x0c0498, 0x0d6ac8, 0x0d7fa8],
MAX_HEARTS: [0x2906f327, 0x00fd28, 0x00fdb8, 0x00fdb8, 0x010438, 0x011420, 0x010508, 0x010970],
MAX_STAMINA: [0x3adff047, 0x043208, 0x0432c0, 0x0432c0, 0x043c98, 0x044da8, 0x04fdb0, 0x0503c8],
ITEMS: [0x5f283289, 0x052828, 0x0528d8, 0x0528c0, 0x053890, 0x054c78, 0x05fa48, 0x060408],
ITEMS_QUANTITY: [0x6a09fc59, 0x063340, 0x0633f0, 0x0633d8, 0x064550, 0x0659d0, 0x070730, 0x0711c8],
FLAGS_WEAPON: [0x57ee221d, 0x050328, 0x0503d8, 0x0503c0, 0x051270, 0x0525f0, 0x05d420, 0x05dd20],
FLAGSV_WEAPON: [0xa6d926bc, 0x0a9ca8, 0x0a9d78, 0x0a9d58, 0x0ab8d0, 0x0ad2e8, 0x0c3bd8, 0x0c4c68],
FLAGS_BOW: [0x0cbf052a, 0x0045f0, 0x0045f8, 0x0045f8, 0x0047e8, 0x004950, 0x004828, 0x004990],
FLAGSV_BOW: [0x1e3fd294, 0x00a8e0, 0x00a940, 0x00a940, 0x00ae08, 0x00bcd0, 0x00ae90, 0x00b1e0],
FLAGS_SHIELD: [0xc5238d2b, 0x0b5810, 0x0b58e8, 0x0b58c8, 0x0b7910, 0x0b95b0, 0x0cfc70, 0x0d1038],
FLAGSV_SHIELD: [0x69f17e8a, 0x063218, 0x0632c8, 0x0632b0, 0x064420, 0x0658a0, 0x070600, 0x071098],
HORSE_SADDLES: [0x333aa6e5, 0x03d0e8, 0x03d190, 0x03d190, 0x03d9d8, 0x03ea60, 0x049ab8, 0x04a008],
HORSE_REINS: [0x6150c6be, 0x060508, 0x0605b8, 0x0605a0, 0x0615d0, 0x0629d8, 0x06d7a0, 0x06e190],
HORSE_NAMES: [0x7b74e117, 0x070320, 0x0703c0, 0x0703a8, 0x071820, 0x072e10, 0x07da30, 0x07e640],
HORSE_MANES: [0x9c6cfd3f, 0x0a6478, 0x0a6538, 0x0a6520, 0x0a7f18, 0x0a9828, 0x0c01c0, 0x0c1168],
HORSE_TYPES: [0xc247b696, 0x0b46f8, 0x0b47d8, 0x0b47b8, 0x0b6780, 0x0b83f0, 0x0cead8, 0x0cfe40],
HORSE_BONDS: [0xe1a0ca54, 0x0c3670, 0x0c3738, 0x0c3710, 0x0c5bb0, 0x0c7a70, 0x0de2a0, 0x0df960], /* max=0x3f80 */
HORSE_POSITION: [0x982ba201, 0x07aed0, 0x07af90, 0x07af78, 0x07c8f8, 0x07e178, 0x088b78, 0x089a80],
KOROK_SEED_COUNTER: [0x8a94e07a, 0x076148, 0x0761f8, 0x0761e0, 0x0778f8, 0x079040, 0x083b60, 0x084908],
DEFEATED_HINOX_COUNTER: [0x54679940, 0x04d2b8, 0x04d368, 0x04d358, 0x04e158, 0x04f488, 0x05a2f0, 0x05ab78],
DEFEATED_TALUS_COUNTER: [0x698266be, 0x063010, 0x0630c0, 0x0630a8, 0x064218, 0x065690, 0x0703f0, 0x070e88],
DEFEATED_MOLDUGA_COUNTER:[0x441b7231, 0x0466d0, 0x046788, 0x046780, 0x0472a8, 0x048480, 0x0533e8, 0x053b00],
PLAYTIME: [0x73c29681, 0x067888, 0x067920, 0x067908, 0x068c40, 0x06a170, 0x074e40, 0x075998],
RELIC_GERUDO: [0x97f925c3, 0x07adc0, 0x07ae80, 0x07ae68, 0x07c7e0, 0x07e060, 0x088a60, 0x089968],
RELIC_GORON: [0xf1cf4807, 0x0cb3c0, 0x0cb488, 0x0cb460, 0x0cdbf8, 0x0cfbf0, 0x0e6340, 0x0e7ba0],
RELIC_RITO: [0xfda0cde4, 0x0da0d8, 0x0da190, 0x0da160, 0x0dcac0, 0x0decc8, 0x0f8370, 0x0f9cc8],
MOTORCYCLE: [0xc9328299, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x0d2660], /* IsGet_Obj_Motorcycle */
PLAYER_POSITION: [0xa40ba103, 0x0a8cd8, 0x0a8da8, 0x0a8d90, 0x0aa8a8, 0x0ac278, 0x0c2b98, 0x0c3bf0],
MAP: [0x0bee9e46, 0x004128, 0x004130, 0x004130, 0x004310, 0x004448, 0x004348, 0x0044a0],
MAPTYPE: [0xd913b769, 0x0c0588, 0x0c0658, 0x0c0630, 0x0c29b0, 0x0c47e8, 0x0db080, 0x0dc658]
},
/* Hashes */
Hashes:[
0x0bee9e46, 'MAP',
0x0cbf052a, 'FLAGS_BOW',
0x1e3fd294, 'FLAGSV_BOW',
0x23149bf8, 'RUPEES',
0x2906f327, 'MAX_HEARTS',
0x333aa6e5, 'HORSE_SADDLES',
0x3adff047, 'MAX_STAMINA',
0x441b7231, 'DEFEATED_MOLDUGA_COUNTER',
0x54679940, 'DEFEATED_HINOX_COUNTER',
0x57ee221d, 'FLAGS_WEAPON',
0x5f283289, 'ITEMS',
0x6150c6be, 'HORSE_REINS',
0x698266be, 'DEFEATED_TALUS_COUNTER',
0x69f17e8a, 'FLAGSV_SHIELD',
0x6a09fc59, 'ITEMS_QUANTITY',
0x73c29681, 'PLAYTIME',
0x7b74e117, 'HORSE_NAMES',
0x8a94e07a, 'KOROK_SEED_COUNTER',
0x97f925c3, 'RELIC_GERUDO',
0x982ba201, 'HORSE_POSITION',
0x9c6cfd3f, 'HORSE_MANES',
0xa40ba103, 'PLAYER_POSITION',
0xa6d926bc, 'FLAGSV_WEAPON',
0xc247b696, 'HORSE_TYPES',
0xc5238d2b, 'FLAGS_SHIELD',
0xc9328299, 'MOTORCYCLE', /* IsGet_Obj_Motorcycle */
0xce7afed3, 'MONS',
0xd913b769, 'MAPTYPE',
0xe1a0ca54, 'HORSE_BONDS', /* max=0x3f80 */
0xf1cf4807, 'RELIC_GORON',
0xfda0cde4, 'RELIC_RITO'
],
/* private functions */
@@ -113,20 +105,18 @@ SavegameEditor={
_getOffsets:function(v){
this.Offsets={};
if(v<this.OffsetsAll.RUPEES.length-1){
for(prop in this.OffsetsAll){
this.Offsets[prop]=this.OffsetsAll[prop][v+1];
}
}else{ /* unknown version */
var textarea=document.createElement('textarea');
for(prop in this.OffsetsAll){
var offset=this._searchHash(this.OffsetsAll[prop][0]);
if(offset){
textarea.value+=prop+':0x'+(offset+4).toString(16)+',\n';
this.Offsets[prop]=offset+4;
var startSearchOffset=0x0c;
for(var i=0; i<this.Hashes.length; i+=2){
for(var j=startSearchOffset; j<tempFile.fileSize; j+=8){
if(this.Hashes[i]===tempFile.readU32(j)){
this.Offsets[this.Hashes[i+1]]=j+4;
startSearchOffset=j+8;
break;
}
}
document.body.appendChild(textarea);
/*if(typeof this.Offsets[this.Hashes[i+1]] === 'undefined'){
console.log(this.Hashes[i+1]+' not found');
}*/
}
},
@@ -259,6 +249,7 @@ SavegameEditor={
document.getElementById('item-name'+i).innerHTML='';
document.getElementById('item-name'+i).parentElement.appendChild(this.selectItem);
this.selectItem.focus();
this.selectItem.click();
},
editItem2:function(i,nameId){
var oldCat=this._getItemCategory(this._loadItemName(i));
@@ -361,12 +352,6 @@ SavegameEditor={
tempFile.littleEndian=switchMode;
for(var i=0; i<this.Constants.FILESIZE.length; i++){
var versionHash=tempFile.readU32(0);
if(versionHash===0x2a46) //v1.3.0 switch?
versionHash=0x29c0;
else if(versionHash===0x3ef9) //v1.3.3 switch?
versionHash=0x3ef8;
else if(versionHash===0x471b) //v1.5 is the same as 1.4
versionHash=0x471a;
if(tempFile.fileSize===this.Constants.FILESIZE[i] && versionHash===this.Constants.HEADER[i] && tempFile.readU32(4)===0xffffffff){
this._getOffsets(i);