Skip to content

Commit

Permalink
improve handling of radio buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed Apr 21, 2023
1 parent a91a42c commit 61f41bd
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions jaws.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ function jawsHandler(e) {
var elem = e.currentTarget;
var jid = elem.getAttribute('jid');
if (jid) {
var val = elem.value;
var elemtype = elem.getAttribute('type');
if (jawsIsCheckable(elemtype)) {
val = elem.checked;
} else if (elem.tagName.toLowerCase() === 'option') {
jawsChangeCheckable(elem);
return;
}
var val = elem.value;
if (elem.tagName.toLowerCase() === 'option') {
val = elem.selected;
}
jaws.send(jid + "\n" + e.type + "\n" + val);
Expand Down Expand Up @@ -76,10 +78,25 @@ function jawsAlert(type, message) {
console.log("jaws: " + type + ": " + message);
}

function jawsChangeCheckable(elem) {
jaws.send(elem.getAttribute('jid') + "\ninput\n" + elem.checked);
var elemname = elem.getAttribute('name');
if (elemname) {
var selector = elem.tagName + '[type="' + elem.type + '"][name="' + elemname + '"]';
var others = document.querySelectorAll(selector);
for (var i = 0; i < others.length; i++) {
var other = others[i];
if (other !== elem) {
jaws.send(other.getAttribute('jid') + "\ninput\n" + other.checked);
}
}
}
}

function jawsSetValue(elem, str) {
var elemtype = elem.getAttribute('type');
if (jawsIsCheckable(elemtype)) {
elem.checked = jawsIsTrue(str);
jawsChangeCheckable(elem);
return;
}
if (jawsHasSelection(elemtype)) {
Expand Down

0 comments on commit 61f41bd

Please sign in to comment.