<commit_before>
<script type="text/javascript"><!--

$(() => {

  const testButton  = $('#test-button');
  const testSpinner = $('#test-spinner');
  const testOverlay = $('<div id="test-overlay"></div>');

  const form = testButton.closest('form');

  testButton.enable = () => {
    testButton.attr('disabled', false);
  };

  testButton.disable = () => {
    testButton.attr('disabled', true);
  };

  testButton.click(() => {
    // Called from 3 places
    // 1. when you click [test]
    // 2. when you hot-key Alt-T
    // 3. when you revert from a diff-dialog

    cd.saveCodeFromSyntaxHighlightEditors();
    cd.storeOutgoingFileHashes();

    $.ajax({
      timeout: 30000, // 30 seconds (twice server timeout)
         type: 'POST',
          url: form.attr('action'),
         data: form.serialize(),

      beforeSend: (_xhr, _settings) => {
        testButton.disable();
        testOverlay.insertAfter($('body'));
        testSpinner.show();
      },
      error: (_xhr, status, thrown) => {
        let info = "ERROR\n";
        info += thrown + "\n";
        info += 'status=' + status + "\n";
        if (status == 'timeout') {
          info += 'have you lost your network connection?'
        }
        if (status == 'error') {
          info += 'is the cyber-dojo server down?';
        }
        cd.deleteFile('output');
        cd.newFile('output', info);
      },
      complete: (_xhr, _status) => {
        testSpinner.hide();
        testOverlay.remove();
        testButton.enable();
        cd.loadFile('output');
      }
    });
  });

});

//--></script><commit_msg>add more info to ajax error to help circleci spike<commit_after>
<script type="text/javascript"><!--

$(() => {

  const testButton  = $('#test-button');
  const testSpinner = $('#test-spinner');
  const testOverlay = $('<div id="test-overlay"></div>');

  const form = testButton.closest('form');

  testButton.enable = () => {
    testButton.attr('disabled', false);
  };

  testButton.disable = () => {
    testButton.attr('disabled', true);
  };

  testButton.click(() => {
    // Called from 3 places
    // 1. when you click [test]
    // 2. when you hot-key Alt-T
    // 3. when you revert from a diff-dialog

    cd.saveCodeFromSyntaxHighlightEditors();
    cd.storeOutgoingFileHashes();

    $.ajax({
      timeout: 30000, // 30 seconds (twice server timeout)
         type: 'POST',
          url: form.attr('action'),
         data: form.serialize(),

      beforeSend: (_xhr, _settings) => {
        testButton.disable();
        testOverlay.insertAfter($('body'));
        testSpinner.show();
      },
      error: (request, status, thrown) => {
        let info = "ERROR\n";
        info += thrown + "\n";
        info += 'status=' + status + "\n";
        if (status == 'timeout') {
          info += 'timeout:have you lost your network connection?' + "\n";
        }
        if (status == 'error') {
          info += 'error:is the cyber-dojo server down?' + "\n";
        }
        info += request.responseText + "\n";
        cd.deleteFile('output');
        cd.newFile('output', info);
      },
      complete: (_xhr, _status) => {
        testSpinner.hide();
        testOverlay.remove();
        testButton.enable();
        cd.loadFile('output');
      }
    });
  });

});

//--></script>
{'fraction_non_alphanumeric': 0.18300060496067755, 'fraction_numerical': 0.006654567453115548, 'mean_word_length': 2.20135527589545, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, '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': '2357113', 'n_tokens_mistral': 1032, 'n_tokens_neox': 993, 'n_words': 233}