From a3fa2d809f0cc162b00e4a8653222530ca120e20 Mon Sep 17 00:00:00 2001 From: futile Date: Sat, 14 Dec 2024 11:05:42 +0000 Subject: [PATCH] load buttons' alt texts from json --- .vscode/settings.json | 3 ++ index.html | 68 +++++++++++++++++---------------------- static/buttons/_alts.json | 18 +++++++++++ 3 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 static/buttons/_alts.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b3e5d19 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "html.format.wrapLineLength": 160 +} diff --git a/index.html b/index.html index 01ce500..1b54d10 100644 --- a/index.html +++ b/index.html @@ -185,6 +185,16 @@ const randomIndex = Math.floor(Math.random() * quotes.length); document.getElementById('quote').textContent = '« ' + quotes[randomIndex] + ' »'; }); + + fetch('static/buttons/_alts.json') + .then(response => response.json()) + .then(alts => { + document.querySelectorAll("div.footer.buttons img").forEach(img => { + const filename = img.src.split('/').pop(); + img.alt = alts[filename] || "no alt text available, sorry"; + }); + }) + .catch(error => console.error('error loading alt texts: ', error));