355 lines
15 KiB
Plaintext
355 lines
15 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap">
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,600&display=swap">
|
|
{{/* page title injected from child template */}}
|
|
<title>MyAnimeList: {{template "title" .}}</title>
|
|
<link rel="manifest" href="/static/assets/manifest.json">
|
|
<link rel="icon" type="image/svg+xml" href="/static/assets/favicon.svg">
|
|
<link rel="stylesheet" href="/dist/tailwind.css">
|
|
<style>
|
|
/* Prevent transition on load */
|
|
@media (min-width: 1024px) {
|
|
#mobile-menu {
|
|
width: 5rem !important; /* lg:w-20 */
|
|
}
|
|
|
|
.nav-label-container {
|
|
grid-template-columns: 0fr !important;
|
|
opacity: 0 !important;
|
|
margin-left: 0 !important;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 1023px) {
|
|
#mobile-menu {
|
|
transform: translateX(-100%);
|
|
}
|
|
|
|
#mobile-menu[data-mobile-open='true'] {
|
|
transform: translateX(0);
|
|
}
|
|
|
|
#mobile-menu-backdrop[data-mobile-open='true'] {
|
|
display: block;
|
|
}
|
|
}
|
|
|
|
/* Re-enable transitions after initialization */
|
|
.sidebar-ready #mobile-menu,
|
|
.sidebar-ready .nav-label-container {
|
|
transition-property: all;
|
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
transition-duration: 300ms;
|
|
}
|
|
|
|
/* Theme toggle icon visibility */
|
|
html[data-theme="dark"] .theme-icon-dark { display: none; }
|
|
html[data-theme="dark"] .theme-icon-light { display: block; }
|
|
html[data-theme="light"] .theme-icon-light { display: none; }
|
|
html[data-theme="light"] .theme-icon-dark { display: block; }
|
|
</style>
|
|
<script type="module" src="/dist/static/theme.js" defer></script>
|
|
<template id="toast-template">
|
|
<div class="toast pointer-events-auto w-[22rem] max-w-[calc(100vw-2rem)] bg-background shadow-[var(--shadow-card)] ring-1 ring-black/5 flex items-start gap-3 px-4 py-3 transform transition-all duration-300 translate-y-2 opacity-0">
|
|
<div class="min-w-0 flex-1">
|
|
<div class="toast-message text-sm font-medium text-foreground leading-snug"></div>
|
|
</div>
|
|
<button class="toast-close -mr-1 -mt-1 rounded-md p-1.5 opacity-70 hover:opacity-100 hover:bg-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring" aria-label="Close">
|
|
<svg class="size-4 text-foreground-muted" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<path d="M18 6L6 18M6 6l12 12"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</template>
|
|
<script type="module" src="/dist/static/dropdown.js" defer></script>
|
|
<script type="module" src="/dist/static/discover.js" defer></script>
|
|
<script type="module" src="/dist/static/anime.js" defer></script>
|
|
<script type="module" src="/dist/static/timezone.js" defer></script>
|
|
<script type="module" src="/dist/static/player/main.js" defer></script>
|
|
<script type="module" src="/dist/static/search.js" defer></script>
|
|
<script type="module" src="/dist/static/sort_filter.js" defer></script>
|
|
<script type="module" src="/dist/static/dedupe.js" defer></script>
|
|
<script type="module" src="/dist/static/toast.js" defer></script>
|
|
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
|
|
<script>
|
|
document.addEventListener('htmx:afterSwap', function(evt) {
|
|
if (evt.detail.target.classList.contains('error')) {
|
|
if (window.showToast) showToast({ message: 'Failed to load content' });
|
|
}
|
|
});
|
|
document.addEventListener('htmx:responseError', function(evt) {
|
|
if (window.showToast) showToast({ message: 'Something went wrong' });
|
|
});
|
|
</script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const menu = document.getElementById('mobile-menu');
|
|
const backdrop = document.getElementById('mobile-menu-backdrop');
|
|
const toggle = document.querySelector('[data-mobile-menu-toggle]');
|
|
|
|
if (!menu || !backdrop || !toggle) return;
|
|
|
|
const openMenu = function() {
|
|
menu.dataset.mobileOpen = 'true';
|
|
backdrop.dataset.mobileOpen = 'true';
|
|
backdrop.classList.remove('hidden');
|
|
toggle.setAttribute('aria-expanded', 'true');
|
|
};
|
|
|
|
const closeMenu = function() {
|
|
menu.dataset.mobileOpen = 'false';
|
|
backdrop.dataset.mobileOpen = 'false';
|
|
backdrop.classList.add('hidden');
|
|
toggle.setAttribute('aria-expanded', 'false');
|
|
};
|
|
|
|
toggle.addEventListener('click', function() {
|
|
if (menu.dataset.mobileOpen === 'true') {
|
|
closeMenu();
|
|
return;
|
|
}
|
|
|
|
openMenu();
|
|
});
|
|
|
|
backdrop.addEventListener('click', closeMenu);
|
|
|
|
menu.querySelectorAll('a, button').forEach(function(el) {
|
|
el.addEventListener('click', function() {
|
|
if (window.innerWidth < 1024) closeMenu();
|
|
});
|
|
});
|
|
});
|
|
|
|
// Initialize sidebar state on load
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// Small delay to ensure styles are applied before enabling transitions
|
|
requestAnimationFrame(() => {
|
|
document.documentElement.classList.add('sidebar-ready');
|
|
});
|
|
});
|
|
|
|
const watchlistIds = new Set()
|
|
|
|
function initWatchlist(ids) {
|
|
ids.forEach(id => watchlistIds.add(id));
|
|
const sync = () => ids.forEach(id => syncRemoveButtonVisibility(id));
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', sync);
|
|
} else {
|
|
sync();
|
|
}
|
|
}
|
|
|
|
function syncRemoveButtonVisibility(id) {
|
|
const container = document.getElementById('remove-watchlist-container-' + id);
|
|
if (container) {
|
|
container.classList.toggle('hidden', !watchlistIds.has(id));
|
|
}
|
|
}
|
|
|
|
function toggleWatchlist(id, title, btn) {
|
|
// determine action based on current watchlist state
|
|
const isInWatchlist = watchlistIds.has(id)
|
|
const url = isInWatchlist ? `/api/watchlist/${id}` : '/api/watchlist'
|
|
const method = isInWatchlist ? 'DELETE' : 'POST'
|
|
// add to watchlist with default status; remove doesn't need body
|
|
const body = isInWatchlist ? null : JSON.stringify({ animeId: id, status: 'plan_to_watch' })
|
|
fetch(url, {
|
|
method,
|
|
headers: body ? { 'Content-Type': 'application/json' } : {},
|
|
body
|
|
}).then(res => {
|
|
if (res.ok) {
|
|
if (isInWatchlist) {
|
|
watchlistIds.delete(id)
|
|
btn.classList.remove('in-watchlist')
|
|
btn.setAttribute('aria-label', 'Add to Watchlist')
|
|
if (window.showToast) showToast({ message: `Removed ${title} from watchlist` })
|
|
|
|
// Update dropdown status if on anime page
|
|
syncWatchlistDropdown(id, false)
|
|
} else {
|
|
watchlistIds.add(id)
|
|
btn.classList.add('in-watchlist')
|
|
btn.setAttribute('aria-label', 'Remove from Watchlist')
|
|
if (window.showToast) showToast({ message: `Added ${title} to watchlist` })
|
|
|
|
// Update dropdown status if on anime page
|
|
syncWatchlistDropdown(id, true)
|
|
}
|
|
|
|
// Update all other watchlist icons on the page for this anime
|
|
document.querySelectorAll('.watchlist-icon').forEach(function(icon) {
|
|
const button = icon.closest('button')
|
|
if (button && button !== btn) {
|
|
const malId = button.dataset.malId
|
|
if (malId && parseInt(malId) === id) {
|
|
if (watchlistIds.has(id)) {
|
|
button.classList.add('in-watchlist')
|
|
} else {
|
|
button.classList.remove('in-watchlist')
|
|
}
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
if (window.showToast) showToast({ message: 'Failed to update watchlist' })
|
|
}
|
|
}).catch(() => {
|
|
if (window.showToast) showToast({ message: 'Something went wrong' })
|
|
})
|
|
}
|
|
|
|
function syncWatchlistDropdown(id, inWatchlist) {
|
|
const statusDisplay = document.getElementById('watchlist-status-display-' + id)
|
|
if (statusDisplay) {
|
|
statusDisplay.textContent = inWatchlist ? 'Plan to Watch' : 'Add to Watchlist'
|
|
syncRemoveButtonVisibility(id)
|
|
}
|
|
}
|
|
|
|
function removeFromWatchlist(id, btn) {
|
|
fetch(`/api/watchlist/${id}`, { method: 'DELETE' }).then(res => {
|
|
if (res.ok) {
|
|
watchlistIds.delete(id)
|
|
const card = btn.closest('.group').parentElement
|
|
if (card) card.remove()
|
|
if (window.showToast) showToast({ message: 'Removed from watchlist' })
|
|
setTimeout(() => location.reload(), 100)
|
|
} else {
|
|
if (window.showToast) showToast({ message: 'Failed to update watchlist' })
|
|
}
|
|
})
|
|
}
|
|
|
|
function updateWatchlist(id, status, display, title, btn) {
|
|
fetch('/api/watchlist', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ animeId: id, status: status })
|
|
}).then(res => {
|
|
if (res.ok) {
|
|
watchlistIds.add(id);
|
|
document.getElementById('watchlist-status-display-' + id).textContent = display;
|
|
syncRemoveButtonVisibility(id);
|
|
document.querySelectorAll('.watchlist-icon').forEach(function(icon) {
|
|
const button = icon.closest('button');
|
|
if (button) {
|
|
const malId = button.dataset.malId;
|
|
if (malId && parseInt(malId) === id) {
|
|
button.classList.add('in-watchlist');
|
|
}
|
|
}
|
|
});
|
|
requestAnimationFrame(() => {
|
|
const dropdown = btn.closest('ui-dropdown');
|
|
if (dropdown) dropdown.close();
|
|
});
|
|
if (window.showToast) showToast({ message: `Marked ${title} as ${display}` });
|
|
} else {
|
|
if (window.showToast) showToast({ message: 'Failed to update watchlist' });
|
|
}
|
|
}).catch(() => {
|
|
if (window.showToast) showToast({ message: 'Something went wrong' });
|
|
});
|
|
}
|
|
|
|
function removeWatchlist(id, title, btn) {
|
|
fetch('/api/watchlist/' + id, { method: 'DELETE' }).then(res => {
|
|
if (res.ok) {
|
|
watchlistIds.delete(id);
|
|
document.getElementById('watchlist-status-display-' + id).textContent = 'Add to Watchlist';
|
|
syncRemoveButtonVisibility(id);
|
|
if (window.showToast) showToast({ message: `Removed ${title} from watchlist` });
|
|
document.querySelectorAll('.watchlist-icon').forEach(function(icon) {
|
|
const button = icon.closest('button');
|
|
if (button) {
|
|
const malId = button.dataset.malId;
|
|
if (malId && parseInt(malId) === id) {
|
|
button.classList.remove('in-watchlist');
|
|
}
|
|
}
|
|
});
|
|
if (btn) {
|
|
const dropdown = btn.closest('ui-dropdown');
|
|
if (dropdown) dropdown.close();
|
|
}
|
|
} else {
|
|
if (window.showToast) showToast({ message: 'Failed to update watchlist' });
|
|
}
|
|
}).catch(() => {
|
|
if (window.showToast) showToast({ message: 'Something went wrong' });
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body class="bg-background text-foreground">
|
|
<div class="flex min-h-screen flex-col">
|
|
{{if .User}}
|
|
<header class="fixed inset-x-0 top-0 z-50 flex h-14 items-center bg-background-sidebar px-4 lg:hidden">
|
|
<button type="button" data-unstyled-button data-mobile-menu-toggle class="inline-flex items-center justify-center bg-background-button p-2 text-foreground" aria-label="Open menu" aria-controls="mobile-menu" aria-expanded="false">
|
|
<svg class="size-6" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
<path d="M4 6h16"></path>
|
|
<path d="M4 12h16"></path>
|
|
<path d="M4 18h16"></path>
|
|
</svg>
|
|
</button>
|
|
<div class="ml-3 min-w-0 flex-1 truncate text-sm font-medium text-foreground">MyAnimeList</div>
|
|
</header>
|
|
|
|
<div class="flex flex-1 overflow-hidden pt-14 lg:pt-0">
|
|
<!-- Sidebar -->
|
|
<div id="mobile-menu-backdrop" data-mobile-menu-backdrop class="fixed inset-0 z-40 hidden bg-black/50 lg:hidden"></div>
|
|
|
|
<div id="mobile-menu" data-mobile-open="false" class="fixed inset-y-0 left-0 z-50 w-64 shrink-0 overflow-hidden bg-background-sidebar transition-transform duration-300 lg:static lg:translate-x-0 lg:transition-none">
|
|
{{block "sidebar" .}}
|
|
{{template "navigation" dict "CurrentPath" .CurrentPath}}
|
|
{{end}}
|
|
</div>
|
|
|
|
<div class="fixed inset-0 z-[60] hidden items-start justify-center bg-black/50 px-4 pt-[12vh]" data-command-palette-dialog aria-hidden="true">
|
|
<div class="w-full max-w-2xl overflow-hidden bg-background-button shadow-[var(--shadow-card)]" data-command-palette-root role="dialog" aria-modal="true" aria-label="Command palette">
|
|
<label for="command-palette-input" class="sr-only">Search commands and anime</label>
|
|
<div class="flex items-center">
|
|
<svg class="mx-4 size-5 shrink-0 text-foreground-muted" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="11" cy="11" r="8" />
|
|
<path d="m21 21-4.35-4.35" />
|
|
</svg>
|
|
<input
|
|
id="command-palette-input"
|
|
name="q"
|
|
type="search"
|
|
autocomplete="off"
|
|
placeholder="Search or jump to..."
|
|
class="min-w-0 flex-1 bg-transparent py-4 pr-4 text-base text-foreground placeholder:text-foreground-muted outline-none"
|
|
/>
|
|
<button type="button" data-unstyled-button class="mr-3 px-2 py-1 text-xs text-foreground-muted transition-colors hover:text-foreground" data-command-palette-close>Esc</button>
|
|
</div>
|
|
<div data-command-palette-results class="max-h-[min(70vh,34rem)] overflow-y-auto py-2"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<main class="w-full flex-1 flex flex-col h-[calc(100dvh-3.5rem)] overflow-y-auto lg:h-screen">
|
|
<div class="flex-1 p-4 md:p-8">
|
|
{{template "content" .}}
|
|
</div>
|
|
</main>
|
|
</div>
|
|
{{else}}
|
|
<main class="w-full flex-1 flex flex-col">
|
|
<div class="flex-1">
|
|
{{template "content" .}}
|
|
</div>
|
|
</main>
|
|
{{end}}
|
|
</div>
|
|
</body>
|
|
</html>
|