minor fixes, dont update episode if its number is wrong [this should be handled by name parser!!!], always display episodes [lazy loading optimisation], split service workers [untested!!!]

This commit is contained in:
ThaUnknown 2021-01-14 16:00:49 +01:00
parent 0133e2769b
commit fac388cb07
6 changed files with 83 additions and 89 deletions

View file

@ -75,13 +75,6 @@
</span>
Trailer
</button>
</button>
<button class="btn d-flex align-items-end mb-20" type="button" id="viewEpisodes">
<span class="material-icons mr-10 font-size-20">
video_library
</span>
Episodes
</button>
</div>
</div>
<div class="col-md-7">
@ -107,16 +100,16 @@
</div>
</div>
</div>
<div class="pt-20" id="viewEpisodesWrapper">
<span class="font-weight-bold font-size-22 text-white">Episodes</span>
<div id="episodes" class="pt-10 d-flex overflow-x-auto justify-content-start">
</div>
</div>
<div id="viewRelations" class="pt-20">
<span class="font-weight-bold font-size-22 text-white">Relations</span>
<div class="gallery gallery-sm" id="viewRelationsGallery">
</div>
</div>
<div class="hidden pt-20" id="viewEpisodesWrapper">
<span class="font-weight-bold font-size-22 text-white">Episodes</span>
<div id="episodes" class="pt-10 d-flex overflow-x-auto justify-content-start">
</div>
</div>
</div>
</div>
</div>
@ -787,9 +780,9 @@
<script src="js/settingsHandler.js"></script>
<script src="js/rangeParser.js"></script>
<script src="js/idbkv-chunk-store.js"></script>
<script src="js/torrentHandler.js"></script>
<script src="js/util.js"></script>
<script src="js/animeHandler.js"></script>
<script src="js/torrentHandler.js"></script>
<script src="js/interface.js"></script>
<script src="js/playerHandler.js"></script>
<script src="js/subtitles-octopus.js"></script>

View file

@ -376,9 +376,6 @@ function viewAnime(media) {
} else {
viewRelationsGallery.classList.add("d-none")
}
viewEpisodes.onclick = () => {
viewEpisodesWrapper.classList.toggle("hidden")
}
viewSynonym.onclick = () => {
store[viewSynonymText.value] = media
viewSynonymText.value = ""
@ -386,8 +383,7 @@ function viewAnime(media) {
}
episodes.innerHTML = ""
if (media.streamingEpisodes.length) {
viewEpisodesWrapper.classList.add("hidden")
viewEpisodes.removeAttribute("disabled", "")
viewEpisodesWrapper.classList.add("remove")
let frag = document.createDocumentFragment()
media.streamingEpisodes.forEach(episode => {
let temp = document.createElement("div")
@ -401,7 +397,6 @@ function viewAnime(media) {
episodes.appendChild(frag)
} else {
viewEpisodesWrapper.classList.add("hidden")
viewEpisodes.setAttribute("disabled", "")
}
}
function trailerPopup(trailer) {
@ -620,7 +615,6 @@ async function releasesRss(limit) {
let alID // login icon
async function loadAnime() {
// await searchAnime()
loadOfflineStorage()
if (localStorage.getItem("ALtoken")) {
alRequest({ method: "Viewer" }).then(result => {
oauth.removeAttribute("href")

View file

@ -661,7 +661,7 @@ if ('mediaSession' in navigator) {
function checkCompletion() {
if (!playerData.watched && video.duration - 180 < video.currentTime && playerData.nowPlaying && playerData.nowPlaying[0]) {
if (settings.other2) {
alEntry()
if (parseInt(playerData.nowPlaying[1]) <= playerData.nowPlaying[0].episodes) alEntry()
} else {
halfmoon.initStickyAlert({
content: `Do You Want To Mark <br><b>${playerData.nowPlaying[0].title.userPreferred}</b><br>Episode ${playerData.nowPlaying[1]} As Completed?<br>

View file

@ -40,7 +40,7 @@ const announceList = [
videoExtensions = [
'.avi', '.mp4', '.m4v', '.webm', '.mov', '.mkv', '.mpg', '.mpeg', '.ogv', '.wmv', '.m2ts'
],
scope = window.location.pathname,
scope = "/app/",
sw = navigator.serviceWorker.register('sw.js', { scope }).then(e => {
if (searchParams.get("file")) {
addTorrent(searchParams.get("file"), {}) // add a torrent if its in the link params
@ -104,6 +104,8 @@ function offlineDownload(torrentID, skipVerify) {
})
}
loadOfflineStorage()
// cleanup torrent and store
function cleanupTorrents() {
client.torrents.filter(torrent => {

View file

@ -1,53 +1,10 @@
'use strict';
const staticCacheName = 'v1.0.0';
const filesToCache = [
'index.html',
'js/settingsHandler.js',
'js/animeHandler.js',
'js/playerHandler.js',
'js/subtitleHandler.js',
'js/torrentHandler.js',
'js/rangeParser.js',
'js/util.js',
'css/misc.css',
'css/player.css',
'logo.png',
'https://cdn.jsdelivr.net/npm/matroska-subtitles@3.0.1/dist/matroska-subtitles.min.js',
'https://cdn.jsdelivr.net/npm/halfmoon@1.1.0/css/halfmoon-variables.min.css',
'https://cdn.jsdelivr.net/gh/halfmoonui/halfmoon@1.1.0/js/halfmoon.min.js',
'https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js',
'https://fonts.googleapis.com/icon?family=Material+Icons'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
);
self.skipWaiting();
});
self.addEventListener('activate', event => {
const cacheWhitelist = [staticCacheName];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
return self.clients.claim();
});
self.addEventListener('activate', evt => {
return self.clients.claim()
})
self.addEventListener('fetch', evt => {
const { request } = evt
@ -100,23 +57,3 @@ self.addEventListener('fetch', evt => {
.catch(console.error)
)
})
// self.addEventListener('fetch', event => {
// event.respondWith(
// caches.match(event.request)
// .then(response => {
// if (response) {
// return response;
// }
// return fetch(event.request)
// .then(response => {
// if (response.status === 404) {
// return;
// }
// return response;
// });
// }).catch(error => {
// return caches.match('index.html');
// })
// );
// });

70
sw.js
View file

@ -1 +1,69 @@
self.addEventListener('fetch',(event)=>{});
'use strict';
const staticCacheName = 'v1.0.0';
const filesToCache = [
'index.html',
'js/settingsHandler.js',
'js/animeHandler.js',
'js/playerHandler.js',
'js/torrentHandler.js',
'js/rangeParser.js',
'js/util.js',
'css/misc.css',
'css/player.css',
'logo.png',
'https://cdn.jsdelivr.net/npm/matroska-subtitles@3.0.1/dist/matroska-subtitles.min.js',
'https://cdn.jsdelivr.net/npm/halfmoon@1.1.0/css/halfmoon-variables.min.css',
'https://cdn.jsdelivr.net/gh/halfmoonui/halfmoon@1.1.0/js/halfmoon.min.js',
'https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js',
'https://fonts.googleapis.com/icon?family=Material+Icons'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
);
self.skipWaiting();
});
self.addEventListener('activate', event => {
const cacheWhitelist = [staticCacheName];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
return self.clients.claim();
});
// self.addEventListener('fetch', event => {
// event.respondWith(
// caches.match(event.request)
// .then(response => {
// if (response) {
// return response;
// }
// return fetch(event.request)
// .then(response => {
// if (response.status === 404) {
// return;
// }
// return response;
// });
// }).catch(error => {
// return caches.match('index.html');
// })
// );
// });