Skip to content

Commit

Permalink
fix submitMove pref - closes #13237
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jul 18, 2023
1 parent 43b2001 commit 741d5a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/views/account/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ object bits:
st.id := id,
checked option st.checked,
tpe := "checkbox",
st.value := key.toString,
name := field.name
st.value := key.toString
),
label(`for` := id)(value)
)
Expand Down
8 changes: 4 additions & 4 deletions ui/site/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lichess.load.then(() => {
$form = $(form),
showSaved = () => $form.find('.saved').removeClass('none');
$form.find('input').on('change', function (this: HTMLInputElement) {
if (this.name == 'behavior.submitMove') submitMoveChoices(this);
submitMoveChoices('behavior.submitMove');
localPrefs.forEach(([categ, name, storeKey]) => {
if (this.name == `${categ}.${name}`) {
lichess.storage.boolean(storeKey).set(this.value == '1');
Expand Down Expand Up @@ -60,10 +60,10 @@ lichess.load.then(() => {
});
});

function submitMoveChoices(input: HTMLInputElement) {
function submitMoveChoices(name: string) {
let sum = 0;
$(`input[type="checkbox"][name="${input.name}"]:checked`).each(function (this: HTMLInputElement) {
$(`input[type="checkbox"][data-name="${name}"]:checked`).each(function (this: HTMLInputElement) {
sum |= parseInt(this.value);
});
$(`input[type="hidden"][name="${input.name}"]`).val(sum.toString());
$(`input[type="hidden"][name="${name}"]`).val(sum.toString());
}

0 comments on commit 741d5a0

Please sign in to comment.