<commit_before>import { once_ready } from 'once_ready';

var showMeMore = function() {
  var more_items = document.getElementById('more_items');
  var loading    = document.getElementsByClassName('loading')[0];
  var nb_items   = document.getElementById('listing').rows.length;
  var total      = document.getElementById('total');
  var csrf_token = document.querySelector("meta[name='csrf-token']").getAttribute('content');
  var action     = document.querySelector('form.button_to').getAttribute('action')

  more_items.style.display = 'none';
  loading.style.display = '';

  var request = new XMLHttpRequest();
  // var timestamp = new Date().getTime()
  // request.open('GET', document.referrer + '?offset=' + nb_items + '&_=' + timestamp, true);
  request.open('GET', action + '?offset=' + nb_items, true);
  request.setRequestHeader('X-CSRF-Token', csrf_token);
  request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  request.setRequestHeader('Accept', 'text/javascript');

  request.onload = function() {
    if (this.status >= 200 && this.status < 400) {
      loading.style.display = 'none';
      if (nb_items >= total.textContent) {      // pb dernier appel
        more_items.style.display = 'none';
      } else {
        more_items.style.display = '';
      }

      eval(this.response);
    } else {
      console.log('We reached the target server, but it returned an error 😵');
    }
  };

  request.onerror = function() {
    console.log('There was a connection error 😵');
  };

  request.send();<commit_msg>fix bad sequencing<commit_after>import { once_ready } from 'once_ready';

var showMeMore = function() {
  var more_items = document.getElementById('more_items');
  var loading    = document.getElementsByClassName('loading')[0];
  var nb_items   = document.getElementById('listing').rows.length;
  var total      = document.getElementById('total');
  var csrf_token = document.querySelector("meta[name='csrf-token']").getAttribute('content');
  var action     = document.querySelector('form.button_to').getAttribute('action');

  more_items.style.display = 'none';
  loading.style.display = '';

  var request = new XMLHttpRequest();
  request.open('GET', action + '?offset=' + nb_items, true);
  request.setRequestHeader('X-CSRF-Token', csrf_token);
  request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  request.setRequestHeader('Accept', 'text/javascript');

  request.onload = function() {
    if (this.status >= 200 && this.status < 400) {
      loading.style.display = 'none';
      eval(this.response);

      if (document.getElementById('listing').rows.length >= total.textContent) {
        more_items.style.display = 'none';
      } else {
        more_items.style.display = '';
      }
    } else {
      console.log('We reached the target server, but it returned an error 😵');
    }
  };

  request.onerror = function() {
    console.log('There was a connection error 😵');
  };

  request.send();
{'fraction_non_alphanumeric': 0.15652467883705207, 'fraction_numerical': 0.004732927653820149, 'mean_word_length': 3.834967320261438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1435228', 'n_tokens_mistral': 909, 'n_tokens_neox': 884, 'n_words': 176}