add image descriptions/alt text

This commit is contained in:
rhiannon morris 2024-10-21 14:24:17 +02:00
parent 9d0b1a5eb3
commit 18629cb220
5 changed files with 29 additions and 18 deletions

View file

@ -21,7 +21,8 @@ function addCWListeners(id: string | null, caption: HTMLElement): void {
e => { if (e.key == 'Enter') openCW(id, caption, true) });
}
function setImage(id: string, src: string, href: string, cw: string): void {
function setImage(id: string, src: string, href: string,
alt: string, cw: string): void {
const curCw = document.getElementById('cw');
const coverNew = cw != '' && !opened.has(id) && !skipAll.checked;
@ -45,12 +46,14 @@ function setImage(id: string, src: string, href: string, cw: string): void {
// else no cover before or after
mainimg.src = src;
mainimg.alt = mainimg.title = alt;
mainlink.href = href;
}
function activateButton(button: HTMLInputElement, doPush = true): void {
setImage(button.id, button.value,
button.dataset.link!,
button.dataset.alt ?? '',
button.dataset.warning ?? '');
if (doPush) history.pushState(null, '', '#' + button.id);