mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
fixed #34: Safari not working with zip files
This commit is contained in:
parent
458d7297e4
commit
539b3080bc
3 changed files with 13 additions and 8 deletions
|
@ -29,7 +29,7 @@ caches.keys().then(function(cacheNames){
|
||||||
});
|
});
|
||||||
|
|
||||||
var PRECACHE_ID='rom-patcher-js';
|
var PRECACHE_ID='rom-patcher-js';
|
||||||
var PRECACHE_VERSION='v14';
|
var PRECACHE_VERSION='v14b';
|
||||||
var PRECACHE_URLS=[
|
var PRECACHE_URLS=[
|
||||||
'/RomPatcher.js/','/RomPatcher.js/index.html',
|
'/RomPatcher.js/','/RomPatcher.js/index.html',
|
||||||
'/RomPatcher.js/manifest.json',
|
'/RomPatcher.js/manifest.json',
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Rom Patcher JS <small>v2.5</small> by <a href="/">Marc Robledo</a>
|
Rom Patcher JS <small>v2.5.1</small> by <a href="/">Marc Robledo</a>
|
||||||
<br />
|
<br />
|
||||||
<i class="icon github"></i> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a>
|
<i class="icon github"></i> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a>
|
||||||
<i class="icon heart"></i> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a>
|
<i class="icon heart"></i> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
/* ZIP module for Rom Patcher JS v20210815 - Marc Robledo 2016-2021 - http://www.marcrobledo.com/license */
|
/* ZIP module for Rom Patcher JS v20220109 - Marc Robledo 2016-2022 - http://www.marcrobledo.com/license */
|
||||||
|
|
||||||
const ZIP_MAGIC='\x50\x4b\x03\x04';
|
const ZIP_MAGIC='\x50\x4b\x03\x04';
|
||||||
|
|
||||||
var ZIPManager=(function(){
|
var ZIPManager=(function(){
|
||||||
const FILTER_PATCHES=/\.(ips|ups|bps|aps|rup|ppf|xdelta)$/i;
|
const FILTER_PATCHES=/\.(ips|ups|bps|aps|rup|ppf|mod|xdelta)$/i;
|
||||||
const FILTER_ROMS=/(?<!\.(txt|diz|rtf|docx?|html?|pdf|jpe?g|gif|png|bmp|zip|rar|7z))$/i;
|
//const FILTER_ROMS=/(?<!\.(txt|diz|rtf|docx?|xlsx?|html?|pdf|jpe?g|gif|png|bmp|webp|zip|rar|7z))$/i; //negative lookbehind is not compatible with Safari https://stackoverflow.com/a/51568859
|
||||||
|
const FILTER_NON_ROMS=/(\.(txt|diz|rtf|docx?|xlsx?|html?|pdf|jpe?g|gif|png|bmp|webp|zip|rar|7z))$/i;
|
||||||
|
|
||||||
var _unzipEntry=function(zippedEntry, dest, dest2, parse){
|
var _unzipEntry=function(zippedEntry, dest, dest2, parse){
|
||||||
zippedEntry.getData(new zip.BlobWriter(), function(blob){
|
zippedEntry.getData(new zip.BlobWriter(), function(blob){
|
||||||
|
@ -39,10 +40,14 @@ var ZIPManager=(function(){
|
||||||
/* success */
|
/* success */
|
||||||
function(zipReader){
|
function(zipReader){
|
||||||
zipReader.getEntries(function(zipEntries){
|
zipReader.getEntries(function(zipEntries){
|
||||||
var regex=(sourceFile===romFile)? FILTER_ROMS : FILTER_PATCHES;
|
|
||||||
var filteredEntries=[];
|
var filteredEntries=[];
|
||||||
for(var i=0; i<zipEntries.length; i++){
|
for(var i=0; i<zipEntries.length; i++){
|
||||||
if(regex.test(zipEntries[i].filename) && !zipEntries[i].directory){
|
if(
|
||||||
|
(
|
||||||
|
(sourceFile===romFile && !FILTER_NON_ROMS.test(zipEntries[i].filename) && !FILTER_PATCHES.test(zipEntries[i].filename)) ||
|
||||||
|
(sourceFile!==romFile && FILTER_PATCHES.test(zipEntries[i].filename))
|
||||||
|
) && !zipEntries[i].directory
|
||||||
|
){
|
||||||
filteredEntries.push(zipEntries[i]);
|
filteredEntries.push(zipEntries[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +125,7 @@ var ZIPManager=(function(){
|
||||||
addEvent(li, 'click', _evtClickDialogEntry);
|
addEvent(li, 'click', _evtClickDialogEntry);
|
||||||
zipList.appendChild(li);
|
zipList.appendChild(li);
|
||||||
}
|
}
|
||||||
zipDialog.innerHTML=_('patch_file');
|
zipDialog.innerHTML=_(sourceFile===romFile?'rom_file':'patch_file');
|
||||||
zipDialog.appendChild(zipList);
|
zipDialog.appendChild(zipList);
|
||||||
zipOverlay.appendChild(zipDialog);
|
zipOverlay.appendChild(zipDialog);
|
||||||
document.body.appendChild(zipOverlay);
|
document.body.appendChild(zipOverlay);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue