<commit_before>(function(jQuery, undefined) {
  var $ = jQuery,
    scrollTopOld = jQuery.fn.scrollTop;

  function mappedElement(elm) {

    if (elm === document || elm === window || elm.tagName === 'HTML' || elm.tagName === 'BODY') {
      elm = document;
    }

    return $(elm);
  }

  function scrollFilter(event, originalEvent) {
    var $elm = mappedElement(event.target);


    var expectedScroll = $elm.data('event-scroll-expected');
    var scrollTop = $elm.scrollTop();
    var diff = Math.floor(expectedScroll - scrollTop);
    var scrollTopSet = $elm.data('event-scroll-set');

    if (scrollTopSet && diff == 0) {
      event.scrollType = 'programm';
    } else {
      event.scrollType = 'user';
    }

    $elm.data('event-scroll-set', false);

    return event;
  };

  jQuery.event.fixHooks.scroll = jQuery.event.fixHooks.scroll || {};
  jQuery.event.fixHooks.scroll.filter = scrollFilter;

  jQuery.Tween.propHooks.scrollTop = jQuery.Tween.propHooks.scrollLeft = {
    set: function(tween) {
      if (tween.elem.nodeType && tween.elem.parentNode) {
        var $elm = mappedElement(tween.elem);
        $elm.data('event-scroll-set', true);
        if (tween.start !== tween.end) {
          //we only need to do something of the values differ
          //this is a hack for the $('body, html').animate({scrollTop:x},1000);
          $elm.data('event-scroll-expected', tween.now);
        }
        tween.elem[tween.prop] = tween.now;
      }
    }
  };

  jQuery.fn.scrollTop = function() {

    if (arguments.length === 0) {
      this.each(function(elm) {
        var $elm = mappedElement(elm);
        $elm.data('event-scroll-set', true);
      });
    }

    return scrollTopOld.apply(this, arguments);
  };
}(jQuery));<commit_msg>code cleanup:<commit_after>(function(jQuery, undefined) {
  
  var $ = jQuery,
      scrollTopOld = jQuery.fn.scrollTop,
      dataKey = 'scroll-event';
      
  function getScrollInfo($elm) {
    var info = $elm.data(dataKey) || {};
    $elm.data(dataKey, info);
    return info;
  }

  
  function mappedElement(elm) {
    if (elm === document || elm === window || elm.tagName === 'HTML' || elm.tagName === 'BODY') {
      elm = document;
    }
    
    return $(elm);
  }

  function scrollFilter(event, originalEvent) {
    var $elm = mappedElement(event.target),
        info = getScrollInfo($elm),
        scrollTop = $elm.scrollTop(),
        diff = Math.floor(info.expectedScrollPos - scrollTop);

    if (info.scrollSet && diff === 0) {
      event.scrollType = 'programm';
    } else {
      event.scrollType = 'user';
    }

    info.scrollSet = false;

    return event;
  };


  jQuery.event.fixHooks.scroll = jQuery.event.fixHooks.scroll || {};
  jQuery.event.fixHooks.scroll.filter = scrollFilter;

  //TODO we need scrollLeft support
  jQuery.Tween.propHooks.scrollTop = /*jQuery.Tween.propHooks.scrollLeft =*/ {
    set: function(tween) {
      var $elm, info;
      
      if (tween.elem.nodeType && tween.elem.parentNode) {
        $elm = mappedElement(tween.elem);
        info = getScrollInfo($elm);
        
        info.scrollSet = true;

        /*
          Only set the expected value if start and end value are different.
        
          This is used to support scroll animations on html/body as they both map do document.
          $('body, html').animate({scrollTop:x},1000);
        */
        if (tween.start !== tween.end) {
          info.expectedScrollPos = tween.now;
        }
        
        tween.elem[tween.prop] = tween.now;
      }
    }
  };


  jQuery.fn.scrollTop = function() {

    if (arguments.length === 0) {
      this.each(function(elm) {
        var $elm = mappedElement(elm),
            info = getScrollInfo($elm);
        
        info.scrollSet = true;
      });
    }

    return scrollTopOld.apply(this, arguments);
  };
  
}(jQuery));
{'fraction_non_alphanumeric': 0.14897482481183494, 'fraction_numerical': 0.003114456267843239, 'mean_word_length': 2.407603890362511, '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': '3358975', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1212, 'n_words': 245}