<commit_before>$(function() {
    loadVoting('meme-container', 'meme');
});

$('#load-button').text("Loading...");

function yHandler(){
	var body = document.getElementById('memebody');
	var contentHeight = body.offsetHeight;
	var y = window.pageYOffset + window.innerHeight;
	if(y + 400 >= contentHeight){
    window.onscroll = null;
    if ($('.meme').length < 50) {
  		loadMore();
    } else {
      $('#load-button').text("Click here for more spice!");
    }
	}
}

function addFromXML(data, xlst, selector, fn) {
    var parsedXML = jQuery.parseXML(data);
    var xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(xlst);
    $(selector)[fn](xsltProcessor.transformToFragment(parsedXML, document));
}

function loadMore() {
  var loadbutton = document.getElementById('load-button');
  var from = loadbutton.getAttribute('data-load-from');
  var amount = loadbutton.getAttribute('data-load-amount');
  var type = loadbutton.getAttribute('data-load-type');
  var params = "type="+type+"&from="+from+"&amount=" + amount;
  $.ajax({
    method: "GET",
    url: location.protocol + '//' + location.hostname + "/assets/xlst/meme.xsl"
  }).done(function(xlst) {
    $.ajax({
      method: "GET",
      url: location.protocol + '//' + location.hostname + "/index.php/ajax?" + params,
      error: function(xhr, status, error) {
        $("#load-button").hide();
      }
    }).done(function(result) {
      if (result == 'null') {
        window.onscroll = null;
        $("#load-button").hide();
        $('#load-more').append("<p>You have reached the end.</p>");
      } else {
        addFromXML(result, xlst, '#load-more', 'append');
        var nextFrom = parseInt(from) + parseInt(amount);
        loadbutton.setAttribute('data-load-from', nextFrom);
        loadbutton.setAttribute('href', "/index.php/" + type + "/" + from + "/" + amount);
        window.onscroll = yHandler;
      }
    });
  });
}

window.onscroll = yHandler;<commit_msg>viited<commit_after>var SPLITPATHNAME = location.pathname.split('/');
var FROM = SPLITPATHNAME.length > 2 ? parseInt(SPLITPATHNAME[2]) : 0;

$(function() {
    loadVoting('meme-container', 'meme');
});

$('#load-button').text("Loading...");

function yHandler(){
	var body = document.getElementById('memebody');
	var contentHeight = body.offsetHeight;
	var y = window.pageYOffset + window.innerHeight;
	if(y + 400 >= contentHeight){
    window.onscroll = null;
    if ($('.meme').length < 10) {
  		loadMore();
    } else {
      $('#load-button').text("Click here for more spice!");
    }
	}
}

function addFromXML(data, xlst, selector, fn) {
    var parsedXML = jQuery.parseXML(data);
    var xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(xlst);
    $(selector)[fn](xsltProcessor.transformToFragment(parsedXML, document));
}

function loadMore() {
  var loadbutton = document.getElementById('load-button');
  var from = loadbutton.getAttribute('data-load-from');
  var amount = loadbutton.getAttribute('data-load-amount');
  var type = loadbutton.getAttribute('data-load-type');
  var params = "type="+type+"&from="+from+"&amount=" + amount;
  $.ajax({
    method: "GET",
    url: location.protocol + '//' + location.hostname + "/assets/xlst/meme.xsl"
  }).done(function(xlst) {
    $.ajax({
      method: "GET",
      url: location.protocol + '//' + location.hostname + "/index.php/ajax?" + params,
      error: function(xhr, status, error) {
        $("#load-button").hide();
      }
    }).done(function(result) {
      if (result == 'null') {
        window.onscroll = null;
        $("#load-button").hide();
        $('#load-more').append("<p>You have reached the end.</p>");
      } else {
        addFromXML(result, xlst, '#load-more', 'append');
        var nextFrom = parseInt(from) + parseInt(amount);
        loadbutton.setAttribute('data-load-from', nextFrom);
        loadbutton.setAttribute('href', "/index.php/" + type + "/" + nextFrom + "/" + amount);
        window.onscroll = yHandler;

        var memeCount = $('.meme').length;
        history.replaceState({}, '', '/' + type + '/' + FROM + '/' + memeCount);
      }
    });
  });
}

window.onscroll = yHandler;
{'fraction_non_alphanumeric': 0.1911377245508982, 'fraction_numerical': 0.0031137724550898203, 'mean_word_length': 3.3409563409563408, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '6767938', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1347, 'n_words': 249}