live region

This commit is contained in:
mi
2025-11-14 18:42:59 +10:00
parent 7e41401ca3
commit f31383800e
4 changed files with 51 additions and 16 deletions

View File

@@ -32,6 +32,12 @@
const title = comic.title || `#${comic.number}`;
currentComicNumber = comic.number;
// Announce comic change to screen readers
const announcer = document.getElementById('comic-announcer');
if (announcer) {
announcer.textContent = `Loaded comic ${title}, dated ${comic.formatted_date || comic.date}`;
}
// Update container class for full-width option
const container = document.querySelector('.comic-container');
if (comic.full_width) {
@@ -244,12 +250,16 @@
return;
}
const announcer = document.getElementById('comic-announcer');
switch(event.key) {
case 'ArrowLeft':
// Previous comic
if (currentComicNumber > 1) {
event.preventDefault();
loadComic(currentComicNumber - 1);
} else if (announcer) {
announcer.textContent = 'Already at the first comic';
}
break;
case 'ArrowRight':
@@ -257,6 +267,8 @@
if (currentComicNumber < totalComics) {
event.preventDefault();
loadComic(currentComicNumber + 1);
} else if (announcer) {
announcer.textContent = 'Already at the latest comic';
}
break;
case 'Home':
@@ -264,6 +276,8 @@
if (currentComicNumber > 1) {
event.preventDefault();
loadComic(1);
} else if (announcer) {
announcer.textContent = 'Already at the first comic';
}
break;
case 'End':
@@ -271,6 +285,8 @@
if (currentComicNumber < totalComics) {
event.preventDefault();
loadComic(totalComics);
} else if (announcer) {
announcer.textContent = 'Already at the latest comic';
}
break;
}