<commit_before>;(function ($, window, document, undefined) {
  'use strict';

  $.fn.timer = function(time_in_ms) {
    var INTERVAL_TIME = 250,
        time = time_in_ms,
        timer,
        start,
        $el = this;

    this.stop = function() {
      clearInterval(timer);
      time = time - (new Date().getTime() - start);
    };

    this.start = function() {
      clearInterval(timer);
      start = new Date().getTime();
      timer = setInterval(function() {
        var now = time - (new Date().getTime() - start);
        if (now <= 0) {
          clearInterval(timer);
          $el.trigger('timer:complete');
          $el.unbind('timer:progress');
          $el.unbind('timer:complete');
          $el.unbind('timer:start');
          $el.unbind('timer:stop');
        } else {
          $el.trigger('timer:progress', [(time-now)/time]);
        }
      }, INTERVAL_TIME);
    };

    $el.bind('timer:start', this.start);
    $el.bind('timer:stop', this.stop);

    return this;
  };

  Foundation.libs = Foundation.libs || {};

  Foundation.libs.orbit = {
    version: '4.0.0.alpha',

    settings: {
      timer: 1500,
      slide_delay: 500
    },

    init: function(scope, method, options) {
      var self = this;
      $('[data-orbit]', scope).each($.proxy(self._init, self));
    },

    _init: function(idx, slider) {
      var data = {};
      data.$container = $(slider).wrap('<div class="orbit-container"></div>').parent();
      data.$container.append('<a data-orbit-prev href="#">Prev</a>');
      data.$container.append('<a data-orbit-next href="#">Next</a>');
      data.$container.append('<div class="orbit-timer"><span></span></div>');
      data.$timer = data.$container.find('.orbit-timer > *');
      data.$slides_container = $(slider).addClass('orbit-slides');
      data.$slides = data.$slides_container.children();
      data.$slides_container.append(data.$slides.first().clone());
      data.$slides_container.prepend(data.$slides.last().clone());
      data.$slides = data.$slides_container.children();
      data.$slides_container.css('marginLeft', '-100%');
      data.activeIndex = 1;
      data.self = this;
      this._init_events(data);
      this._init_dimensions(data);
      this._start_timer(data);
    },

    _init_events: function(data) {
      $(window).on('resize', function() {
        data.$slides_container.height('');
        data.$slides_container.height(data.$slides_container.height(data.$container.height()));
      });
      data.$container.on('click', '[data-orbit-prev]', function(e) {
        e.preventDefault();
        data.$container.trigger('timer:stop');
        data.self.goto(data, 'prev');
      });
      data.$container.on('click', '[data-orbit-next]', function(e) {
        e.preventDefault();
        data.$container.trigger('timer:stop');
        data.self.goto(data, 'next');
      });
    },

    _init_dimensions: function(data) {
      data.$slides_container.css('width', data.$slides.length * 100 + '%');
      data.$slides.css('width', 100 / data.$slides.length + '%');
      data.$slides_container.height(data.$container.height());
      data.$slides_container.css('width', data.$slides.length * 100 + '%');
    },

    _start_timer: function(data) {
      data.$container.timer(data.self.settings.timer);
      data.$container.on('timer:complete', function() {
        data.$container.unbind('timer:complete');
        data.$timer.css('width', '100%');
        data.self.goto(data, 'next', function() {
          data.self._start_timer(data);
        });
      });
      data.$container.on('timer:progress', function(e) {
        data.$timer.css('width', e.data[0] * 100 + '%');
      });
      data.$container.trigger('timer:start');
    },

    goto: function(data, index_or_direction, callback) {
      if (index_or_direction === 'prev') {
        if (data.activeIndex === 0) {
          data.activeIndex = data.$slides.length - 1;
        }
        else {
          data.activeIndex--;
        }<commit_msg>clear width on timer started<commit_after>;(function ($, window, document, undefined) {
  'use strict';

  $.fn.timer = function(time_in_ms) {
    var INTERVAL_TIME = 250,
        time = time_in_ms,
        timer,
        start,
        stopped = false,
        $el = this;

    this.stop = function() {
      clearInterval(timer);
      stopped = true;
      $el.trigger('timer:stopped');
      time = time - (new Date().getTime() - start);
    };

    this.start = function() {
      clearInterval(timer);
      start = new Date().getTime();      
      if (stopped) {
        $el.trigger('timer:resumed');
      } else {
        $el.trigger('timer:started');
      }
      timer = setInterval(function() {
        var now = time - (new Date().getTime() - start);
        if (now <= 0) {
          clearInterval(timer);
          stopped = false;
          $el.trigger('timer:complete');
          $el.unbind('timer:progress');
          $el.unbind('timer:complete');
          $el.unbind('timer:start');
          $el.unbind('timer:stop');
        } else {
          var progress_percent = (time-now)/time;
          progress_percent = Math.ceil(progress_percent*100) + '%';
          $el.trigger('timer:progress', [progress_percent])
        }
      }, INTERVAL_TIME);
    };

    $el.bind('timer:start', this.start);
    $el.bind('timer:stop', this.stop);

    return this;
  };

  Foundation.libs = Foundation.libs || {};

  Foundation.libs.orbit = {
    version: '4.0.0.alpha',

    settings: {
      timer: 1500,
      slide_delay: 1500
    },

    init: function(scope, method, options) {
      var self = this;
      $('[data-orbit]', scope).each($.proxy(self._init, self));
    },

    _init: function(idx, slider) {
      var data = {};
      data.$container = $(slider).wrap('<div class="orbit-container"></div>').parent();
      data.$container.append('<a data-orbit-prev href="#">Prev</a>');
      data.$container.append('<a data-orbit-next href="#">Next</a>');
      data.$container.append('<div class="orbit-timer"><span></span></div>');
      data.$timer = data.$container.find('.orbit-timer > *');
      data.$slides_container = $(slider).addClass('orbit-slides');
      data.$slides = data.$slides_container.children();
      data.$slides_container.append(data.$slides.first().clone());
      data.$slides_container.prepend(data.$slides.last().clone());
      data.$slides = data.$slides_container.children();
      data.$slides_container.css('marginLeft', '-100%');
      data.activeIndex = 1;
      data.self = this;
      this._init_events(data);
      this._init_dimensions(data);
      this._start_timer(data);
    },

    _init_events: function(data) {
      $(window).on('resize', function() {
        data.$slides_container.height('');
        data.$slides_container.height(data.$slides_container.height(data.$container.height()));
      });
      data.$container.on('click', '[data-orbit-prev]', function(e) {
        e.preventDefault();
        data.$container.trigger('timer:stop');
        data.self.goto(data, 'prev');
      });
      data.$container.on('click', '[data-orbit-next]', function(e) {
        e.preventDefault();
        data.$container.trigger('timer:stop');
        data.self.goto(data, 'next');
      });
      data.$container.on('timer:started', function(e) {
        data.$timer.css('width', '0%');
      });
    },

    _init_dimensions: function(data) {
      data.$slides_container.css('width', data.$slides.length * 100 + '%');
      data.$slides.css('width', 100 / data.$slides.length + '%');
      data.$slides_container.height(data.$container.height());
      data.$slides_container.css('width', data.$slides.length * 100 + '%');
    },

    _start_timer: function(data) {
      data.$container.timer(data.self.settings.timer);
      data.$container.on('timer:complete', function() {
        data.$container.unbind('timer:complete');
        data.$timer.css('width', '100%');
        data.self.goto(data, 'next', function() {
          data.self._start_timer(data);
        });
      });
      data.$container.on('timer:progress', function(e) {
        data.$timer.css('width', e.data[0]);
      });
      data.$container.trigger('timer:start');
    },

    goto: function(data, index_or_direction, callback) {
      if (data.$container.hasClass("orbit-transitioning")) {
        console.info('is transitioning');
        return false;
      }
      if (index_or_direction === 'prev') {
        if (data.activeIndex === 0) {
          data.activeIndex = data.$slides.length - 1;
        }
        else {
          data.activeIndex--;
        }
{'fraction_non_alphanumeric': 0.18907611853573503, 'fraction_numerical': 0.008599651365485184, 'mean_word_length': 2.581356637536413, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '2742825', 'n_tokens_mistral': 2736, 'n_tokens_neox': 2613, 'n_words': 386}