<commit_before>function TimelineSetter(timelineData) {
  this.items = timelineData;
  this.times = _(this.items).map(function(q){
    return q.timestamp;
  });
  this.max = _(this.times).max();
  this.min = _(this.times).min();
};

TimelineSetter.prototype.createNotches = function() {
  console.log("max: "+ this.max);
  console.log("min: "+ this.min);
  var that = this;
  _(this.items).each(function(item) {
    var timestamp,position,tmpl,html;
    timestamp = item.timestamp;
    position = that.calculatePosition(timestamp);
    tmpl = _.template($("#notch_tmpl").html());
    html = tmpl(item);
    $(".timeline_notchbar").append(html);
    $(".notch_" + timestamp).css("right",position + "%");
  });
};

TimelineSetter.prototype.calculatePosition = function(timestamp) {
  return ((this.max - timestamp) / (this.max - this.min)) * 100;
};

TimelineSetter.prototype.template = function(timestamp) {
  var item,tmpl,html;
  item = _(this.items).select(function(q) {
    return q.timestamp === Number(timestamp);
  })[0];
  tmpl = _.template($("#card_tmpl").html());
  html = tmpl(item);
  return html;
};

TimelineSetter.prototype.cardPosition = function(timestamp) {
  var barWidth,cardWidth,notchPosition,cardPosition;
  barWidth = $(".timeline_notchbar").width();
  cardWidth = 300;
  notchPosition = this.calculatePosition(timestamp);
  return cardPosition = notchPosition > 50 ? notchPosition : (notchPosition + ((cardWidth / barWidth) * 100));
};

TimelineSetter.prototype.next = function() {
  if (!this.currentCard) return;
};

TimelineSetter.prototype.prev = function() {
  if (!this.currentCard) return;

};

TimelineSetter.prototype.zoom = function(direction) {
  this.curZoom = this.curZoom ? this.curZoom : 100;
  if (direction === "in") {
    this.curZoom += 100;
  } else if (this.curZoom === 100) {
    return;
  } else {
    this.curZoom -= 100;
  }
  var dir = this.direction === "in" ? "-" : "+";
  //$(".timeline_notchbar").animate({ width : dir + "=" + this.curZoom + "%"});
  $(".timeline_notchbar").width(this.curZoom + "%")
}

TimelineSetter.prototype.scrub = function(direction) {
  //don't allow scrubbage if we're not zoomed in
  if (!this.curZoom || this.curZoom === 100) return;
  
  
  this.curScrub = this.curScrub ? this.curScrub : 0;
  if (direction === "right") {
   if (this.curScrub === 100) return;
   this.curScrub += 20; 
  }
  
  if (direction === "left") {
    if (this.curScrub === 0) return;
    this.curScrub -= 20;
  }
  console.log(this.curScrub);
  $(".timeline_notchbar").css("left",this.curScrub + "%");
}

$(document).ready(function() {
  var page_timeline = new TimelineSetter(timelineData);
  page_timeline.createNotches();
  
  
  $(".timeline_notch").hover(function() {
    var timestamp,html,cardPosition;
    page_timeline.currentCard = timestamp;
    timestamp = $(this).attr("data-timestamp");
    html = page_timeline.template(timestamp);
    cardPosition = page_timeline.cardPosition(timestamp);
    $("#timeline_card_container").show().html(html).css("right",cardPosition + "%");
    $(".css_arrow").show().css("right",(page_timeline.calculatePosition(timestamp) - 2.8) + "%");
  },function() {
    var el = $("#timeline_card_container");
    // window.setTimeout(function(){
    //   $(".css_arrow").hide();
    //   el.hide();
    // },1000)
  });
  
  $(".timeline_zoom").click(function() {
    var direction = $(this).attr("data-zoom-direction");
    console.log(direction)
    page_timeline.zoom(direction);
  })
  $(".timeline_scrub").click(function() {
    var direction = $(this).attr("data-scrub-direction");
    console.log(direction)
    page_timeline.scrub(direction);
  })
  
});
<commit_msg>zoom and scrub animated<commit_after>function TimelineSetter(timelineData) {
  this.items = timelineData;
  this.times = _(this.items).map(function(q){
    return q.timestamp;
  });
  this.max = _(this.times).max();
  this.min = _(this.times).min();
};

TimelineSetter.prototype.createNotches = function() {
  console.log("max: "+ this.max);
  console.log("min: "+ this.min);
  var that = this;
  _(this.items).each(function(item) {
    var timestamp,position,tmpl,html;
    timestamp = item.timestamp;
    position = that.calculatePosition(timestamp);
    tmpl = _.template($("#notch_tmpl").html());
    html = tmpl(item);
    $(".timeline_notchbar").append(html);
    $(".notch_" + timestamp).css("right",position + "%");
  });
};

TimelineSetter.prototype.calculatePosition = function(timestamp) {
  return ((this.max - timestamp) / (this.max - this.min)) * 100;
};

TimelineSetter.prototype.template = function(timestamp) {
  var item,tmpl,html;
  item = _(this.items).select(function(q) {
    return q.timestamp === Number(timestamp);
  })[0];
  tmpl = _.template($("#card_tmpl").html());
  html = tmpl(item);
  return html;
};

TimelineSetter.prototype.cardPosition = function(timestamp) {
  var barWidth,cardWidth,notchPosition,cardPosition;
  barWidth = $(".timeline_notchbar").width();
  cardWidth = 300;
  notchPosition = this.calculatePosition(timestamp);
  return cardPosition = notchPosition > 50 ? notchPosition : (notchPosition + ((cardWidth / barWidth) * 100));
};

TimelineSetter.prototype.next = function() {
  if (!this.currentCard) return;
};

TimelineSetter.prototype.prev = function() {
  if (!this.currentCard) return;

};

TimelineSetter.prototype.zoom = function(direction) {
  this.curZoom = this.curZoom ? this.curZoom : 100;
  if (direction === "in") {
    this.curZoom += 100;
  } else if (this.curZoom === 100) {
    return;
  } else {
    this.curZoom -= 100;
  }
  var dir = direction === "in" ? "+" : "-";
  console.log(dir + "=" + this.curZoom + "%")
  $(".timeline_notchbar").animate({ width : dir + "=" + this.curZoom + "%"});
}

TimelineSetter.prototype.scrub = function(direction) {
  //don't allow scrubbage if we're not zoomed in
  if (!this.curZoom || this.curZoom === 100) return;
  
  
  this.curScrub = this.curScrub ? this.curScrub : 0;
  if (direction === "right") {
   if (this.curScrub === 80) return;
   this.curScrub += 20;
  }
  
  if (direction === "left") {
    if (this.curScrub === 0) return;
    this.curScrub -= 20;
  }
  var dir = direction === "left" ? "+" : "-";
  console.log(dir + "=" + this.curScrub + "%");
  $(".timeline_notchbar").animate(
    { left : dir + "=" + this.curScrub + "%" }
  );
} 

$(document).ready(function() {
  var page_timeline = new TimelineSetter(timelineData);
  page_timeline.createNotches();
  
  
  $(".timeline_notch").hover(function() {
    var timestamp,html,cardPosition;
    page_timeline.currentCard = timestamp;
    timestamp = $(this).attr("data-timestamp");
    html = page_timeline.template(timestamp);
    cardPosition = page_timeline.cardPosition(timestamp);
    $("#timeline_card_container").show().html(html).css("right",cardPosition + "%");
    $(".css_arrow").show().css("right",(page_timeline.calculatePosition(timestamp) - 2.8) + "%");
  },function() {
    var el = $("#timeline_card_container");
    // window.setTimeout(function(){
    //   $(".css_arrow").hide();
    //   el.hide();
    // },1000)
  });
  
  _(["zoom", "scrub"]).each(function(q) {
    $(".timeline_" + q).click(function() {
      var direction = $(this).attr("data-" + q + "-direction");
      page_timeline[q](direction);
    })
  })  
});

{'fraction_non_alphanumeric': 0.1908417877707705, 'fraction_numerical': 0.011379215793803125, 'mean_word_length': 3.90255376344086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3276154', 'n_tokens_mistral': 2552, 'n_tokens_neox': 2436, 'n_words': 400}