ui: declutter anime pages and controls

This commit is contained in:
2026-04-10 01:15:19 +02:00
parent 8965dc5441
commit e2fc44bf1a
12 changed files with 425 additions and 168 deletions

28
static/js/anime.js Normal file
View File

@@ -0,0 +1,28 @@
;(function () {
const toggleDropdown = () => {
const dropdown = document.getElementById('watchlist-dropdown')
if (!dropdown) {
return
}
dropdown.classList.toggle('open')
}
window.toggleDropdown = toggleDropdown
document.addEventListener('click', (event) => {
const dropdown = document.getElementById('watchlist-dropdown')
if (!dropdown) {
return
}
const target = event.target
if (!(target instanceof Node)) {
return
}
if (!dropdown.contains(target)) {
dropdown.classList.remove('open')
}
})
})()

26
static/js/discover.js Normal file
View File

@@ -0,0 +1,26 @@
;(function () {
const setActiveTab = (clickedTab) => {
const group = clickedTab.closest('[data-tab-group="discover"]')
if (!group) {
return
}
const triggers = group.querySelectorAll('[data-tab-trigger]')
triggers.forEach((tab) => tab.classList.remove('active'))
clickedTab.classList.add('active')
}
document.addEventListener('click', (event) => {
const target = event.target
if (!(target instanceof Element)) {
return
}
const trigger = target.closest('[data-tab-trigger]')
if (!trigger) {
return
}
setActiveTab(trigger)
})
})()

29
static/js/schedule.js Normal file
View File

@@ -0,0 +1,29 @@
;(function () {
const contentSelector = '#schedule-content'
const loadDay = (tab) => {
const day = tab.getAttribute('data-day')
if (!day || typeof htmx === 'undefined') {
return
}
const tabs = document.querySelectorAll('[data-schedule-tab]')
tabs.forEach((item) => item.classList.remove('active'))
tab.classList.add('active')
htmx.ajax('GET', `/api/schedule?day=${day}`, contentSelector)
}
document.addEventListener('click', (event) => {
const target = event.target
if (!(target instanceof Element)) {
return
}
const tab = target.closest('[data-schedule-tab]')
if (!tab) {
return
}
loadDay(tab)
})
})()