|
|
|
|
@@ -20,35 +20,70 @@ async function loadAnime() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const title = data.title.english || data.title.romaji;
|
|
|
|
|
const title = data.title?.english || data.title?.romaji || "Unknown Title";
|
|
|
|
|
document.title = `${title} | WaifuBoard`;
|
|
|
|
|
document.getElementById('title').innerText = title;
|
|
|
|
|
if (data.coverImage?.extraLarge) {
|
|
|
|
|
document.getElementById('poster').src = data.coverImage.extraLarge;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rawDesc = data.description || "No description available.";
|
|
|
|
|
handleDescription(rawDesc);
|
|
|
|
|
|
|
|
|
|
document.getElementById('score').innerText = (data.averageScore || '?') + '% Score';
|
|
|
|
|
document.getElementById('year').innerText = data.seasonYear || '????';
|
|
|
|
|
document.getElementById('genres').innerText = data.genres ? data.genres.slice(0, 3).join(' • ') : '';
|
|
|
|
|
|
|
|
|
|
document.getElementById('year').innerText = data.seasonYear || data.startDate?.year || '????';
|
|
|
|
|
document.getElementById('genres').innerText = data.genres?.length > 0 ? data.genres.slice(0, 3).join(' • ') : '';
|
|
|
|
|
document.getElementById('format').innerText = data.format || 'TV';
|
|
|
|
|
document.getElementById('episodes').innerText = data.episodes || '?';
|
|
|
|
|
document.getElementById('status').innerText = data.status || 'Unknown';
|
|
|
|
|
document.getElementById('season').innerText = `${data.season || ''} ${data.seasonYear || ''}`;
|
|
|
|
|
|
|
|
|
|
if (data.studios && data.studios.nodes.length > 0) {
|
|
|
|
|
document.getElementById('studio').innerText = data.studios.nodes[0].name;
|
|
|
|
|
let seasonText = '';
|
|
|
|
|
if (data.season && data.seasonYear) {
|
|
|
|
|
seasonText = `${data.season} ${data.seasonYear}`;
|
|
|
|
|
} else if (data.startDate?.year) {
|
|
|
|
|
const months = ['', 'Winter', 'Winter', 'Spring', 'Spring', 'Spring', 'Summer', 'Summer', 'Summer', 'Fall', 'Fall', 'Fall', 'Winter'];
|
|
|
|
|
const month = data.startDate.month || 1;
|
|
|
|
|
const estimatedSeason = months[month] || '';
|
|
|
|
|
seasonText = `${estimatedSeason} ${data.startDate.year}`.trim();
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('season').innerText = seasonText || 'Unknown';
|
|
|
|
|
|
|
|
|
|
let studioName = 'Unknown Studio';
|
|
|
|
|
if (data.studios?.nodes?.length > 0) {
|
|
|
|
|
studioName = data.studios.nodes[0].name;
|
|
|
|
|
} else if (data.studios?.edges?.length > 0) {
|
|
|
|
|
studioName = data.studios.edges[0]?.node?.name || 'Unknown Studio';
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('studio').innerText = studioName;
|
|
|
|
|
|
|
|
|
|
const charContainer = document.getElementById('char-list');
|
|
|
|
|
charContainer.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
let characters = [];
|
|
|
|
|
|
|
|
|
|
if (data.characters?.nodes?.length > 0) {
|
|
|
|
|
characters = data.characters.nodes.slice(0, 5);
|
|
|
|
|
}
|
|
|
|
|
else if (data.characters?.edges?.length > 0) {
|
|
|
|
|
characters = data.characters.edges
|
|
|
|
|
.filter(edge => edge?.node?.name?.full)
|
|
|
|
|
.slice(0, 5)
|
|
|
|
|
.map(edge => edge.node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.characters && data.characters.nodes) {
|
|
|
|
|
const charContainer = document.getElementById('char-list');
|
|
|
|
|
data.characters.nodes.slice(0, 5).forEach(char => {
|
|
|
|
|
if (characters.length > 0) {
|
|
|
|
|
characters.forEach(char => {
|
|
|
|
|
if (char?.name?.full) {
|
|
|
|
|
charContainer.innerHTML += `
|
|
|
|
|
<div class="character-item">
|
|
|
|
|
<div class="char-dot"></div> ${char.name.full}
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
charContainer.innerHTML = `
|
|
|
|
|
<div class="character-item" style="color: #666;">
|
|
|
|
|
No character data available
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.getElementById('watch-btn').onclick = () => {
|
|
|
|
|
@@ -70,23 +105,28 @@ async function loadAnime() {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
const banner = data.bannerImage || data.coverImage.extraLarge;
|
|
|
|
|
const banner = data.bannerImage || data.coverImage?.extraLarge || '';
|
|
|
|
|
if (banner) {
|
|
|
|
|
document.querySelector('.video-background').innerHTML = `<img src="${banner}" style="width:100%; height:100%; object-fit:cover;">`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.nextAiringEpisode) {
|
|
|
|
|
if (data.episodes) {
|
|
|
|
|
totalEpisodes = data.episodes;
|
|
|
|
|
} else if (data.nextAiringEpisode?.episode) {
|
|
|
|
|
totalEpisodes = data.nextAiringEpisode.episode - 1;
|
|
|
|
|
} else {
|
|
|
|
|
totalEpisodes = data.episodes || 12;
|
|
|
|
|
totalEpisodes = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
totalEpisodes = Math.min(Math.max(totalEpisodes, 1), 5000);
|
|
|
|
|
document.getElementById('episodes').innerText = totalEpisodes;
|
|
|
|
|
|
|
|
|
|
renderEpisodes();
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
console.error('Error loading anime:', err);
|
|
|
|
|
document.getElementById('title').innerText = "Error loading anime";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|