<commit_before>(function(window, document, undefined){

  // Various stateful variables;
  var cache     = {};
  var idCounter = 0;
  
  /*
    Mixins
  */
  
  var renderable = function(obj) {
    obj.cid = function(){
      if(this._cid) return this._cid;
      this._cid = idCounter++;
      return this._cid;
    };
    
    obj.$ = function(query){
      return $(query, this.el);
    };
    
    obj.render = function(args){
      if(!this.cacheable) return this.template(args);
      var cid = this.cid();
      if(cache[cid]) return cache[cid].children();
      cache[cid] = $("<div/>").html(this.template(args));
      return cache[cid].children();
    };
    
    return obj;
  };
  
  var observable = function(obj){
    obj.bind = function(cb){
      this._callbacks = this._callbacks || [];
      this._callbacks.push(cb);
    };
    
    obj.trigger = function(){
      if(!this._callbacks) return;
      for(var i = 0; callback = this._callbacks[i]; i++)
        callback.apply(this, arguments)
    };
    
    return obj;
  };
  
  /*
    Plugins
  */
  var draggable = function(obj){
    var dragging = false;
    
    function mousedown(e){
      e.preventDefault();
      dragging = true;
      e.type = "dragstart"
      obj.el.trigger(e);
    };

    function mousemove(e){
      if(!dragging) return;
      e.type = "dragging"
      obj.el.trigger(e);
    };

    function mouseup(e){
      if(!dragging) return;
      dragging = false;
      e.type = "dragend"
      
      obj.el.trigger(e);
    };

    obj.el.bind("mousedown", mousedown);

    $("body").bind("mousemove", mousemove);
    $("body").bind("mouseup", mouseup);

    return obj;
  };
  
  /*
    Utils
  */
  var Bounds = function(){
    this.min = -Infinity;
    this.max = Infinity;
  };
  
  Bounds.prototype.extend = function(num){
    this.min = Math.min(num, this.min);
    this.max = Math.max(num, this.max);
  };
  
  
  /*
    Models
  */
  
  var Timeline = function(series) {
    this.createSeries(series);
    this.bySid  = {};
    this.series = [];
    this.bounds = new Bounds();
  };
  
  observable(timeline);
  Timeline.prototype = _.extend(Timeline.prototype, {
    createSeries : function(series){
      for(var i = 0; i < series.length; i++){
        this.add(series[i]);
      }
    },
    
    add : function(card){
      if(!card.event_series in this.bySid)
        this.bySid(new Series(card));
      var series = this.bySid[card.event_series];
      series.add(card, this);
      this.bounds(series.max());
      this.bounds(series.min());
    }
  });
  
  /*
   Views
  */
  var Bar = function() {
    this.el = $("#timeline_notchbar");
    draggable(this);
  };
  renderable(Bar.prototype);
  Bar.prototype = _.extend(Bar.prototype, {});
  
  
  var color = function(){
    return "#" + _.reduce([256, 182, 230], function(memo, it){
      var unpadded = (Math.random(it) * 256 | 0).toString(16);
      return memo + (unpadded.length < 2 ? "0" + unpadded : unpadded);
    }, "");
  };
  
  var Series = function(series, timeline) {
    this.color    = color();
    this.timeline = timeline;
    this.name     = series.event_name;
    this.cards    = [];
  };
  observable(series);
  renderable(Series.prototype);
  Series.prototype = _.extend(Bar.prototype, {
    add : function(card){
      var crd = new Card(card, this);
      this.cards.splice(this.sortedIndex(crd), 0, crd);
    },
    
    max : function(){
      _.map(this.cards, function(card) { card.timestamp }).chain().max().value();
    },
    
    min : function(){
      _.map(this.cards, function(card) { card.timestamp }).chain().min().value();
    },
    
    sortedIndex : function(card){
      return _.sortedIndex(this.cards, card, function (crd) { return crd.timestamp });
    }
  });
  
  
  var Card = function(card, series) {
    this.series = series;
    
  };
  renderable(Card.prototype);
  Card.prototype = _.extend(Card.prototype, {
    cacheable : true
  });
  
  // Controls
  var Zoom = function() {};
  var Pan = function() {};  
  
})(window, document);




function TimelineSetter(timelineData) {
  this.items = timelineData;
  this.times = _(this.items).map(function(q){
    return q.timestamp;
  }).sort(function(a,b) {<commit_msg>more stubbing out, playing around with state<commit_after>(function(window, document, undefined){

  // Various stateful variables;
  var cache     = {};
  var idCounter = 0;
  
  /*
    Mixins
  */
  
  var renderable = function(obj) {
    obj.cid = function(){
      if(this._cid) return this._cid;
      this._cid = idCounter++;
      return this._cid;
    };
    
    obj.$ = function(query){
      return $(query, this.el);
    };
    
    obj.render = function(args){
      if(!this.cacheable) return this.template(args);
      var cid = this.cid();
      if(cache[cid]) return cache[cid].children();
      cache[cid] = $("<div/>").html(this.template(args));
      return cache[cid].children();
    };
    
    return obj;
  };
  
  var observable = function(obj){
    obj.bind = function(cb){
      this._callbacks = this._callbacks || [];
      this._callbacks.push(cb);
    };
    
    obj.trigger = function(){
      if(!this._callbacks) return;
      for(var i = 0; callback = this._callbacks[i]; i++)
        callback.apply(this, arguments)
    };
    
    return obj;
  };
  
  /*
    Plugins
  */
  var draggable = function(obj){
    var dragging = false;
    
    function mousedown(e){
      e.preventDefault();
      dragging = true;
      e.type = "dragstart"
      obj.el.trigger(e);
    };

    function mousemove(e){
      if(!dragging) return;
      e.type = "dragging"
      obj.el.trigger(e);
    };

    function mouseup(e){
      if(!dragging) return;
      dragging = false;
      e.type = "dragend"
      obj.el.trigger(e);
    };

    obj.el.bind("mousedown", mousedown);

    $("body").bind("mousemove", mousemove);
    $("body").bind("mouseup", mouseup);

    return obj;
  };
  
  /*
    Utils
  */
  var Bounds = function(){
    this.min = -Infinity;
    this.max = Infinity;
  };
  
  Bounds.prototype.extend = function(num){
    this.min = Math.min(num, this.min);
    this.max = Math.max(num, this.max);
  };
  
  
  /*
    Models
  */
  
  var Timeline = function(series) {
    this.createSeries(series);
    this.bySid  = {};
    this.series = [];
    this.bounds = new Bounds();
    this.bar    = new Bar(this);
    this.bind(this.update);
    this.offset    = 0;
    this.zoomLevel = 0;
  };
  
  observable(timeline);
  Timeline.prototype = _.extend(Timeline.prototype, {
    createSeries : function(series){
      for(var i = 0; i < series.length; i++){
        this.add(series[i]);
      }
    },
    
    add : function(card){
      if(!card.event_series in this.bySid)
        this.bySid(new Series(card));
      var series = this.bySid[card.event_series];
      series.add(card, this);
      this.bounds(series.max());
      this.bounds(series.min());
    },
    
    update : function(e){
      
      this.trigger(e);
    }
  });
  
  /*
   Views
  */
  var Bar = function(timeline) {
    this.el = $("#timeline_notchbar");
    this.timeline = timeline;
    draggable(this);
    _.bindAll(this, "dragging", "move")
    el.bind("dragging", this.dragging);
    timeline.bind(this.move);
  };
  renderable(Bar.prototype);
  observable(Bar.prototype);
  
  Bar.prototype = _.extend(Bar.prototype, {
    dragging : function(e){
      this.trigger("move", e);
    },
    
    move : function(e){
      
    }
  });
  
  
  var color = function(){
    return "#" + _.reduce([256, 182, 230], function(memo, it){
      var unpadded = (Math.random(it) * 256 | 0).toString(16);
      return memo + (unpadded.length < 2 ? "0" + unpadded : unpadded);
    }, "");
  };
  
  var Series = function(series, timeline) {
    this.color    = color();
    this.timeline = timeline;
    this.name     = series.event_name;
    this.cards    = [];
  };
  observable(Series);
  renderable(Series.prototype);
  
  Series.prototype = _.extend(Bar.prototype, {
    add : function(card){
      var crd = new Card(card, this);
      this.cards.splice(this.sortedIndex(crd), 0, crd);
    },
    
    sortedIndex : function(card){
      return _.sortedIndex(this.cards, card, this._comparator);
    },
    
    _comparator : function(){
      return crd.timestamp;
    }
  });
  
  ["min", "max"].each(function(key){
    Series.prototype[key] = function() {
      _[key].call(_, this.cards, this._comparator);
    };
  });
  
  
  var Card = function(card, series) {
    this.series = series;
    series.timeline.bind(_.bind(this, this.move));
  };
  renderable(Card.prototype);
  
  Card.prototype = _.extend(Card.prototype, {
    cacheable : true,
    move : function(e){
      
    }
  });
  
  // Controls
  var Zoom = function() {};
  var Pan = function() {};  
  
})(window, document);




function TimelineSetter(timelineData) {
  this.items = timelineData;
  this.times = _(this.items).map(function(q){
    return q.timestamp;
  }).sort(function(a,b) {
{'fraction_non_alphanumeric': 0.1656121656121656, 'fraction_numerical': 0.004884004884004884, 'mean_word_length': 2.337037037037037, 'pattern_counts': {'":': 0, '<': 9, '<?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': '509259', 'n_tokens_mistral': 3133, 'n_tokens_neox': 3071, 'n_words': 562}