<commit_before>Meteor.subscribe('Chats');
Session.set('slider', parseInt(moment(new Date("01-09-2011 00:00")).format('X')));
function renderSlider() {
    slider = this.$("#slider").noUiSlider({
      range: {
        'min': Session.get('sliderMin'),
        'max': Session.get('sliderMax')
      },
      animate: true,
      start: Session.get('slider'),
      step: 3600,
      format: wNumb({
         decimals: 3
       })
    }).on('slide', function (ev, val) {
      Session.set('slider', val);
  });
}
Tracker.autorun(function () {
Template.Chat.onRendered(renderSlider);
});

Template['Chat'].helpers({
    slider: function () {
      return Session.get("slider");
    },
    formatDate : function(date) {
      return moment.unix(date).format('MM/DD/YYYY hh:mm a');
    },
    Bubbles : function() {
      id = Router.current().params._id;
      Bubbles = new Mongo.Collection(null);
      chats = Chats.findOne({ _id : id })
      Session.set('sliderMin', parseInt(moment(_.first(_.pluck(chats.bubbles, 'sentAt'))).format('X')));
      Session.set('sliderMax', parseInt(moment(_.last(_.pluck(chats.bubbles, 'sentAt'))).format('X')));
      for (var i = 0; i < chats.bubbles.length; i++) {
        Bubbles.insert(chats.bubbles[i]);
      }
      return Bubbles.find({
                            sentAt : {
                                      $lt : new Date(Session.get('slider')*1000)
                                     }
                          });
    }
});

Template['Chat'].events({
  'click .play' : function(e) {
    console.log("Playing...");
    e.preventDefault();
    time = 20; //seconds
    val = parseInt(moment(new Date("01-10-2011 00:00")).format('X'));
    step = Math.abs(val - slider.val())/time;
    stepper = 0;
    start = parseInt(slider.val());
    timer = setInterval(function(){
              setSliderValue(start + stepper);
              if(val <= parseInt(slider.val())) {
                clearInterval(timer);
              }
              stepper+=step;
          }, 1000);
  },
  'click .stop' : function(e) {
    e.preventDefault();
    console.log("Stopped");
  }
  });

function setSliderValue(val){
  slider.val(val);
  Session.set('slider', val);
  return true;
}
<commit_msg>Fixed slider pt.2<commit_after>Meteor.subscribe('Chats');

function renderSlider(min, max, start, step) {
    Session.set('slider', min);
    slider = this.$("#slider").noUiSlider({
      range: {
        'min': min,
        'max': max
      },
      animate: true,
      start: start,
      step: step,
      format: wNumb({
         decimals: 3
       })
    }).on('slide', function (ev, val) {
      Session.set('slider', val);
  });
}
Tracker.autorun(function () {
  if(Session.get('sliderMin') != undefined || Session.get('sliderMax') != undefined) {
    Template.Chat.onRendered(renderSlider(Session.get('sliderMin'), Session.get('sliderMax'), Session.get('sliderMin'), 3600));
  }
});

Template['Chat'].helpers({
    slider: function () {
      return Session.get("slider");
    },
    formatDate : function(date) {
      return moment.unix(date).format('MM/DD/YYYY hh:mm a');
    },
    Bubbles : function() {
      id = Router.current().params._id;
      Bubbles = new Mongo.Collection(null);
      chats = Chats.findOne({ _id : id })
      console.log("Burbujas");
      /* TODO: Order by sentAt */
      if(Session.get('sliderMin') == undefined || Session.get('sliderMax') == undefined) {
        Session.set('sliderMin', parseInt(moment(_.first(_.pluck(chats.bubbles, 'sentAt'))).format('X')));
        Session.set('sliderMax', parseInt(moment(_.last(_.pluck(chats.bubbles, 'sentAt'))).format('X')));
      }
      for (var i = 0; i < chats.bubbles.length; i++) {
        Bubbles.insert(chats.bubbles[i]);
      }
      return Bubbles.find({
                            sentAt : {
                                      $lt : new Date(Session.get('slider')*1000)
                                     }
                          });
    }
});

Template['Chat'].events({
  'click .play' : function(e) {
    console.log("Playing...");
    e.preventDefault();
    time = 20; //seconds
    val = parseInt(moment(new Date("01-10-2011 00:00")).format('X'));
    step = Math.abs(val - slider.val())/time;
    stepper = 0;
    start = parseInt(slider.val());
    timer = setInterval(function(){
              setSliderValue(start + stepper);
              if(val <= parseInt(slider.val())) {
                clearInterval(timer);
              }
              stepper+=step;
          }, 1000);
  },
  'click .stop' : function(e) {
    e.preventDefault();
    console.log("Stopped");
  }
  });

function setSliderValue(val){
  slider.val(val);
  Session.set('slider', val);
  return true;
}

{'fraction_non_alphanumeric': 0.18297331639135958, 'fraction_numerical': 0.015036001694197373, 'mean_word_length': 2.279861111111111, 'pattern_counts': {'":': 0, '<': 7, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6405186', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1503, 'n_words': 249}