<commit_before>var conn;

$(function() {
  renderButton();
  loadWebSockets();

  $('.search-form').submit(function(e) {
    e.preventDefault();
    reloadResults();
  });

  $('body').on('click', '.update', function(e) {
    e.preventDefault();

    var form = $(this).find('form');
    var icon = $(this).find('.fa');
    $.post(form.attr('action'), form.serialize(), function(data) {
      if (data.Error) {
        alert(data.Message);
      } else {
        icon.toggleClass('fa-check');
        icon.toggleClass('fa-plus');
        $('.queue').load('/rooms/' + room + '/queue');
        reloadResults();
      }
    });
  });
});

function reloadResults() {
  var form = $('.search-form');
  if (form.find('input[name="search"]').val() !== '') {
    var res = $('.results');
    res.load(form.attr('action'), form.serialize());
  }
}

function loadWebSockets() {
  if (window["WebSocket"] && typeof(room) !== 'undefined' && room != '') {
    conn = new WebSocket("ws://" + host + "/rooms/" + room + "/ws");
    conn.onclose = function(evt) {
      // Something
    }
    conn.onmessage = function(evt) {
      if (evt.data === "pop") {
        $('.queue').load('/rooms/' + room + '/queue');
        reloadResults();
        return;
      }

      if (evt.data === "playing") {
        $('.now-playing').load('/rooms/' + room + '/now');
        return;
      }
    }
  } else {
    // You ain't got WebSockets, brah
  }
}

function onSignIn(googleUser) {
  var idToken = googleUser.getAuthResponse().id_token;
  verifyToken(idToken);
}
<commit_msg>Scroll to the end when you add a new song<commit_after>var conn;

$(function() {
  renderButton();
  loadWebSockets();

  $('.search-form').submit(function(e) {
    e.preventDefault();
    reloadResults();
  });

  $('body').on('click', '.update', function(e) {
    e.preventDefault();

    var form = $(this).find('form');
    var icon = $(this).find('.fa');
    $.post(form.attr('action'), form.serialize(), function(data) {
      if (data.Error) {
        alert(data.Message);
      } else {
        icon.toggleClass('fa-check');
        icon.toggleClass('fa-plus');
        reloadQueue(true);
        reloadResults();
      }
    });
  });
});

function reloadResults() {
  var form = $('.search-form');
  if (form.find('input[name="search"]').val() !== '') {
    var res = $('.results');
    res.load(form.attr('action'), form.serialize());
  }
}

function reloadQueue(scroll) {
  $('.queue').load('/rooms/' + room + '/queue', function() {
    if (scroll) {
      var q = $('.queue').get(0);
      q.scrollLeft = q.scrollWidth;
    }
  });
}

function loadWebSockets() {
  if (window["WebSocket"] && typeof(room) !== 'undefined' && room != '') {
    conn = new WebSocket("ws://" + host + "/rooms/" + room + "/ws");
    conn.onclose = function(evt) {
      // Something
    }
    conn.onmessage = function(evt) {
      if (evt.data === "pop") {
        reloadQueue(false);
        reloadResults();
        return;
      }

      if (evt.data === "playing") {
        $('.now-playing').load('/rooms/' + room + '/now');
        return;
      }
    }
  } else {
    // You ain't got WebSockets, brah
  }
}

function onSignIn(googleUser) {
  var idToken = googleUser.getAuthResponse().id_token;
  verifyToken(idToken);
}

{'fraction_non_alphanumeric': 0.2189981673793525, 'fraction_numerical': 0.00030543677458766036, 'mean_word_length': 2.587075575027382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6554861', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1062, 'n_words': 196}