From 712e9323e74fe35ed7bbf3f6586375250f5985d1 Mon Sep 17 00:00:00 2001 From: peregrineshahin <41402573+peregrineshahin@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:50:49 +0300 Subject: [PATCH] Improve eAccessibility --- server/fishtest/static/js/application.js | 6 + server/fishtest/static/js/live_elo.js | 8 +- server/fishtest/static/js/spsa.js | 27 +- server/fishtest/templates/actions.mak | 26 +- server/fishtest/templates/base.mak | 50 ++-- server/fishtest/templates/contributors.mak | 30 ++- server/fishtest/templates/elo_results.mak | 7 +- server/fishtest/templates/machines.mak | 32 +-- server/fishtest/templates/nn_upload.mak | 29 ++- server/fishtest/templates/nns.mak | 49 ++-- server/fishtest/templates/notfound.mak | 16 +- server/fishtest/templates/pagination.mak | 8 +- server/fishtest/templates/run_table.mak | 78 +++++- server/fishtest/templates/signup.mak | 58 +++-- server/fishtest/templates/sprt_calc.mak | 68 ++++- server/fishtest/templates/tasks.mak | 8 +- server/fishtest/templates/tests.mak | 48 +++- server/fishtest/templates/tests_live_elo.mak | 44 ++-- server/fishtest/templates/tests_run.mak | 243 +++++++++++++++--- server/fishtest/templates/tests_view.mak | 144 +++++++---- server/fishtest/templates/user.mak | 48 +++- server/fishtest/templates/user_management.mak | 140 +++++----- server/fishtest/templates/workers.mak | 10 +- 23 files changed, 824 insertions(+), 353 deletions(-) diff --git a/server/fishtest/static/js/application.js b/server/fishtest/static/js/application.js index d1fa8e0f3..f8312c036 100644 --- a/server/fishtest/static/js/application.js +++ b/server/fishtest/static/js/application.js @@ -308,6 +308,7 @@ function handleSortingTables() { const th = target; const table = th.closest("table"); const body = table.querySelector("tbody"); + const headers = table.querySelectorAll("th"); Array.from(body.querySelectorAll("tr")) .sort( comparer( @@ -322,6 +323,11 @@ function handleSortingTables() { } body.append(tr); }); + + headers.forEach((header) => { + header.removeAttribute("aria-sort"); + }); + th.setAttribute("aria-sort", this.asc ? "ascending" : "descending"); } }); } diff --git a/server/fishtest/static/js/live_elo.js b/server/fishtest/static/js/live_elo.js index 0e08590b8..e56ea49d7 100644 --- a/server/fishtest/static/js/live_elo.js +++ b/server/fishtest/static/js/live_elo.js @@ -197,7 +197,9 @@ async function followLive(testId) { async function mainWorker() { while (true) { - if (isTabFocused) { + const switchElement = document.getElementById("auto-refresh-switch"); + const autoRefresh = switchElement.checked; + if (autoRefresh && isTabFocused) { update(); } await asyncSleep(20000); @@ -210,7 +212,9 @@ async function followLive(testId) { try { const m = await fetchJson("/api/get_elo/" + testId + "?" + timestamp); displayData(m); - if (m.args.sprt.state) return; + if (m.args.sprt.state) { + return; + } } catch (e) { console.log("Network error: " + e); } diff --git a/server/fishtest/static/js/spsa.js b/server/fishtest/static/js/spsa.js index 575f6a602..dc5d1be97 100644 --- a/server/fishtest/static/js/spsa.js +++ b/server/fishtest/static/js/spsa.js @@ -254,24 +254,25 @@ async function handleSPSA() { } for (let j = 0; j < spsaParams.length; j++) { - const dropdownItem = document.createElement("li"); - const anchorItem = document.createElement("a"); - anchorItem.className = "dropdown-item"; - anchorItem.href = "javascript:"; - anchorItem.param_id = j + 1; - anchorItem.append(spsaParams[j].name); - dropdownItem.append(anchorItem); - document.getElementById("dropdown_individual").append(dropdownItem); + const li = document.createElement("li"); + const button = document.createElement("button"); + button.className = "dropdown-item"; + button.dataset.paramId = j + 1; + button.append(spsaParams[j].name); + li.append(button); + document.getElementById("dropdown_individual").append(li); } document .getElementById("dropdown_individual") .addEventListener("click", (e) => { - if (!e.target.matches("a")) return; const { target } = e; - const param_id = target.param_id; + if (!target.classList.includes("dropdown-item")) { + return; + } + const paramId = target.dataset.paramId; for (let i = 1; i < chart_data.getNumberOfColumns(); i++) { - updateColumnVisibility(i, i == param_id); + updateColumnVisibility(i, i == paramId); } viewAll = false; @@ -304,7 +305,9 @@ async function handleSPSA() { }); document.getElementById("btn_view_all").addEventListener("click", () => { - if (viewAll) return; + if (viewAll) { + return; + } viewAll = true; for (let i = 0; i < chart_data.getNumberOfColumns(); i++) { updateColumnVisibility(i, true); diff --git a/server/fishtest/templates/actions.mak b/server/fishtest/templates/actions.mak index fb08c179b..c5bbd5160 100644 --- a/server/fishtest/templates/actions.mak +++ b/server/fishtest/templates/actions.mak @@ -4,16 +4,16 @@ import datetime %> -

Events Log

+

Events Log

-
+
- @@ -45,6 +45,7 @@ name="user" list="users-list" value="${username_param}" + aria-controls="events-table" > % for user in request.userdb.get_users(): @@ -60,17 +61,20 @@ role="button" data-bs-toggle="modal" data-bs-target="#autoselect-modal" + aria-haspopup="dialog" + aria-label="Free text search information" >