From 9a9d56d59f50f5a69e2040fc1ad01cbe029e7813 Mon Sep 17 00:00:00 2001 From: fauzanmhr Date: Mon, 21 Oct 2024 20:14:42 +0700 Subject: [PATCH] improve code --- services/animeService.js | 4 +--- views/episode.ejs | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/services/animeService.js b/services/animeService.js index 0af6a42..e08949e 100644 --- a/services/animeService.js +++ b/services/animeService.js @@ -27,6 +27,4 @@ export const fetchAnimeDetails = async (slug) => { console.error('Error fetching anime details:', error); return null; } -}; - -// Add other service methods as needed \ No newline at end of file +}; \ No newline at end of file diff --git a/views/episode.ejs b/views/episode.ejs index 25ae8d8..c74800f 100644 --- a/views/episode.ejs +++ b/views/episode.ejs @@ -73,19 +73,15 @@ const spinner = document.getElementById('loading-spinner'); // Show the spinner and hide the iframe - spinner.style.display = 'flex'; + spinner.classList.remove('d-none'); iframe.classList.add('d-none'); if (selectedValue === "default") { - // Use the default streaming URL iframe.src = "<%= episode.defaultStreamingUrl %>"; } else { - // Fetch the server URL const response = await fetch(`/server-url?serverId=${selectedValue}`); const data = await response.json(); - if (data.url) { - // Update iframe source iframe.src = data.url; } else { console.error('Error fetching server URL'); @@ -93,13 +89,12 @@ } }); - // Listen for iframe load event to hide spinner document.getElementById('streaming-iframe').addEventListener('load', function() { const spinner = document.getElementById('loading-spinner'); const iframe = document.getElementById('streaming-iframe'); // Hide the spinner and show the iframe once loaded - spinner.style.display = 'none'; + spinner.classList.add('d-none'); iframe.classList.remove('d-none'); });