chore: split out styles + only load where needed

This commit is contained in:
Cory Dransfeldt 2024-01-02 12:50:20 -08:00
parent 37db7d35d6
commit 0e65983a19
No known key found for this signature in database
28 changed files with 250 additions and 287 deletions

View file

@ -1,43 +0,0 @@
;(async function () {
const nowPlaying = document.getElementById('now-playing')
if (nowPlaying) {
const content = document.getElementById('now-playing-content')
const loading = document.getElementById('now-playing-loading')
const populateNowPlaying = (data) => {
loading.style.display = 'none'
content.innerHTML = data.content
content.classList.remove('hidden')
}
try {
const cache = JSON.parse(localStorage.getItem('now-playing'))
if (cache) populateNowPlaying(cache)
} catch (e) {
/* quiet catch */
}
const data = await fetch('/api/now-playing', {
type: 'json',
})
.then((data) => data.json())
.catch(() => {
loading.style.display = 'none'
})
try {
localStorage.setItem('now-playing', JSON.stringify(data))
} catch (e) {
/* quiet catch */
}
if (!JSON.parse(localStorage.getItem('now-playing')) && !data) nowPlaying.remove()
populateNowPlaying(data)
}
})()
;(async function () {
if (window.location.search.includes('ignore-me') && localStorage)
localStorage.plausible_ignore = true
})()