4 Commits

Author SHA1 Message Date
Leo Herzog
c4af414e16 Version Bump 2025-07-02 13:46:20 -04:00
Leo Herzog
d22fdf219c Restructure and Update Service Worker 2025-07-02 13:45:59 -04:00
Leo Herzog
d60f8ffcf1 Icon Fix 2025-07-02 13:34:30 -04:00
Leo Herzog
0c5f522459 Fixed Undefined Variable Reference 2025-07-02 13:33:49 -04:00
3 changed files with 75 additions and 24 deletions

View File

@@ -216,7 +216,7 @@
</div>
<footer>
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v2.0.0</a>
<a href="https://github.com/leoherzog/TorrentParts/releases" target="_blank" rel="noopener">v2.0.1</a>
</footer>
<script type="module" src="/src/parse.js"></script>

View File

@@ -92,7 +92,7 @@ function start() {
source = 'magnet';
originalSourceIcon.innerHTML = '<span class="fad fa-magnet fa-fw"></span>';
sourceTooltip.setContent('Currently loaded information sourced from Magnet URL');
parse(magnet.value);
parse(this.value);
}
});
@@ -390,7 +390,7 @@ function getFontAwesomeIconForMimetype(mimetype) {
return 'file-word';
case mimetype.includes('ms-excel'):
case mimetype.includes('spreadsheet'):
return 'file-powerpoint';
return 'file-spreadsheet';
case mimetype.includes('powerpoint'):
case mimetype.includes('presentation'):
return 'file-powerpoint';

View File

@@ -1,33 +1,84 @@
const assets = [
'/',
'/index.html',
'/bin/bundle.min.js',
'/src/style.css',
'/ext/alata-latin-400.woff2',
'/ext/alata-latin-400.woff',
'/ext/fa.min.js',
'/ext/notyf.min.js',
'/ext/jj2008-06-14.mk4_archive.torrent'
];
const cache_name = 'torrent-parts-v1';
const assets = ['/', '/index.html', '/src/parse.js', '/src/style.css', '/ext/alata-v9-latin-regular.woff2', '/ext/alata-v9-latin-regular.ttf', '/ext/fa.min.js', '/ext/jj2008-06-14.mk4_archive.torrent', '/favicon.ico', '/manifest.webmanifest'];
self.addEventListener('install', function(event) {
self.addEventListener('install', function (event) {
self.skipWaiting(); // Force activate new SW immediately
event.waitUntil(
caches.open('assets')
.then(function(cache) {
caches
.open(cache_name)
.then(function (cache) {
return cache.addAll(assets);
})
.catch(function (error) {
console.error('Service worker install failed:', error);
})
);
});
self.addEventListener('fetch', function(event) {
self.addEventListener('activate', function (event) {
event.waitUntil(
Promise.all([
// Take control of all clients immediately
self.clients.claim(),
// Clean up old caches
caches.keys().then(function (cacheNames) {
return Promise.all(
cacheNames.map(function (cacheName) {
if (cacheName !== cache_name) {
console.log('Deleting old cache:', cacheName);
return caches.delete(cacheName);
}
})
);
}),
])
);
});
self.addEventListener('fetch', function (event) {
// Only cache GET requests
if (event.request.method !== 'GET') {
return;
}
// Network-first strategy for external requests
const requestUrl = new URL(event.request.url);
if (requestUrl.origin !== self.location.origin) {
event.respondWith(
fetch(event.request)
.then(function (response) {
return response;
})
.catch(function () {
console.log('Network request failed, trying cache:', event.request.url);
return caches.match(event.request);
})
);
return;
}
// Cache-first strategy for app assets
event.respondWith(
caches.match(event.request)
.then(function(response) {
caches
.match(event.request)
.then(function (response) {
if (response) {
return response;
}
return fetch(event.request);
}
)
return fetch(event.request).then(function (response) {
// Cache successful responses for future use
if (response && response.status === 200) {
const responseClone = response.clone();
caches.open(cache_name).then(function (cache) {
cache.put(event.request, responseClone);
});
}
return response;
});
})
.catch(function (error) {
console.error('Service worker fetch failed:', error);
// Could return offline fallback page here if needed
})
);
});
});