From 2a74365651662e3cb256c3b95f690b53b418db11 Mon Sep 17 00:00:00 2001 From: Tommy Feldt Date: Fri, 2 Feb 2024 16:38:10 +0100 Subject: [PATCH 1/3] Improve screen reader experience based on user feedback. Remove annoying stuff, add more useful stuff --- src/assets/js/keyboard-mode.js | 8 ++++++-- src/assets/js/script.js | 9 ++------- src/assets/js/search.js | 2 +- src/index.html | 1 + 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/assets/js/keyboard-mode.js b/src/assets/js/keyboard-mode.js index 67d0fe9..6deb516 100644 --- a/src/assets/js/keyboard-mode.js +++ b/src/assets/js/keyboard-mode.js @@ -56,13 +56,17 @@ const handleLetterKeyPress = (e) => { } function getCurrentlyVisibleCountries() { + const userName = window.location.href.split("username=")[1]; + let data = script.getCurrentData(); // return an array consiting of objects with the country name in plain text + the index number of the country let formattedCountries = []; visibleCountries.forEach((country) => { + const countryId = parseInt(country.id.slice(1)); const letter = ALPHABET[visibleCountries.indexOf(country)]; formattedCountries.push({ name: utils.getCountryNameFromId(parseInt(country.id.slice(1))), - number: letter + number: letter, + artistCount: data[countryId][userName].length || 0 }); }); return formattedCountries; @@ -354,7 +358,7 @@ function getVisibleCountries(zoom) { let message = "List of countries: "; const countries = getCurrentlyVisibleCountries(); countries.forEach((country) => { - message += `${country.number}: ${country.name}, `; + message += `${country.number}: ${country.name} (${country.artistCount} artists), `; }); announcer.announce(message, "assertive", 100); console.log(message); diff --git a/src/assets/js/script.js b/src/assets/js/script.js index a7ed496..6b0dd5f 100644 --- a/src/assets/js/script.js +++ b/src/assets/js/script.js @@ -298,11 +298,7 @@ var countryCountObj = {}; // Screen reader status update every 30 seconds setTimeout(function () { announcer.announce(document.getElementById("loading-text").innerText); - }, 3000); - announcer.announce(document.getElementById("loading-text").innerText); - announcementIntervalId = setInterval(() => { - announcer.announce(document.getElementById("loading-text").innerText); - }, 45000); + }, 6000); setTimeout(function () { if (d3.select("#loading-text").html() === "Getting library...") { @@ -311,7 +307,6 @@ var countryCountObj = {}; if (d3.select("#loading-text").html() === "Last.fm is taking
a long time to
respond...") { d3.select("#loading-text").html("Maybe last.fm has
gone offline...") .style("pointer-events", "all"); - clearInterval(announcementIntervalId); } }, 8000); } @@ -414,7 +409,7 @@ var countryCountObj = {}; // Screen reader status update clearInterval(announcementIntervalId); - announcer.announce("All artists are loaded!"); + announcer.announce("All artists have been loaded!"); const map = document.querySelector("#map-container svg") const existingAriaLabelledBy = map.getAttribute("aria-labelledby"); map.setAttribute("aria-labelledby", `${existingAriaLabelledBy} progress-text`); diff --git a/src/assets/js/search.js b/src/assets/js/search.js index b90d230..ffd0232 100644 --- a/src/assets/js/search.js +++ b/src/assets/js/search.js @@ -47,7 +47,7 @@ let filteredShortcuts = []; let announcement = ''; if (announcementParts.length > 0) { - announcement = 'Showing ' + announcementParts.slice(0, -1).join(', ') + (announcementParts.length > 1 ? ' and ' : '') + announcementParts.slice(-1); + announcement = 'Showing ' + announcementParts.slice(0, -1).join(', ') + (announcementParts.length > 1 ? ' and ' : '') + announcementParts.slice(-1) + ', press down arrow to go to results'; } else { announcement = 'No results found'; } diff --git a/src/index.html b/src/index.html index 2db7487..6ce32f0 100644 --- a/src/index.html +++ b/src/index.html @@ -313,6 +313,7 @@

+ From f35f44f71c6d15e082e0c3f9dc9badd6e5c2aede Mon Sep 17 00:00:00 2001 From: Tommy Feldt Date: Fri, 2 Feb 2024 16:42:25 +0100 Subject: [PATCH 2/3] Forgot something --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 6ce32f0..932fae6 100644 --- a/src/index.html +++ b/src/index.html @@ -189,7 +189,7 @@

Did you find an accessibility bug or something that didn't work quite right?
-