<commit_before>define(['can/map', 'can/map/define'], function($map) {
  
  function calcViewable($target_top, $target_height, $view_top, $view_height) {
    var target_bottom = $target_top + $target_height,
        view_bottom = $view_top + $view_height;
    return !($target_top > view_bottom) && !(target_bottom < $view_top);
  }
  
  var defaultWatcherTargetImpl = {
    offsetTop: 0,
    offsetHeight: 0,
    offsetBottom: 0
  };
  
  var Watcher = $map.extend({
    define: {
      status: {
          set: function($target) {
            this.attr('y', $target.pageYOffset);
            this.attr('vh', $target.innerHeight);
          }
      },
      optimal: {
        get: function() {
          var target = this.attr('target'),
              viewHeight = this.attr('vh'),
              viewTop = this.attr('y') + viewHeight/3,
              viewBottom = viewTop + viewHeight - viewHeight/3 * 2;
          
          return !(target.offsetTop > viewBottom) && !(target.offsetBottom < viewTop);
        },
        value: false,
        type: 'boolean'
      },
      viewable: {
        get: function() {
          var target = this.attr('target'),
              viewTop = this.attr('y'),
              viewBottom = viewTop + this.attr('vh');
          
          return !(target.offsetTop > viewBottom) && !(target.offsetBottom < viewTop);
        },
        value: false,
        type: 'boolean'
      },
      y: {
        type: 'number',
        value: 0
      },
      vh: {
        type: 'number',
        value: 0
      },
      target: {
        set: function($target) {
          var impl = defaultWatcherTargetImpl;
          
          if($target) {
            impl.offsetTop = parseFloat($target.offsetTop);
            impl.offsetHeight = parseFloat($target.offsetHeight);
            impl.offsetBottom = impl.offsetTop + impl.offsetHeight;
          }
          
          return impl;
        },
        value: defaultWatcherTargetImpl
      }
    }
  });
  
  return function($element) {
    var watcher = new Watcher(),
        handler = function($event) {
          watcher.attr('status', this);
        };
    
    watcher.attr('target', $element);
    window.addEventListener('scroll', handler);
    window.addEventListener('unload', function() {
      window.removeEventListener('scroll', handler);
    });
    
    return watcher;
  }
});
<commit_msg>Update main.js<commit_after>define(['can/map', 'can/map/define'], function($map) {
  
  function calcViewable($target_top, $target_height, $view_top, $view_height) {
    var target_bottom = $target_top + $target_height,
        view_bottom = $view_top + $view_height;
    return !($target_top > view_bottom) && !(target_bottom < $view_top);
  }
  
  var Watcher = $map.extend({
    define: {
      status: {
          set: function($target) {
            this.attr('y', $target.pageYOffset);
            this.attr('vh', $target.innerHeight);
          }
      },
      optimal: {
        get: function() {
          var target = this.attr('target'),
              viewHeight = this.attr('vh'),
              viewTop = this.attr('y') + viewHeight/3,
              viewBottom = viewTop + viewHeight - viewHeight/3 * 2;
          
          return !(target.offsetTop > viewBottom) && !(target.offsetBottom < viewTop);
        },
        value: false,
        type: 'boolean'
      },
      viewable: {
        get: function() {
          var target = this.attr('target'),
              viewTop = this.attr('y'),
              viewBottom = viewTop + this.attr('vh');
          
          return !(target.offsetTop > viewBottom) && !(target.offsetBottom < viewTop);
        },
        value: false,
        type: 'boolean'
      },
      y: {
        type: 'number',
        value: 0
      },
      vh: {
        type: 'number',
        value: 0
      },
      target: {
        set: function($target) {
          var impl = {
            offsetTop: 0,
            offsetHeight: 0,
            offsetBottom: 0
          };
          
          if($target) {
            impl.offsetTop = parseFloat($target.offsetTop);
            impl.offsetHeight = parseFloat($target.offsetHeight);
            impl.offsetBottom = impl.offsetTop + impl.offsetHeight;
          }
          
          return impl;
        },
        value: null
      }
    }
  });
  
  return function($element) {
    var watcher = new Watcher(),
        handler = function($event) {
          watcher.attr('status', this);
        };
    
    watcher.attr('target', $element);
    window.addEventListener('scroll', handler);
    window.addEventListener('unload', function() {
      window.removeEventListener('scroll', handler);
    });
    
    return watcher;
  }
});

{'fraction_non_alphanumeric': 0.1375874496502014, 'fraction_numerical': 0.0033919864320542717, 'mean_word_length': 1.791715976331361, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2795554', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1352, 'n_words': 262}