<commit_before>$(function () {

  var duration = $('#duration');
  var animationDuration = initialDuration = duration.val();

  // The code in these are deliberately using some weird formatting.  The code
  // within gets used as a string.  Like magic!
  Tweenable.prototype.formula.customEase1 =
      function (x) {return Math.pow(x, 4)};

  Tweenable.prototype.formula.customEase2 =
      function (x) {return Math.pow(x, 0.25)};

  function getFormulaFromEasingFunc (fn) {
    var fnString = fn.toString(); // An f'n string
    var indexOfReturn = fnString.indexOf('return');
    var deprefixed = fnString.slice(indexOfReturn + 7);
    var desuffixed = deprefixed.replace(/\}$/, '');
    return desuffixed;
  }

  var PRERENDER_GRANULARITY = 100;
  function generatePathPoints (x1, y1, x2, y2, easeX, easeY) {
    var points = [];
    var from = {
        'x': x1
        ,'y': y1
      };
    var to = {
        'x': x2
        ,'y': y2
      };
    var easing = {
      'x': easeX
      ,'y': easeY
    };
    var i, point;
    for (i = 0; i <= PRERENDER_GRANULARITY; i++) {
      point = Tweenable.util.interpolate(
          from, to, (1 / PRERENDER_GRANULARITY) * i, easing);
      points.push(point);
    }

    return points;
  }

  var prerenderedPath;
  function generatePathPrerender (x1, y1, x2, y2, easeX, easeY) {
    prerenderedPath = document.createElement('canvas');
    prerenderedPath.width = kapi.canvas_width();
    prerenderedPath.height = kapi.canvas_height();
    var ctx = prerenderedPath.ctx = prerenderedPath.getContext('2d');
    var points = generatePathPoints.apply(this, arguments);

    var previousPoint;
    ctx.beginPath();
    _.each(points, function (point) {
      if (previousPoint) {
        ctx.lineTo(point.x, point.y);
      } else {
        ctx.moveTo(point.x, point.y);
      }

      previousPoint = point;
    });
    ctx.lineWidth = 1;
    ctx.strokeStyle = '#fa0';
    ctx.stroke();
    ctx.closePath();
  }

  var ease = $('.ease');
  ease.on('keyup', function (evt) {
    var el = $(evt.target);
    var val = el.val();
    var easename = el.data('easename');
    var lastValid = el.data('lastvalidfn');

    try {
      eval('Tweenable.prototype.formula.' + easename
          + ' = function (x) {return ' + val + '}');
      el.data('lastvalidfn', val);
      el.removeClass('error');
      kapi.canvas_clear();
      updatePath();
    } catch (ex) {
      eval('Tweenable.prototype.formula.' + easename
          + ' = function (x) {return ' + lastValid + '}');
      el.addClass('error');
    }
  });

  ease.each(function (i, el) {
    el = $(el);
    var easename = el.data('easename');
    var fnString = Tweenable.prototype.formula[easename];
    el.val(getFormulaFromEasingFunc(fnString));
    el.data('lastvalidfn', fnString);
  });
<commit_msg>Fixed a custom easing bug in the easing app.<commit_after>$(function () {

  var duration = $('#duration');
  var animationDuration = initialDuration = duration.val();

  // The code in these are deliberately using some weird formatting.  The code
  // within gets used as a string.  Like magic!
  Tweenable.prototype.formula.customEase1 =
      function (x) {return Math.pow(x, 4)};

  Tweenable.prototype.formula.customEase2 =
      function (x) {return Math.pow(x, 0.25)};

  function getFormulaFromEasingFunc (fn) {
    var fnString = fn.toString(); // An f'n string
    var indexOfReturn = fnString.indexOf('return');
    var deprefixed = fnString.slice(indexOfReturn + 7);
    var desuffixed = deprefixed.replace(/\}$/, '');
    return desuffixed;
  }

  var PRERENDER_GRANULARITY = 100;
  function generatePathPoints (x1, y1, x2, y2, easeX, easeY) {
    var points = [];
    var from = {
        'x': x1
        ,'y': y1
      };
    var to = {
        'x': x2
        ,'y': y2
      };
    var easing = {
      'x': easeX
      ,'y': easeY
    };
    var i, point;
    for (i = 0; i <= PRERENDER_GRANULARITY; i++) {
      point = Tweenable.util.interpolate(
          from, to, (1 / PRERENDER_GRANULARITY) * i, easing);
      points.push(point);
    }

    return points;
  }

  var prerenderedPath;
  function generatePathPrerender (x1, y1, x2, y2, easeX, easeY) {
    prerenderedPath = document.createElement('canvas');
    prerenderedPath.width = kapi.canvas_width();
    prerenderedPath.height = kapi.canvas_height();
    var ctx = prerenderedPath.ctx = prerenderedPath.getContext('2d');
    var points = generatePathPoints.apply(this, arguments);

    var previousPoint;
    ctx.beginPath();
    _.each(points, function (point) {
      if (previousPoint) {
        ctx.lineTo(point.x, point.y);
      } else {
        ctx.moveTo(point.x, point.y);
      }

      previousPoint = point;
    });
    ctx.lineWidth = 1;
    ctx.strokeStyle = '#fa0';
    ctx.stroke();
    ctx.closePath();
  }

  var ease = $('.ease');
  ease.on('keyup', function (evt) {
    var el = $(evt.target);
    var val = el.val();
    var easename = el.data('easename');
    var lastValid = el.data('lastvalidfn');

    if (lastValid === val) {
      return;
    }

    try {
      eval('Tweenable.prototype.formula.' + easename
          + ' = function (x) {return ' + val + '}');
      el.data('lastvalidfn', val);
      el.removeClass('error');
      kapi.canvas_clear();
      updatePath();
    } catch (ex) {
      eval('Tweenable.prototype.formula.' + easename
          + ' = function (x) {return ' + lastValid + '}');
      el.addClass('error');
    }
  });

  ease.each(function (i, el) {
    el = $(el);
    var easename = el.data('easename');
    var fn = Tweenable.prototype.formula[easename];
    var fnString = getFormulaFromEasingFunc(fn);
    el.val(fnString);
    el.data('lastvalidfn', fnString);
  });

{'fraction_non_alphanumeric': 0.15202939118264522, 'fraction_numerical': 0.009447165850244927, 'mean_word_length': 2.622940430925222, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4636645', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1910, 'n_words': 435}