<commit_before>_SleepMode = function () {  
  EV.call(this);
}
_.extend(_SleepMode.prototype, EV.prototype);

_SleepMode.prototype.configure = function(config){
  config = config || {};
  this.config = config;
  this.sleepModeStatus = false;
  this.timer = null;
  this.config.timeout = this.config.timeout || 1000 * 60 * 5 // 5mins
  this.config.ddp = this.config.ddp || true;
  this.config.focus = this.config.focus || true;
  this.config.route = this.config.route || true;

  if(this.config.ddp){
    this._trackDDPSend();
  }
  this._startTimer();
  _SleepMode.prototype.configure = function(){};
}

_SleepMode.prototype._startTimer = function() {
  var lastTimeoutTime = new Date().getTime();
  var self = this;
  if(!this.timer){
    this.timer = setInterval(function(){
      lastTimeoutTime = new Date().getTime();
      if(lastTimeoutTime - self.lastDDPSendTime >= self.config.timeout){
        self.sleepModeStatus = true;
        self.goSleepMode();
        self.emit('sleep', {type: 'ddp-send'});
      }
    }, this.config.timeout);
  }

};

_SleepMode.prototype._trackDDPSend = function(){
  var originalSend = Meteor.default_connection._send;
  this.lastDDPSendTime = new Date().getTime();
  var self = this;
  Meteor.default_connection._send = function (msg) {
    self.lastDDPSendTime = new Date().getTime();
    return originalSend.call(this, msg);
  }
  this._trackDDPSend = function(){};
}

_SleepMode.prototype._trackRouteChange = function(timeout) {

};

_SleepMode.prototype._trackMouseFocus = function(timeout) {

};<commit_msg>route change and hasFocus<commit_after>_SleepMode = function () {  
  EV.call(this);
}
_.extend(_SleepMode.prototype, EV.prototype);

_SleepMode.prototype.configure = function(config){
  config = config || {};
  this.config = config;
  this.sleepModeStatus = false;
  this.timer = null;
  this.config.timeout = this.config.timeout || 1000 * 60 * 5 // 5mins
  this.config.ddp = this.config.ddp || true;
  this.config.focus = this.config.focus || true;
  this.config.route = this.config.route || true;

  if(this.config.ddp){
    this._trackDDPSend();
  }
  if(this.config.route){
    this._trackRouteChange();
  }
  this._startTimer();
  _SleepMode.prototype.configure = function(){};
}

_SleepMode.prototype._startTimer = function() {
  var lastTimeoutTime = new Date().getTime();
  var self = this;
  if(!this.timer){
    this.timer = setInterval(function(){
      lastTimeoutTime = new Date().getTime();
      var condition;
      if(self.config.ddp){
        condition = lastTimeoutTime - self.lastDDPSendTime >= self.config.timeout;
      }
      if(self.config.focus){
        condition = condition || !document.hasFocus();
      }
      if(self.config.route){
        condition = condition || lastTimeoutTime - self.lastRouteTime >= self.config.timeout;
      }
      if(condition){
        self.sleepModeStatus = true;
        self.goSleepMode();
        self.emit('sleep', self);
      }
    }, this.config.timeout);
  }

};

_SleepMode.prototype._trackDDPSend = function(){
  var originalSend = Meteor.default_connection._send;
  this.lastDDPSendTime = new Date().getTime();
  var self = this;
  Meteor.default_connection._send = function (msg) {
    self.lastDDPSendTime = new Date().getTime();
    return originalSend.call(this, msg);
  }
  this._trackDDPSend = function(){};
}

_SleepMode.prototype._trackRouteChange = function() {
  var self = this;
  if(Router){
    Router.before(function(){
      self.lastRouteTime = new Date().getTime();
    });  
  }
  this._trackRouteChange = function(){};
};

_SleepMode.prototype._trackMouseFocus = function() {
  //document.hasFocus();
};
{'fraction_non_alphanumeric': 0.14971209213051823, 'fraction_numerical': 0.004387167534960241, 'mean_word_length': 3.4981504315659677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7515202', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1155, 'n_words': 202}