<commit_before>'user strict';

var flo = function (canvas, position) {

  var floObject = {
    animations: {},
    requestAnimationFrame: function (func) {
      var requestAnimationFrame = window.requestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.webkitRequestAnimationFrame ||
      window.msRequestAnimationFrame;
      requestAnimationFrame(func);
    },
    isFullscreen: function () {
      return document.fullscreenElement ||
        document.msFullscreenElement ||
        document.mozFullScreenElement ||
        document.webkitFullscreenElement;
    },
    enterFullscreen: function (element) {
      if (element.requestFullscreen) {
        element.requestFullscreen();
      } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
      } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
      } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
      }
    },
    exitFullscreen: function () {
      if (document.exitFullscreen) {
        document.exitFullscreen();
      } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
      } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
      }
    },
    onDocumentReady: function (func) {
      var domContentLoaded = false;
      var runFunction = function () {
        if (!domContentLoaded) {
          domContentLoaded = true;
          func();
        }
      };
      if (document.addEventListener) {
        document.addEventListener("DOMContentLoaded", runFunction, false);
      }
      if (document.attachEvent) {
        document.attachEvent("onreadystatechange", runFunction);
      }
      document.onload = runFunction;
    }
  };

  floObject.position = position;
  floObject.canvas = canvas;

  floObject.addAnimation = function (name, nextPosition, previousPosition, onComplete) {
    floObject.aniimations[name] = {};
    floObject.aniimations[name].nextPosition = nextPosition;
    floObject.aniimations[name].previousPosition = function () {
      var position = {};
      if (previousPosition) {
        for (key in floObject.position) {
          position[key] = previousPosition[key] || position[key];
        }
        return position;
      }
      for (key in floObject.position) {
        position[key] = position[key];
      }
      return position;
    };
    floObject.onComplete = onComplete;
  };

  floObject.doAnimation = function (name, duration) {
    floObject.duration = duration;
    floObject.currentAnimation = name;
  };

  floObject.animate = function () {
    if (floObject.currentAnimation) {

    }
  };

  return floObject;

};
<commit_msg>Refactor of adding & running animations<commit_after>'user strict';

var flo = function (canvas, position) {

  var floObject = {
    animations: {},
    requestAnimationFrame: function (func) {
      var requestAnimationFrame = window.requestAnimationFrame ||
      window.mozRequestAnimationFrame ||
      window.webkitRequestAnimationFrame ||
      window.msRequestAnimationFrame;
      requestAnimationFrame(func);
    },
    isFullscreen: function () {
      return document.fullscreenElement ||
        document.msFullscreenElement ||
        document.mozFullScreenElement ||
        document.webkitFullscreenElement;
    },
    enterFullscreen: function (element) {
      if (element.requestFullscreen) {
        element.requestFullscreen();
      } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
      } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
      } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
      }
    },
    exitFullscreen: function () {
      if (document.exitFullscreen) {
        document.exitFullscreen();
      } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
      } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
      }
    },
    onDocumentReady: function (func) {
      var domContentLoaded = false;
      var runFunction = function () {
        if (!domContentLoaded) {
          domContentLoaded = true;
          func();
        }
      };
      if (document.addEventListener) {
        document.addEventListener("DOMContentLoaded", runFunction, false);
      }
      if (document.attachEvent) {
        document.attachEvent("onreadystatechange", runFunction);
      }
      document.onload = runFunction;
    }
  };

  floObject.position = position;
  floObject.canvas = canvas;

  floObject.addAnimation = function (name, duration, nextPosition, previousPosition, onComplete) {
    floObject.animations[name] = {};
    floObject.animations[name].duration = duration;
    floObject.animations[name].nextPosition = nextPosition;
    floObject.animations[name].previousPosition = previousPosition;
    floObject.animations[name].onComplete = onComplete;
  };

  floObject.doAnimation = function (name, duration, onComplete) {
    if (name === undefined) {
      floObject.currentAnimation === undefined;
    } else {
      floObject.startTime = new Date().getTime();
      floObject.currentAnimation = name;
      floObject.duration = duration || floObject.animations[name] ? floObject.animations[name].duration : undefined;
      floObject.animations[name].onComplete = onComplete || floObject.animations[name] ? floObject.animations[name].onComplete : undefined;

      floObject.previousPosition = function () {
        var newPosition = {};
        var animation = floObject.animations[name];
        if (animation.previousPosition) {
          for (key in floObject.position) {
            newPosition[key] = animation.previousPosition[key] ? animation.previousPosition[key] : floObject.position[key];
          }
          return newPosition;
        }
        for (key in floObject.position) {
          newPosition[key] = floObject.position[key];
        }
        return newPosition;
      }();
    }
  };

  floObject.animate = function () {
    var multiplier = Math.min((new Date().getTime() - floObject.startTime) / floObject.duration, 1);

    if (floObject.currentAnimation) {
      var animation = floObject.animations[floObject.currentAnimation];

      for (key in animation.nextPosition) {
        floObject.position[key] = animation.nextPosition[key] * multiplier + floObject.previousPosition[key] * (1 - multiplier);
      }

      if (multiplier === 1) {
        floObject.doAnimation(animation.onComplete);
      }
    }
  };

  return floObject;

};

{'fraction_non_alphanumeric': 0.10813199764289923, 'fraction_numerical': 0.00044195639363582795, 'mean_word_length': 2.8838672768878717, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5942572', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1786, 'n_words': 333}