<commit_before>import * as xhr from 'common/xhr';

lichess.load.then(() => {
  const localPrefs: [string, string, string, number][] = [
    ['behavior', 'arrowSnap', 'arrow.snap', 1],
    ['behavior', 'courtesy', 'courtesy', 0],
    ['behavior', 'scrollMoves', 'scrollMoves', 1],
  ];

  $('.security table form').on('submit', function (this: HTMLFormElement) {
    xhr.text(this.action, { method: 'post', body: new URLSearchParams(new FormData(this) as any) });
    $(this).parent().parent().remove();
    return false;
  });

  $('form.autosubmit').each(function (this: HTMLFormElement) {
    const form = this,
      $form = $(form),
      showSaved = () => $form.find('.saved').show();
    $form.find('input').on('change', function (this: HTMLInputElement) {
      localPrefs.forEach(([categ, name, storeKey]) => {
        if (this.name == `${categ}.${name}`) {
          lichess.storage.set(storeKey, this.value);
          showSaved();
        }
      });
      xhr.formToXhr(form).then(() => {
        showSaved();<commit_msg>Actually show "your settings were saved" banner<commit_after>import * as xhr from 'common/xhr';

lichess.load.then(() => {
  const localPrefs: [string, string, string, number][] = [
    ['behavior', 'arrowSnap', 'arrow.snap', 1],
    ['behavior', 'courtesy', 'courtesy', 0],
    ['behavior', 'scrollMoves', 'scrollMoves', 1],
  ];

  $('.security table form').on('submit', function (this: HTMLFormElement) {
    xhr.text(this.action, { method: 'post', body: new URLSearchParams(new FormData(this) as any) });
    $(this).parent().parent().remove();
    return false;
  });

  $('form.autosubmit').each(function (this: HTMLFormElement) {
    const form = this,
      $form = $(form),
      showSaved = () => $form.find('.saved').removeClass('none');
    $form.find('input').on('change', function (this: HTMLInputElement) {
      localPrefs.forEach(([categ, name, storeKey]) => {
        if (this.name == `${categ}.${name}`) {
          lichess.storage.set(storeKey, this.value);
          showSaved();
        }
      });
      xhr.formToXhr(form).then(() => {
        showSaved();
{'fraction_non_alphanumeric': 0.20823473734027448, 'fraction_numerical': 0.002839564600094652, 'mean_word_length': 3.4133611691022963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '318995', 'n_tokens_mistral': 711, 'n_tokens_neox': 689, 'n_words': 139}