Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve screen reader experience based on user feedback. #64

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/assets/js/keyboard-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 3 additions & 8 deletions src/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...") {
Expand All @@ -311,7 +307,6 @@ var countryCountObj = {};
if (d3.select("#loading-text").html() === "Last.fm is taking<br>a long time to<br>respond...") {
d3.select("#loading-text").html("Maybe <a href='http://last.fm' target='_blank'>last.fm</a> has<br>gone offline...")
.style("pointer-events", "all");
clearInterval(announcementIntervalId);
}
}, 8000);
}
Expand Down Expand Up @@ -414,10 +409,10 @@ 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`);
map.setAttribute("aria-labelledby", `${existingAriaLabelledBy} progress-text sr-instructions`);

// We're done, fade out loader
var loader = d3.select(".loader");
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ <h2 class="no-countries__info"></h2>
<!-- Labels used for screen reader labels -->
<span class="hidden" id="map-label">Your world map</span>
<span class="hidden" id="showing">Currently showing</span>
<span class="hidden" id="sr-instructions">Press L to list visible countries</span>
<span class="hidden" id="music-from">Music from</span>
<span class="hidden" id="tags-for">Tags for</span>
</footer>
Expand Down
Loading