Homepage rework
This commit is contained in:
1 parent
554b7cc82c
commit
db8226b980
6 files changed
+521
-41
No files matched your search
@@ -0,0 +1,27 @@
|
||||
const selectionCard = document.querySelector('[data-selection-url]')
|
||||
const selectionName = document.getElementById('home-selection')
|
||||
const selectionDetail = document.getElementById('home-selection-detail')
|
||||
|
||||
function updateSelectionText(element, text) {
|
||||
// Avoid repeated screen-reader announcements when the selection hasn't changed.
|
||||
if (element.textContent !== text) element.textContent = text
|
||||
}
|
||||
|
||||
async function refreshHomeSelection() {
|
||||
try {
|
||||
const response = await fetch(selectionCard.dataset.selectionUrl, {cache: 'no-store'})
|
||||
if (!response.ok) throw new Error('Selection unavailable')
|
||||
const state = await response.json()
|
||||
updateSelectionText(selectionName, state.blank ? 'Blank screen selected' : state.selected_name)
|
||||
updateSelectionText(selectionDetail, state.using_default && !state.blank
|
||||
? 'Default selection. The player runs separately on your display.'
|
||||
: 'This is the requested selection; the player runs separately on your display.')
|
||||
} catch (error) {
|
||||
updateSelectionText(selectionName, 'Selection unavailable')
|
||||
updateSelectionText(selectionDetail, 'Open the media library to try again.')
|
||||
} finally {
|
||||
window.setTimeout(refreshHomeSelection, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
refreshHomeSelection()
|
||||
Reference in new issue
Block a user