<commit_before>(function() {

   var ChildProcess = require('child_process');

   /**
    * Git handling for node. All public functions can be chained and all `then` handlers are optional.
    *
    * @param {String} baseDir
    * @constructor
    */
   function Git(baseDir) {
      this._baseDir = baseDir;
      this._runCache = [];
   }

   /**
    * Initalize a git repo
    *
    * @param {Function} [then]
    */
   Git.prototype.init = function(then) {
      return this._run('git init', function(err) {
         then && then(err);
      });
   };

   /**
    * Clone a git repo
    *
    * @param {String} repoPath
    * @param {String} localPath
    * @param {Function} [then]
    */
   Git.prototype.clone = function(repoPath, localPath, then ) {
      return this._run('git clone ' + repoPath + ' ' + localPath, function(err) {
         then && then(err);
      });
   };

   /**
    * Internally uses pull and tags to get the list of tags then checks out the latest tag.
    *
    * @param {Function} [then]
    */
   Git.prototype.checkoutLatestTag = function(then) {
      var git = this;
      return this.pull().tags(function(err, tags) {
         git.checkout(tags.latest, then);
      });
   };

   /**
    * Adds one or more files to source control
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.add = function(files, then) {
      return this._run('git add "' + [].concat(files).join('" "') + '"', function(err, data) {
         then && then(err);
      });
   };

   /**
    * Commits changes in the current working directory - when specific file paths are supplied, only changes on those
    * files will be committed.
    *
    * @param {String} message
    * @param {String|String[]} [files]
    * @param {Function} [then]
    */
   Git.prototype.commit = function(message, files, then) {
      var git = this;
      if(!then && typeof files === "function") {
         then = files;
         files = [];
      }

      files = files ? ' "' + [].concat(files).join('" "') + '"' : '';

      return this._run('git commit -m "' + message.replace(/"/g, '\\"') + '"' + files, function(err, data) {
         then && then(err, !err && git._parseCommit(data));
      });
   };

   /**
    * Pull the updated contents of the current repo
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.pull = function(remote, branch, then) {
      var command = "git pull";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePull(data));
      });
   };

   /**
    * Fetch the updated contents of the current repo.
    *
    * @example
    *   .fetch('upstream', 'master') // fetches from master on remote named upstream
    *   .fetch(function () {}) // runs fetch against default remote and branch and calls function
    *
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.fetch = function(remote, branch, then) {
      var command = "git fetch";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePush(data));
      });
   };

   /**
    * List all tags
    *
    * @param {Function} [then]
    */
   Git.prototype.tags = function(then) {
      return this._run('git tag -l', function(err, data) {
         then && then(err, !err && this._parseListTags(data));
      });
   };

   /**
    * Check out a tag or revision
    *
    * @param {String} what
    * @param {Function} [then]
    */
   Git.prototype.checkout = function(what, then) {
      return this._run('git checkout "' + what + '"', function(err, data) {
         then && then(err, !err && this._parseCheckout(data));
      });
   };

   /**
    * Check out a remote branch
    *
    * @param {String} name of branch
    * @param {String} what
    * @param {Function} [then]
    */
   Git.prototype.checkoutBranch = function(name, what, then) {
      return this._run('git checkout -b "' +  name + '" "' + what + '"', function(err, data) {
         then && then(err, !err && this._parseCheckout(data));
      });
   };

   /**
    * Add a submodule
    *
    * @param {String} repo
    * @param {String} path
    * @param {Function} [then]
    */
   Git.prototype.submoduleAdd = function(repo, path, then) {
      return this._run('git submodule add "' + repo + '" "' + path + '"', function(err) {
         then && then(err);
      });
   };

   /**
    * List remote
    *
    * @param {String} [args]
    * @param {Function} [then]
    */
   Git.prototype.listRemote = function(args, then) {
      if (!then && typeof args === "function") {
         then = args;
         args = '';
      }
      return this._run('git ls-remote ' + args, function(err, data) {
         then && then(err, data);
      });
   };

   /**
    * Adds a remote to the list of remotes.
    *
    * @param {String} remoteName Name of the repository - eg "upstream"
    * @param {String} remoteRepo Fully qualified SSH or HTTP(S) path to the remote repo
    * @param {Function} [then]
    * @returns {*}
    */
   Git.prototype.addRemote = function(remoteName, remoteRepo, then) {
      return this._run('git remote add "' + remoteName + '" "' + remoteRepo + '"', function (err) {
         then && then(err);
      });
   };

   /**
    * Removes an entry from the list of remotes.
    *
    * @param {String} remoteName Name of the repository - eg "upstream"
    * @param {Function} [then]
    * @returns {*}
    */
   Git.prototype.removeRemote = function(remoteName, then) {
      return this._run('git remote remove "' + remoteName + '"', function (err) {
         then && then(err);
      });
   };

   /**
    * Pushes the current committed changes to a remote, optionally specify the names of the remote and branch to use
    * when pushing.
    *
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.push = function(remote, branch, then) {
      var command = "git push";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePush(data));
      });
   };

   /**
    * Removes the named files from source control.
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.rm = function(files, then) {
      return this._rm(files, '-f', then);
   };

   /**
    * Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
    * completely remove the files, use `rm`.
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.rmKeepLocal = function(files, then) {
      return this._rm(files, '--cached', then);
   };

   /**
    * Return repository changes.
    *
    * @param {String} [options]
    * @param {Function} [then]
    */
   Git.prototype.diff = function(options, then) {
      var command = 'git diff';

      if (typeof options === 'string' && typeof then === 'function') {
         command += ' ' + options;
      }

      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, data);
      });
   };

   Git.prototype._rm = function(files, options, then) {
      return this._run('git rm ' + options + ' "' + [].concat(files).join('" "') + '"', function(err) {
         then && then(err);
      });
   };

   Git.prototype._parsePull = function(pull) {
      var changes = {
         files: [],
         insertions: {},
         deletions: {},
         summary: {
            changes: 0,
            insertions: 0,
            deletions: 0
         }
      };

      var fileUpdateRegex = /^\s*(.+)\s\|\s(\d+)\s([\+]+)/;
      for(var lines = pull.split('\n'), i = 0, l = lines.length; i < l; i++) {
         var update = fileUpdateRegex.exec(lines[i]);

         // search for update statement for each file
         if(update) {
            changes.files.push(update[1]);

            var insertions = update[3].length;
            if(insertions) {
               changes.insertions[update[1]] = insertions;
            }
            if(update[2] > insertions) {
               changes.deletions[update[1]] = update[2] - insertions;
            }
         }

         // summary appears after updates
         else if(changes.files.length && (update = /(\d+)\D+(\d+)\D+(\d+)/.exec(lines[i]))) {
            changes.summary.changes = +update[1];
            changes.summary.insertions = +update[2];
            changes.summary.deletions = +update[3];
         }
      }

      return changes;
   };

   Git.prototype._parseListTags = function(tags) {
      var tagList = tags.split('\n').sort(function(tagA, tagB) {
         var partsA = tagA.split('.');
         var partsB = tagB.split('.');

         for(var i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
            var diff = partsA[i] - partsB[i];
            if(diff) {
               return diff > 0 ? 1 : -1;
            }
         }

         return 0;
      });

      return {
         latest: tagList.length && tagList[tagList.length - 1],
         all: tagList
      };
   };

   Git.prototype._parseCommit = function(commit) {
      var lines = commit.trim().split('\n');
      var branch = /\[([^\s]+) ([^\]]+)/.exec(lines.shift());
      var summary = /(\d+)[^,]*(?:,\s*(\d+)[^,]*)?(?:,\s*(\d+))?/g.exec(lines.shift()) || [];

      return {
         branch: branch[1],
         commit: branch[2],
         summary: {
            changes: (typeof summary[1] !== 'undefined') ? summary[1] : 0,
            insertions: (typeof summary[2] !== 'undefined') ? summary[2] : 0,
            deletions: (typeof summary[3] !== 'undefined') ? summary[3] : 0
         }
      };
   };

   Git.prototype._parseCheckout = function(checkout) {
      // TODO
   };

   Git.prototype._parseFetch = function(fetch) {
      return data;
   };

   Git.prototype._run = function(command, then) {
      this._runCache.push([command, then]);
      this._schedule();

      return this;
   };

   Git.prototype._schedule = function() {
      if(!this._childProcess && this._runCache.length) {
         var task = this._runCache.shift();
         var command = task[0];
         var then = task[1];

         this._childProcess = ChildProcess.exec(
             command,
             {cwd: this._baseDir},
             function(err, stdout, stderr) {
                delete this._childProcess;

                if(err) {
                   console.error(stderr);
                   this._runCache = [];
                   then.call(this, err, null);
                }
                else {
                   then.call(this, null, stdout);
                }

                process.nextTick(this._schedule.bind(this));
             }.bind(this));
      }
   };

   module.exports = function(baseDir) {
      return new Git(baseDir || process.cwd());
   };

}());
<commit_msg>Improve the argument names for checkout branch function<commit_after>(function() {

   var ChildProcess = require('child_process');

   /**
    * Git handling for node. All public functions can be chained and all `then` handlers are optional.
    *
    * @param {String} baseDir
    * @constructor
    */
   function Git(baseDir) {
      this._baseDir = baseDir;
      this._runCache = [];
   }

   /**
    * Initalize a git repo
    *
    * @param {Function} [then]
    */
   Git.prototype.init = function(then) {
      return this._run('git init', function(err) {
         then && then(err);
      });
   };

   /**
    * Clone a git repo
    *
    * @param {String} repoPath
    * @param {String} localPath
    * @param {Function} [then]
    */
   Git.prototype.clone = function(repoPath, localPath, then ) {
      return this._run('git clone ' + repoPath + ' ' + localPath, function(err) {
         then && then(err);
      });
   };

   /**
    * Internally uses pull and tags to get the list of tags then checks out the latest tag.
    *
    * @param {Function} [then]
    */
   Git.prototype.checkoutLatestTag = function(then) {
      var git = this;
      return this.pull().tags(function(err, tags) {
         git.checkout(tags.latest, then);
      });
   };

   /**
    * Adds one or more files to source control
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.add = function(files, then) {
      return this._run('git add "' + [].concat(files).join('" "') + '"', function(err, data) {
         then && then(err);
      });
   };

   /**
    * Commits changes in the current working directory - when specific file paths are supplied, only changes on those
    * files will be committed.
    *
    * @param {String} message
    * @param {String|String[]} [files]
    * @param {Function} [then]
    */
   Git.prototype.commit = function(message, files, then) {
      var git = this;
      if(!then && typeof files === "function") {
         then = files;
         files = [];
      }

      files = files ? ' "' + [].concat(files).join('" "') + '"' : '';

      return this._run('git commit -m "' + message.replace(/"/g, '\\"') + '"' + files, function(err, data) {
         then && then(err, !err && git._parseCommit(data));
      });
   };

   /**
    * Pull the updated contents of the current repo
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.pull = function(remote, branch, then) {
      var command = "git pull";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePull(data));
      });
   };

   /**
    * Fetch the updated contents of the current repo.
    *
    * @example
    *   .fetch('upstream', 'master') // fetches from master on remote named upstream
    *   .fetch(function () {}) // runs fetch against default remote and branch and calls function
    *
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.fetch = function(remote, branch, then) {
      var command = "git fetch";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePush(data));
      });
   };

   /**
    * List all tags
    *
    * @param {Function} [then]
    */
   Git.prototype.tags = function(then) {
      return this._run('git tag -l', function(err, data) {
         then && then(err, !err && this._parseListTags(data));
      });
   };

   /**
    * Check out a tag or revision
    *
    * @param {String} what
    * @param {Function} [then]
    */
   Git.prototype.checkout = function(what, then) {
      return this._run('git checkout "' + what + '"', function(err, data) {
         then && then(err, !err && this._parseCheckout(data));
      });
   };

   /**
    * Check out a remote branch
    *
    * @param {String} name of branch
    * @param {String} start point(e.g origin/development)
    * @param {Function} [then]
    */
   Git.prototype.checkoutBranch = function(branchName, startPoint, then) {
      return this._run('git checkout -b "' +  branchName + '" "' + startPoint + '"', function(err, data) {
         then && then(err, !err && this._parseCheckout(data));
      });
   };

   /**
    * Add a submodule
    *
    * @param {String} repo
    * @param {String} path
    * @param {Function} [then]
    */
   Git.prototype.submoduleAdd = function(repo, path, then) {
      return this._run('git submodule add "' + repo + '" "' + path + '"', function(err) {
         then && then(err);
      });
   };

   /**
    * List remote
    *
    * @param {String} [args]
    * @param {Function} [then]
    */
   Git.prototype.listRemote = function(args, then) {
      if (!then && typeof args === "function") {
         then = args;
         args = '';
      }
      return this._run('git ls-remote ' + args, function(err, data) {
         then && then(err, data);
      });
   };

   /**
    * Adds a remote to the list of remotes.
    *
    * @param {String} remoteName Name of the repository - eg "upstream"
    * @param {String} remoteRepo Fully qualified SSH or HTTP(S) path to the remote repo
    * @param {Function} [then]
    * @returns {*}
    */
   Git.prototype.addRemote = function(remoteName, remoteRepo, then) {
      return this._run('git remote add "' + remoteName + '" "' + remoteRepo + '"', function (err) {
         then && then(err);
      });
   };

   /**
    * Removes an entry from the list of remotes.
    *
    * @param {String} remoteName Name of the repository - eg "upstream"
    * @param {Function} [then]
    * @returns {*}
    */
   Git.prototype.removeRemote = function(remoteName, then) {
      return this._run('git remote remove "' + remoteName + '"', function (err) {
         then && then(err);
      });
   };

   /**
    * Pushes the current committed changes to a remote, optionally specify the names of the remote and branch to use
    * when pushing.
    *
    * @param {String} [remote]
    * @param {String} [branch]
    * @param {Function} [then]
    */
   Git.prototype.push = function(remote, branch, then) {
      var command = "git push";
      if (typeof remote === 'string' && typeof branch === 'string') {
         command += ' "' + remote + '" "' + branch + '"';
      }
      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, !err && this._parsePush(data));
      });
   };

   /**
    * Removes the named files from source control.
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.rm = function(files, then) {
      return this._rm(files, '-f', then);
   };

   /**
    * Removes the named files from source control but keeps them on disk rather than deleting them entirely. To
    * completely remove the files, use `rm`.
    *
    * @param {String|String[]} files
    * @param {Function} [then]
    */
   Git.prototype.rmKeepLocal = function(files, then) {
      return this._rm(files, '--cached', then);
   };

   /**
    * Return repository changes.
    *
    * @param {String} [options]
    * @param {Function} [then]
    */
   Git.prototype.diff = function(options, then) {
      var command = 'git diff';

      if (typeof options === 'string' && typeof then === 'function') {
         command += ' ' + options;
      }

      if (typeof arguments[arguments.length - 1] === 'function') {
         then = arguments[arguments.length - 1];
      }

      return this._run(command, function(err, data) {
         then && then(err, data);
      });
   };

   Git.prototype._rm = function(files, options, then) {
      return this._run('git rm ' + options + ' "' + [].concat(files).join('" "') + '"', function(err) {
         then && then(err);
      });
   };

   Git.prototype._parsePull = function(pull) {
      var changes = {
         files: [],
         insertions: {},
         deletions: {},
         summary: {
            changes: 0,
            insertions: 0,
            deletions: 0
         }
      };

      var fileUpdateRegex = /^\s*(.+)\s\|\s(\d+)\s([\+]+)/;
      for(var lines = pull.split('\n'), i = 0, l = lines.length; i < l; i++) {
         var update = fileUpdateRegex.exec(lines[i]);

         // search for update statement for each file
         if(update) {
            changes.files.push(update[1]);

            var insertions = update[3].length;
            if(insertions) {
               changes.insertions[update[1]] = insertions;
            }
            if(update[2] > insertions) {
               changes.deletions[update[1]] = update[2] - insertions;
            }
         }

         // summary appears after updates
         else if(changes.files.length && (update = /(\d+)\D+(\d+)\D+(\d+)/.exec(lines[i]))) {
            changes.summary.changes = +update[1];
            changes.summary.insertions = +update[2];
            changes.summary.deletions = +update[3];
         }
      }

      return changes;
   };

   Git.prototype._parseListTags = function(tags) {
      var tagList = tags.split('\n').sort(function(tagA, tagB) {
         var partsA = tagA.split('.');
         var partsB = tagB.split('.');

         for(var i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
            var diff = partsA[i] - partsB[i];
            if(diff) {
               return diff > 0 ? 1 : -1;
            }
         }

         return 0;
      });

      return {
         latest: tagList.length && tagList[tagList.length - 1],
         all: tagList
      };
   };

   Git.prototype._parseCommit = function(commit) {
      var lines = commit.trim().split('\n');
      var branch = /\[([^\s]+) ([^\]]+)/.exec(lines.shift());
      var summary = /(\d+)[^,]*(?:,\s*(\d+)[^,]*)?(?:,\s*(\d+))?/g.exec(lines.shift()) || [];

      return {
         branch: branch[1],
         commit: branch[2],
         summary: {
            changes: (typeof summary[1] !== 'undefined') ? summary[1] : 0,
            insertions: (typeof summary[2] !== 'undefined') ? summary[2] : 0,
            deletions: (typeof summary[3] !== 'undefined') ? summary[3] : 0
         }
      };
   };

   Git.prototype._parseCheckout = function(checkout) {
      // TODO
   };

   Git.prototype._parseFetch = function(fetch) {
      return data;
   };

   Git.prototype._run = function(command, then) {
      this._runCache.push([command, then]);
      this._schedule();

      return this;
   };

   Git.prototype._schedule = function() {
      if(!this._childProcess && this._runCache.length) {
         var task = this._runCache.shift();
         var command = task[0];
         var then = task[1];

         this._childProcess = ChildProcess.exec(
             command,
             {cwd: this._baseDir},
             function(err, stdout, stderr) {
                delete this._childProcess;

                if(err) {
                   console.error(stderr);
                   this._runCache = [];
                   then.call(this, err, null);
                }
                else {
                   then.call(this, null, stdout);
                }

                process.nextTick(this._schedule.bind(this));
             }.bind(this));
      }
   };

   module.exports = function(baseDir) {
      return new Git(baseDir || process.cwd());
   };

}());
<|endoftext|>


<commit_before>!(function(){
  var width = innerWidth,
      height = innerHeight;

  var canvas = d3.select('#background-canvas').append("canvas")
      .attr({width: width, height: height})

  d3.select(window).on('resize.background', function(){
    width  = innerWidth
    height = innerHeight
    canvas.attr({width: width, height: height})
  })

  var ctx = canvas.node().getContext("2d");

  ctx.fillStyle = '#f94600'
  ctx.fillRect(0, 0, width, height)

  var shapes = [],
      curTime = 0,
      l = 14,
      unload = function(){ shapes = shapes.filter(function(d){ d.start > curTime }) }

  d3.timer(function(t){
    curTime = t

    shapes.forEach(function(s){
      if (t < s.start) return

      var u = (t - s.start)/(s.end - s.start)

      if (u > 1){
        u = 1
        s.done = true
      }

      ctx.fillStyle = s.fill
      if (s.type == 'rect'){
        var a0 = s.sV[0]*(1 - u) + s.eV[0]*u
        var a1 = s.sV[1]*(1 - u) + s.eV[1]*u
        var a2 = s.sV[2]*(1 - u) + s.eV[2]*u
        var a3 = s.sV[3]*(1 - u) + s.eV[3]*u
        ctx.fillRect(a0, a1, a2, a3)
      }
      if (s.type == 'circle'){
        var a0 = s.sV[0]*(1 - u) + s.eV[0]*u
        var a1 = s.sV[1]*(1 - u) + s.eV[1]*u
        var a2 = s.sV[2]*(1 - u) + s.eV[2]*u

        ctx.beginPath()
        ctx.arc(a0, a1, a2, 0, Math.PI*2, true)
        ctx.closePath()
        ctx.fill()
      }
    })

    shapes = shapes.filter(function(s){ return !s.done })
  })

  // wave squares
  !(function(){
    var module = {sel: d3.select('.sectionNum4'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(1, 4)
    var offset = 1

    setInterval(function(){
      if (!module.active) return
      var speed = Math.random()*.0003 + .2
      offset++
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!!((i + j + offset) % 4)) return
          if (Math.random() < .3) return
          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + (i + j)*40*speed + Math.random()*200,
              sV: [x, y, 0, 0],
              eV: [x, y, l, l],
              fill: offset % 10 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 500
          shapes.push(shape)
        })
      })

    }, 800)
  })()
  //sprial squares
  !(function(){
    var module = {sel: d3.select('#background-hook'), active: true, onunload: unload}

    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      return
      if (!module.active) return

      offset++
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!!((i + j + offset) % 2)) return
          if (Math.random() < .3) return

          var d = Math.random() < .5  //shape moves down
          var r = Math.random() < .5  //shape moves left

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + d*1000 + r*1000 + (d && !r)*1000*2 + Math.random()*400,
              sV: [r ? x : x + l, d ? y : y + l, 0, 0],
              eV: [x, y, l, l],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 500
          shapes.push(shape)
        })
      })

    }, 5/4*1000)
  })()

  !(function(){
    var module = {sel: d3.select('#background-hook'), active: true, onunload: unload}

    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var size = Math.random()
      d3.range(0, width + l, l*10).forEach(function(x, i){
        d3.range(0, height + l, l*10).forEach(function(y, j){
          // if (!!((i + j + offset) % 2)) return
          if (Math.random() < .7) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'circle',
              start: curTime + Math.random()*1500,
              sV: [x, y - 200 , 0],
              eV: [x, y, l*3 + size*l*5*size],
              fill: offset % 18 ? colors[((Math.random() < .3) + offset) % 3] : 'white'
            }
          shape.end = shape.start + 1500 + size*400
          shapes.push(shape)
        })
      })

    }, 1500)
  })()

  //circles
  !(function(){
    var module = {sel: d3.select('.sectionNum5'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var size = Math.random()
      d3.range(0, width + l, l*10).forEach(function(x, i){
        d3.range(0, height + l, l*10).forEach(function(y, j){
          // if (!!((i + j + offset) % 2)) return
          // if (Math.random() < .3) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'circle',
              start: curTime + Math.random()*4,
              sV: [x, y, 0],
              eV: [x, y, l*3 + Math.random()*l*5*size],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 1500
          shapes.push(shape)
        })
      })

    }, 1500/2.3)
  })()

  //different sized squares
  !(function(){
    // d3.select('.overlay').style('display', 'none')
    var module = {sel: d3.select('.sectionNum2'), active: false, onunload: unload}
    addModule(module)

    // Object.observe(module, function (changes){
    //   console.log("Changes:");
    //   console.log(changes.name);
    //   if (!module.active) debugger
    // })

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var sizeI = Math.ceil(Math.random()*3.5)
      // size = Math.floor((offset % 2) + Math.random()*2.5)
      // size = offset % 5
      var size = sizeI*sizeI*.8
      d3.range(0, width + l, l*size).forEach(function(x, i){
        d3.range(0, height + l, l*size).forEach(function(y, j){
          if (!!((i + j + sizeI + (Math.random() < .1)) % 2)) return
          if (Math.random() < .3) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + Math.random()*4,
              sV: [x + l*size/2, y + l*size/2, 0, 0],
              eV: [x, y, l*size, l*size],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          if (size > 4) shape.fill = colors[Math.floor(Math.random()*3)]
          shape.end = shape.start +800
          shapes.push(shape)
        })
      })

    }, 1/4*1000)
  })()

  //down wave
  !(function(){
    var module = {sel: d3.select('.sectionNum3'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(2, 5)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      var speed = Math.random()*.5 + .5
      speed = 1
      offset++
      var m = offset % 4
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!((i + j + offset) % 5)) return
          if (Math.random() < .6) return

          var stagger = speed*40 + Math.random()*5
          var start = curTime
          var sV = []
          if        (m == 0){
            start += j*stagger
            sV = [x, y, l, 0]
          } else if (m == 1){
            start += (width /l - i)*stagger
            sV = [x + l, y, 0, l]
          } else if (m == 2){
            start += (height/l - j)*stagger
            sV = [x, y + l, l, 0]
          } else if (m == 3){
            start += i*stagger
            sV = [x, y, 0, l]
          }

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: start,
              sV: sV,
              eV: [x, y, l, l],
              fill: offset % 10 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 200*Math.random()
          shapes.push(shape)
        })
      })

    }, 2000)
  })()

})();

<commit_msg>adds triangles<commit_after>!(function(){
  var width = innerWidth,
      height = innerHeight;

  var canvas = d3.select('#background-canvas').append("canvas")
      .attr({width: width, height: height})

  d3.select(window).on('resize.background', function(){
    width  = innerWidth
    height = innerHeight
    canvas.attr({width: width, height: height})
  })

  var ctx = canvas.node().getContext("2d");

  ctx.fillStyle = '#f94600'
  ctx.fillRect(0, 0, width, height)

  var shapes = [],
      curTime = 0,
      l = 14,
      unload = function(){ shapes = shapes.filter(function(d){ d.start > curTime }) }

  d3.timer(function(t){
    curTime = t

    shapes.forEach(function(s, i){
      if (t < s.start || i > 4000) return

      var u = (t - s.start)/(s.end - s.start)

      if (u > 1){
        u = 1
        s.done = true
      }

      ctx.fillStyle = s.fill
      if (s.type == 'rect'){
        var a0 = s.sV[0]*(1 - u) + s.eV[0]*u
        var a1 = s.sV[1]*(1 - u) + s.eV[1]*u
        var a2 = s.sV[2]*(1 - u) + s.eV[2]*u
        var a3 = s.sV[3]*(1 - u) + s.eV[3]*u
        ctx.fillRect(a0, a1, a2, a3)
      }
      if (s.type == 'circle'){
        var a0 = s.sV[0]*(1 - u) + s.eV[0]*u
        var a1 = s.sV[1]*(1 - u) + s.eV[1]*u
        var a2 = s.sV[2]*(1 - u) + s.eV[2]*u

        ctx.beginPath()
        ctx.arc(a0, a1, a2, 0, Math.PI*2, true)
        ctx.closePath()
        ctx.fill()
      }
      if (s.type == 'triangle'){
        var x0 = s.sV[0]*(1 - u) + s.eV[0]*u
        var y0 = s.sV[1]*(1 - u) + s.eV[1]*u
        var x1 = s.sV[2]*(1 - u) + s.eV[2]*u
        var y1 = s.sV[3]*(1 - u) + s.eV[3]*u
        var x2 = s.sV[4]*(1 - u) + s.eV[4]*u
        var y2 = s.sV[5]*(1 - u) + s.eV[5]*u

        ctx.beginPath()
        ctx.moveTo(x0, y0)
        ctx.lineTo(x1, y1)
        ctx.lineTo(x2, y2)
        ctx.closePath()
        ctx.fill()
      }
    })

    shapes = shapes.filter(function(s){ return !s.done })
  })

  // wave squares
  !(function(){
    var module = {sel: d3.select('.sectionNum4'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(1, 4)
    var offset = 1

    setInterval(function(){
      if (!module.active) return
      var speed = Math.random()*.0003 + .2
      offset++
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!!((i + j + offset) % 4)) return
          if (Math.random() < .3) return
          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + (i + j)*40*speed + Math.random()*200,
              sV: [x, y, 0, 0],
              eV: [x, y, l, l],
              fill: offset % 10 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 500
          shapes.push(shape)
        })
      })

    }, 800)
  })()
  //sprial squares
  !(function(){
    var module = {sel: d3.select('#background-hook'), active: true, onunload: unload}

    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!!((i + j + offset) % 2)) return
          if (Math.random() < .3) return

          var d = Math.random() < .5  //shape moves down
          var r = Math.random() < .5  //shape moves left

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + d*1000 + r*1000 + (d && !r)*1000*2 + Math.random()*400,
              sV: [r ? x : x + l, d ? y : y + l, 0, 0],
              eV: [x, y, l, l],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 500
          shapes.push(shape)
        })
      })

    }, 5/4*1000)
  })()

  //triangles
  !(function(){
    var module = {sel: d3.select('.sectionNum7'), active: false, onunload: unload}

    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      var x0 = Math.cos(Math.PI/6 + Math.PI*6/3)*l*3
      var y0 = Math.sin(Math.PI/6 + Math.PI*6/3)*l*3
      var x1 = Math.cos(Math.PI/6 + Math.PI*2/3)*l*3
      var y1 = Math.sin(Math.PI/6 + Math.PI*2/3)*l*3
      var x2 = Math.cos(Math.PI/6 + Math.PI*4/3)*l*3
      var y2 = Math.sin(Math.PI/6 + Math.PI*4/3)*l*3

      offset++
      d3.range(0, width + l, l*3).forEach(function(x, i){
        d3.range(0, height + l, l*3).forEach(function(y, j){
          // if (!!((i + j + offset) % 2)) return
          if (Math.random() < .9) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'triangle',
              start: curTime + 1000 - j*30,
              sV: [x, y, x, y, x, y],
              eV: [x + x0, y + y0, x + x1, y + y1, x + x2, y + y2],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }

          if (offset % 3 == 0){
            shape.sV[0] += x0
            shape.sV[1] += y0
            shape.sV[2] += x1
            shape.sV[3] += y1
          }
          if (offset % 3 == 1){
            shape.sV[2] += x1
            shape.sV[3] += y1
            shape.sV[4] += x2
            shape.sV[5] += y2

          }
          if (offset % 3 == 2){
            shape.sV[0] += x0
            shape.sV[1] += y0

            shape.sV[4] += x2
            shape.sV[5] += y2
          }
          shape.end = shape.start + 500
          shapes.push(shape)
        })
      })

    }, 1*1000)
  })()

  //tears
  !(function(){
    var module = {sel: d3.select('.sectionNum6'), active: false, onunload: unload}

    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var size = Math.random()
      d3.range(0, width + l, l*10).forEach(function(x, i){
        d3.range(0, height + l, l*10).forEach(function(y, j){
          // if (!!((i + j + offset) % 2)) return
          if (Math.random() < .7) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'circle',
              start: curTime + Math.random()*1500,
              sV: [x, y - 200 , 0],
              eV: [x, y, l*3 + size*l*5*size],
              fill: offset % 18 ? colors[((Math.random() < .3) + offset) % 3] : 'white'
            }
          shape.end = shape.start + 1500 + size*400
          shapes.push(shape)
        })
      })

    }, 1500)
  })()

  //circles
  !(function(){
    var module = {sel: d3.select('.sectionNum5'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var size = Math.random()
      d3.range(0, width + l, l*10).forEach(function(x, i){
        d3.range(0, height + l, l*10).forEach(function(y, j){
          // if (!!((i + j + offset) % 2)) return
          // if (Math.random() < .3) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'circle',
              start: curTime + Math.random()*4,
              sV: [x, y, 0],
              eV: [x, y, l*3 + Math.random()*l*5*size],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 1500
          shapes.push(shape)
        })
      })

    }, 1500/2.3)
  })()

  //different sized squares
  !(function(){
    // d3.select('.overlay').style('display', 'none')
    var module = {sel: d3.select('.sectionNum2'), active: false, onunload: unload}
    addModule(module)

    // Object.observe(module, function (changes){
    //   console.log("Changes:");
    //   console.log(changes.name);
    //   if (!module.active) debugger
    // })

    var colors = colorArray.slice(0, 3)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      offset++
      var sizeI = Math.ceil(Math.random()*3.5)
      // size = Math.floor((offset % 2) + Math.random()*2.5)
      // size = offset % 5
      var size = sizeI*sizeI*.8
      d3.range(0, width + l, l*size).forEach(function(x, i){
        d3.range(0, height + l, l*size).forEach(function(y, j){
          if (!!((i + j + sizeI + (Math.random() < .1)) % 2)) return
          if (Math.random() < .3) return

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: curTime + Math.random()*4,
              sV: [x + l*size/2, y + l*size/2, 0, 0],
              eV: [x, y, l*size, l*size],
              fill: offset % 18 ? colors[offset % 3] : 'white'
            }
          if (size > 4) shape.fill = colors[Math.floor(Math.random()*3)]
          shape.end = shape.start +800
          shapes.push(shape)
        })
      })

    }, 1/4*1000)
  })()

  //down wave
  !(function(){
    var module = {sel: d3.select('.sectionNum3'), active: false, onunload: unload}
    addModule(module)

    var colors = colorArray.slice(2, 5)
    var offset = 1
    setInterval(function(){
      if (!module.active) return

      var speed = Math.random()*.5 + .5
      speed = 1
      offset++
      var m = offset % 4
      d3.range(0, width + l, l).forEach(function(x, i){
        d3.range(0, height + l, l).forEach(function(y, j){
          if (!((i + j + offset) % 5)) return
          if (Math.random() < .6) return

          var stagger = speed*40 + Math.random()*5
          var start = curTime
          var sV = []
          if        (m == 0){
            start += j*stagger
            sV = [x, y, l, 0]
          } else if (m == 1){
            start += (width /l - i)*stagger
            sV = [x + l, y, 0, l]
          } else if (m == 2){
            start += (height/l - j)*stagger
            sV = [x, y + l, l, 0]
          } else if (m == 3){
            start += i*stagger
            sV = [x, y, 0, l]
          }

          var shape =
            { x: x,
              y: y,
              i: i,
              j: j,
              type: 'rect',
              start: start,
              sV: sV,
              eV: [x, y, l, l],
              fill: offset % 10 ? colors[offset % 3] : 'white'
            }
          shape.end = shape.start + 200*Math.random()
          shapes.push(shape)
        })
      })

    }, 2000)
  })()

})();

<|endoftext|>


<commit_before>$.parentController = Alloy.getController('BaseController');

// preLayout() is optional. It's safe to delete.
function preLayout(args) {}

// postLayout() is also optional, but most often all your app
// logic will be contained in this function.
function postLayout(args) {}<commit_msg>default controller stripped down to nothing again<commit_after><|endoftext|>


<commit_before>// namespace
var App = App || {};

App.Flag = (function () {
    "use strict";

    var fn = function (game, x, y, args) {
        Phaser.Sprite.call(this, game, x, y, args.image_key);

        // Create animation linked to this object
        if (args.init) args.init(this, args);

        this.animations.play('wave');

        this.game.physics.arcade.enable(this);

        this.following = null;
    };

    fn.prototype = Object.create(Phaser.Sprite.prototype);
    fn.prototype.constructor = fn;

    fn.prototype.update = function () {
        if (this.game.global.player && ! this.following) {
            if (this.game.physics.arcade.collide(this.game.global.player, this) ) {
                this.following = this.game.global.player;
            }
        }

        if (this.following) {
            this.x = this.following.x;
            this.y = this.following.y;
        }
    };

    return fn;
})();
<commit_msg>Change flag.js to just play any animation instead of hard coding animation_name "wave"<commit_after>// namespace
var App = App || {};

App.Flag = (function () {
    "use strict";

    var fn = function (game, x, y, args) {
        Phaser.Sprite.call(this, game, x, y, args.image_key);

        // Create animation linked to this object
        if (args.init) args.init(this, args);

        // If there exists any animation, then play it.
        var anim = _.keys(this.animations._anims)[0];
        if (anim) this.animations.play(anim);

        this.game.physics.arcade.enable(this);

        this.following = null;
    };

    fn.prototype = Object.create(Phaser.Sprite.prototype);
    fn.prototype.constructor = fn;

    fn.prototype.update = function () {
        if (this.game.global.player && ! this.following) {
            if (this.game.physics.arcade.collide(this.game.global.player, this) ) {
                this.following = this.game.global.player;
            }
        }

        if (this.following) {
            this.x = this.following.x;
            this.y = this.following.y;
        }
    };

    return fn;
})();
<|endoftext|>


<commit_before>// Inspired by https://github.com/airbnb/javascript but less opinionated.

// We use eslint-loader so even warnings are very visibile.
// This is why we only use "WARNING" level for potential errors,
// and we don't use "ERROR" level at all.

// In the future, we might create a separate list of rules for production.
// It would probably be more strict.

var WARNING = 1;

module.exports = {
    root: true,

    parser: 'babel-eslint',

    // import plugin is termporarily disabled, scroll below to see why
    plugins: ['react'/*, 'import'*/, 'jsx-a11y'],

    env: {
        es6: true,
        commonjs: true,
        browser: true
    },

    parserOptions: {
        ecmaVersion: 6,
        sourceType: 'module',
        ecmaFeatures: {
            jsx: true,
            generators: true,
            experimentalObjectRestSpread: true
        }
    },

    settings: {
        'import/ignore': [
            'node_modules',
            '\\.(json|css|jpg|png|gif|eot|svg|ttf|woff|woff2|mp4|webm)$',
        ],
        'import/extensions': ['.js', '.jsx'],
        'import/resolver': {
            node: {
                extensions: ['.js', '.json', '.jsx']
            }
        }
    },

    rules: {
        // http://eslint.org/docs/rules/
        // 'array-callback-return': WARNING,
        'default-case': [WARNING, {commentPattern: '^no default$'}],
        'dot-location': [WARNING, 'property'],
        eqeqeq: [WARNING, 'allow-null'],
        'guard-for-in': WARNING,
        'new-cap': [WARNING, {newIsCap: true}],
        'new-parens': WARNING,
        'no-array-constructor': WARNING,
        'no-caller': WARNING,
        'no-cond-assign': [WARNING, 'always'],
        'no-const-assign': WARNING,
        'no-control-regex': WARNING,
        'no-delete-var': WARNING,
        'no-dupe-args': WARNING,
        'no-dupe-class-members': WARNING,
        'no-dupe-keys': WARNING,
        'no-duplicate-case': WARNING,
        'no-empty-character-class': WARNING,
        'no-empty-pattern': WARNING,
        'no-eval': WARNING,
        'no-ex-assign': WARNING,
        'no-extend-native': WARNING,
        'no-extra-bind': WARNING,
        'no-extra-label': WARNING,
        'no-fallthrough': WARNING,
        'no-func-assign': WARNING,
        'no-implied-eval': WARNING,
        'no-invalid-regexp': WARNING,
        'no-iterator': WARNING,
        'no-label-var': WARNING,
        'no-labels': [WARNING, {allowLoop: false, allowSwitch: false}],
        'no-lone-blocks': WARNING,
        'no-loop-func': WARNING,
        'no-mixed-operators': [WARNING, {
            groups: [
                ['+', '-', '*', '/', '%', '**'],
                ['&', '|', '^', '~', '<<', '>>', '>>>'],
                ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
                ['&&', '||'],
                ['in', 'instanceof']
            ],
            allowSamePrecedence: false
        }],
        'no-multi-str': WARNING,
        'no-native-reassign': WARNING,
        'no-negated-in-lhs': WARNING,
        'no-new-func': WARNING,
        'no-new-object': WARNING,
        'no-new-symbol': WARNING,
        'no-new-wrappers': WARNING,
        'no-obj-calls': WARNING,
        'no-octal': WARNING,
        'no-octal-escape': WARNING,
        'no-redeclare': WARNING,
        'no-regex-spaces': WARNING,
        'no-restricted-syntax': [
            WARNING,
            'LabeledStatement',
            'WithStatement',
        ],
        'no-return-assign': WARNING,
        'no-script-url': WARNING,
        'no-self-assign': WARNING,
        'no-self-compare': WARNING,
        'no-sequences': WARNING,
        'no-shadow-restricted-names': WARNING,
        'no-sparse-arrays': WARNING,
        'no-this-before-super': WARNING,
        'no-throw-literal': WARNING,
        'no-undef': WARNING,
        'no-unexpected-multiline': WARNING,
        'no-unreachable': WARNING,
        'no-unused-expressions': WARNING,
        'no-unused-labels': WARNING,
        'no-unused-vars': [WARNING, {vars: 'local', args: 'none'}],
        'no-use-before-define': [WARNING, 'nofunc'],
        'no-useless-computed-key': WARNING,
        'no-useless-concat': WARNING,
        'no-useless-constructor': WARNING,
        'no-useless-escape': WARNING,
        'no-useless-rename': [WARNING, {
            ignoreDestructuring: false,
            ignoreImport: false,
            ignoreExport: false,
        }],
        'no-with': WARNING,
        'no-whitespace-before-property': WARNING,
        'operator-assignment': [WARNING, 'always'],
        radix: WARNING,
        'require-yield': WARNING,
        'rest-spread-spacing': [WARNING, 'never'],
        strict: [WARNING, 'never'],
        'unicode-bom': [WARNING, 'never'],
        'use-isnan': WARNING,
        'valid-typeof': WARNING,

        // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/

        // TODO: import rules are temporarily disabled because they don't play well
        // with how eslint-loader only checks the file you change. So if module A
        // imports module B, and B is missing a default export, the linter will
        // record this as an issue in module A. Now if you fix module B, the linter
        // will not be aware that it needs to re-lint A as well, so the error
        // will stay until the next restart, which is really confusing.

        // This is probably fixable with a patch to eslint-loader.
        // When file A is saved, we want to invalidate all files that import it
        // *and* that currently have lint errors. This should fix the problem.

        // 'import/default': WARNING,
        // 'import/export': WARNING,
        // 'import/named': WARNING,
        // 'import/namespace': WARNING,
        // 'import/no-amd': WARNING,
        // 'import/no-duplicates': WARNING,
        // 'import/no-extraneous-dependencies': WARNING,
        // 'import/no-named-as-default': WARNING,
        // 'import/no-named-as-default-member': WARNING,
        // 'import/no-unresolved': [WARNING, { commonjs: true }],

        'jsx-quotes': WARNING,
        'jsx-a11y/img-has-alt': WARNING,
        'jsx-a11y/img-redundant-alt': WARNING,
        'jsx-a11y/aria-role': WARNING,
        'jsx-a11y/no-access-key': WARNING,
        // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
        'react/jsx-equals-spacing': [WARNING, 'never'],
        'react/jsx-handler-names': WARNING,
        'react/sort-comp': WARNING,
        'react/jsx-no-duplicate-props': [WARNING, {ignoreCase: true}],
        'react/jsx-no-undef': WARNING,
        'react/jsx-curly-spacing': WARNING,
        'react/jsx-boolean-value': WARNING,
        'react/self-closing-comp': WARNING,
        'react/wrap-multilines': WARNING,
        'react/no-multi-comp': WARNING,
        'react/prefer-es6-class': WARNING,
        'react/prefer-stateless-function': WARNING,
        'react/no-string-refs': WARNING,
        'react/jsx-closing-bracket-location': WARNING,
        'react/jsx-pascal-case': WARNING,
        'react/jsx-uses-react': WARNING,
        'react/jsx-uses-vars': WARNING,
        'react/no-deprecated': WARNING,
        'react/no-direct-mutation-state': WARNING,
        'react/no-is-mounted': WARNING,
        'react/react-in-jsx-scope': WARNING,
        'react/require-render-return': WARNING,
    }
};
<commit_msg>update eslint for better code quality<commit_after>// Inspired by https://github.com/airbnb/javascript but less opinionated.

// We use eslint-loader so even warnings are very visibile.
// This is why we only use "WARNING" level for potential errors,
// and we don't use "ERROR" level at all.

// In the future, we might create a separate list of rules for production.
// It would probably be more strict.

const WARNING = 1;

module.exports = {
    root: true,

    parser: 'babel-eslint',

    // import plugin is termporarily disabled, scroll below to see why
    plugins: ['react'/*, 'import'*/, 'jsx-a11y'],

    env: {
        es6: true,
        commonjs: true,
        browser: true
    },

    parserOptions: {
        ecmaVersion: 6,
        sourceType: 'module',
        ecmaFeatures: {
            jsx: true,
            generators: true,
            experimentalObjectRestSpread: true
        }
    },

    settings: {
        'import/ignore': [
            'node_modules',
            '\\.(json|css|jpg|png|gif|eot|svg|ttf|woff|woff2|mp4|webm)$',
        ],
        'import/extensions': ['.js', '.jsx'],
        'import/resolver': {
            node: {
                extensions: ['.js', '.json', '.jsx']
            }
        }
    },

    rules: {
        // http://eslint.org/docs/rules/
        'array-callback-return': WARNING,
        'arrow-parens': WARNING,
        'arrow-spacing': WARNING,
        'default-case': [WARNING, {commentPattern: '^no default$'}],
        'dot-location': [WARNING, 'property'],
        eqeqeq: [WARNING, 'allow-null'],
        'guard-for-in': WARNING,
        'new-cap': [WARNING, {newIsCap: true}],
        'new-parens': WARNING,
        'no-array-constructor': WARNING,
        'no-caller': WARNING,
        'no-cond-assign': [WARNING, 'always'],
        'no-const-assign': WARNING,
        'no-confusing-arrow': WARNING,
        'no-control-regex': WARNING,
        'no-delete-var': WARNING,
        'no-dupe-args': WARNING,
        'no-dupe-class-members': WARNING,
        'no-dupe-keys': WARNING,
        'no-duplicate-case': WARNING,
        'no-empty-character-class': WARNING,
        'no-empty-pattern': WARNING,
        'no-eval': WARNING,
        'no-ex-assign': WARNING,
        'no-extend-native': WARNING,
        'no-extra-bind': WARNING,
        'no-extra-label': WARNING,
        'no-fallthrough': WARNING,
        'no-func-assign': WARNING,
        'no-implied-eval': WARNING,
        'no-invalid-regexp': WARNING,
        'no-iterator': WARNING,
        'no-label-var': WARNING,
        'no-labels': [WARNING, {allowLoop: false, allowSwitch: false}],
        'no-lone-blocks': WARNING,
        'no-loop-func': WARNING,
        'no-mixed-operators': [WARNING, {
            groups: [
                ['+', '-', '*', '/', '%', '**'],
                ['&', '|', '^', '~', '<<', '>>', '>>>'],
                ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
                ['&&', '||'],
                ['in', 'instanceof']
            ],
            allowSamePrecedence: false
        }],
        'no-multi-str': WARNING,
        'no-native-reassign': WARNING,
        'no-negated-in-lhs': WARNING,
        'no-new-func': WARNING,
        'no-new-object': WARNING,
        'no-new-symbol': WARNING,
        'no-new-wrappers': WARNING,
        'no-obj-calls': WARNING,
        'no-octal': WARNING,
        'no-octal-escape': WARNING,
        'no-param-reassign': WARNING,
        'no-redeclare': WARNING,
        'no-regex-spaces': WARNING,
        'no-restricted-syntax': [
            WARNING,
            'LabeledStatement',
            'WithStatement',
        ],
        'no-return-assign': WARNING,
        'no-script-url': WARNING,
        'no-self-assign': WARNING,
        'no-self-compare': WARNING,
        'no-sequences': WARNING,
        'no-shadow-restricted-names': WARNING,
        'no-sparse-arrays': WARNING,
        'no-this-before-super': WARNING,
        'no-throw-literal': WARNING,
        'no-undef': WARNING,
        'no-unexpected-multiline': WARNING,
        'no-unneeded-ternary': WARNING,
        'no-unreachable': WARNING,
        'no-unused-expressions': WARNING,
        'no-unused-labels': WARNING,
        'no-unused-vars': [WARNING, {vars: 'local', args: 'none'}],
        'no-use-before-define': [WARNING, 'nofunc'],
        'no-useless-computed-key': WARNING,
        'no-useless-concat': WARNING,
        'no-useless-constructor': WARNING,
        'no-useless-escape': WARNING,
        'no-useless-rename': [WARNING, {
            ignoreDestructuring: false,
            ignoreImport: false,
            ignoreExport: false,
        }],
        'no-var': WARNING,
        'no-with': WARNING,
        'no-whitespace-before-property': WARNING,
        'object-shorthand': WARNING,
        'operator-assignment': [WARNING, 'always'],
        radix: WARNING,
        'prefer-arrow-callback': WARNING,
        'prefer-const': WARNING,
        'prefer-spread': WARNING,
        'prefer-template': WARNING,
        'quote-props': [WARNING, "as-needed"],
        'require-yield': WARNING,
        'rest-spread-spacing': [WARNING, 'never'],
        strict: [WARNING, 'never'],
        'unicode-bom': [WARNING, 'never'],
        'use-isnan': WARNING,
        'template-curly-spacing': WARNING,
        'valid-typeof': WARNING,

        // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/

        // TODO: import rules are temporarily disabled because they don't play well
        // with how eslint-loader only checks the file you change. So if module A
        // imports module B, and B is missing a default export, the linter will
        // record this as an issue in module A. Now if you fix module B, the linter
        // will not be aware that it needs to re-lint A as well, so the error
        // will stay until the next restart, which is really confusing.

        // This is probably fixable with a patch to eslint-loader.
        // When file A is saved, we want to invalidate all files that import it
        // *and* that currently have lint errors. This should fix the problem.

        // 'import/default': WARNING,
        // 'import/export': WARNING,
        // 'import/named': WARNING,
        // 'import/namespace': WARNING,
        // 'import/no-amd': WARNING,
        // 'import/no-duplicates': WARNING,
        // 'import/no-extraneous-dependencies': WARNING,
        // 'import/no-named-as-default': WARNING,
        // 'import/no-named-as-default-member': WARNING,
        // 'import/no-unresolved': [WARNING, { commonjs: true }],

        'jsx-quotes': WARNING,
        'jsx-a11y/img-has-alt': WARNING,
        'jsx-a11y/img-redundant-alt': WARNING,
        'jsx-a11y/aria-role': WARNING,
        'jsx-a11y/no-access-key': WARNING,
        // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
        'react/jsx-equals-spacing': [WARNING, 'never'],
        //'react/jsx-handler-names': WARNING,
        'react/sort-comp': WARNING,
        'react/jsx-no-duplicate-props': [WARNING, {ignoreCase: true}],
        'react/jsx-no-undef': WARNING,
        //'react/jsx-no-bind': [WARNING, {ignoreRefs: true, allowArrowFunctions: false, allowBind: false}],
        'react/jsx-curly-spacing': WARNING,
        'react/jsx-boolean-value': WARNING,
        'react/self-closing-comp': WARNING,
        'react/wrap-multilines': WARNING,
        'react/no-direct-mutation-state': WARNING,
        'react/no-multi-comp': WARNING,
        'react/no-unknown-property': WARNING,
        'react/prefer-es6-class': WARNING,
        'react/prefer-stateless-function': WARNING,
        'react/prop-types': WARNING,
        'react/no-string-refs': WARNING,
        'react/jsx-closing-bracket-location': WARNING,
        'react/jsx-pascal-case': WARNING,
        'react/jsx-uses-react': WARNING,
        'react/jsx-uses-vars': WARNING,
        'react/no-deprecated': WARNING,
        'react/no-is-mounted': WARNING,
        'react/react-in-jsx-scope': WARNING,
        'react/require-render-return': WARNING,
    }
};
<|endoftext|>


<commit_before>function destroyPage() {
  setInterval(function() {
    var $el = $('body');
    while($el.children().length > 0) {
      $el = $el.children().eq(0);
    }
    $el.remove();
  },100);
}

function randomize() {
  var selectors = ["h1", "h2", "p"];
  var properties = [
    {
      "name": "background",
      "values": ["none", "#d5cdfb", "#fdc8d8", "#fae665", "#fbba7d", "#94e1bb"]
    },
    {
      "name": "font-family",
      "values": ["helvetica, arial", "garamond", "times new roman", "comic sans ms", "verdana", "georgia", "palatino", "courier"]
    },
    {
      "name": "font-size",
      "values": ["1em", ".7em", "1.3em", "2em"]
    },
    {
      "name": "padding",
      "values": ["0","5px","10px","15px"]
    },
    {
      "name": "margin",
      "values": ["0","5px","10px","15px"]
    },
    {
      "name": "border-radius",
      "values": ["0", "2px", "3px", "4px", "5px"]
    },
    {
      "name": "text-align",
      "values": ["left", "center", "right"]
    },
    {
      "name": "transform",
      "values": ["rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(5deg)","rotate(-5deg)","rotate(-10deg)","rotate(10deg)","rotate(15deg)"]
    }
  ];

  $els = $("article").find(_.sample(selectors));
  var prop = _.sample(properties);
  $els.css(prop.name, _.sample(prop.values));
}

function roulette(time) {
  if (!time) time = 1;
  if (time>500) return;
  randomize();
  setTimeout(function() {roulette(time*1.1)}, time);
}

function resetArticle() {
  $("article").html(originalArticle);
  d3.select("body").style("background-color", "inherit");
  d3.select("body").style("color", "inherit");
}

function rewrite() {

  var speed = 1,
      n = 0;

  var articleTemplate = $("article").html(),
      styleTemplate = $("style").html();

  var article = $("article"),
      style = $("style");

  var timer = setInterval(function() {
    if(read(n,n)) {
      speed *= 1.01;
      n += speed;
    } else {
      clearInterval(timer);
    }
  });

  function read(n_article, n_style) {
    article.html(articleTemplate.substr(0,n_article));
    style.html(styleTemplate.substr(0,n_style));
    return n_article <= articleTemplate.length || n_style <= styleTemplate.length;
  }

}

var log = {
  "mouse": [],
  "scroll": []
}
function logger(bool) {

  if(this.state === bool) {
    return;
  } else {
    this.state = bool;
  }

  var eventHandlers = {
    "scroll": drawScroll,
    "keydown": drawKey,
    "keypress": drawKey,
    "keyup": drawKey,
    "mousemove": drawMouse,
    "click": drawMouse
  };

  for(var eventName in eventHandlers) {
    if(bool) {
      d3.select(window).on(eventName+".logger", eventHandlers[eventName]);
    } else {
      d3.select(window).on(eventName+".logger", null);
    }
  }

  function drawScroll(e) {

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed("scroll", true)
    .style("position", "fixed")
    .style("right", "10px")
    .style("top", (100*$("body").scrollTop()/($("body").height()-$(window).height())) + "%")
    .html("scroll" + "
(" + (100*$("body").scrollTop()/($("body").height()-$(window).height())).toFixed() + "%" + ")")
    .transition()
    .duration(1000)
    .style("opacity", 0)
    .remove();

    log.scroll.push({
      "time": new Date(),
      "scrollTop": $("body").scrollTop()
    });
  }

  function drawKey(e) {

    var key = event.keyCode || event.which;
    var keychar = String.fromCharCode(key);

    var x = Math.random()*$(window).width();
    var y = Math.random()*$(window).height();
    var color = d3.scale.linear().domain([0,25,50,75,100]).range(["red", "orange", "green", "blue", "purple"]);

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed("keyboard", true)
    .style("position", "fixed")
    .style("left", x+"px")
    .style("top", y+"px")
    .style("color", color(key%100))
    .html(keychar + "
" + d3.event.type + "")
    .transition()
    .duration(1000)
    .style("opacity", 0)
    .remove();
  }

  function drawMouse(e) {

    var xScale = d3.scale.linear().domain([0,$(window).width()]).range([0, 255]);
    var xScale2 = d3.scale.linear().domain([0,$(window).width()]).range([255, 0]);
    var yScale = d3.scale.linear().domain([0,$(window).height()]).range([0, 255]);
    var color = "rgb("+ xScale(d3.event.clientX).toFixed() + "," + yScale(d3.event.clientY).toFixed() + "," + xScale2(d3.event.clientX).toFixed() +")";

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed(d3.event.type, true)
    .style("position", "fixed")
    .style("left", d3.event.clientX+"px")
    .style("top", d3.event.clientY+"px")
    .style("transform", "translate(-50%,-50%) rotate("+ (Math.random()*60-30).toFixed() +"deg)")
    .style("color", color)
    .html(d3.event.type + "
(" + d3.event.clientX + ", " + d3.event.clientY + ")")
    .transition()
    .ease("exp-out")
    .duration(10000)
    .style("opacity", 0)
    .remove();

    log.mouse.push({
      "time": new Date(),
      "type": d3.event.type,
      "clientX": d3.event.clientX,
      "clientY": d3.event.clientY,
      "offsetX": d3.event.offsetX,
      "offsetY": d3.event.offsetY,
      "pageX": d3.event.pageX,
      "pageY": d3.event.pageY,
      "screenX": d3.event.screenX,
      "screenY": d3.event.screenY
    });
  }
}

console.log("                    ___\n                _.-'   ```'--.._                 _____ ___ ___   ____  _____ __ __      ______  __ __    ___  \n              .'                `-._            / ___/|   |   | /    |/ ___/|  |  |    |      ||  |  |  /  _] \n             /                      `.         (   \\_ | _   _ ||  o  (   \\_ |  |  |    |      ||  |  | /  [_        \n            /                         `.        \\__  ||  \\_/  ||     |\\__  ||  _  |    |_|  |_||  _  ||    _]       \n           /                            `.      /  \\ ||   |   ||  _  |/  \\ ||  |  |      |  |  |  |  ||   [_        \n          :       (                       \\     \\    ||   |   ||  |  |\\    ||  |  |      |  |  |  |  ||     |       \n          |    (   \\_                  )   `.    \\___||___|___||__|__| \\___||__|__|      |__|  |__|__||_____|       \n          |     \\__/ '.               /  )  ;  \n          |   (___:    \\            _/__/   ;    ____   ____  ______  ____   ____   ____  ____      __  __ __  __ __ \n          :       | _  ;          .'   |__) :   |    \\ /    ||      ||    \\ |    | /    ||    \\    /  ]|  |  ||  |  |\n           :      |` \\ |         /     /   /    |  o  )  o  ||      ||  D  ) |  | |  o  ||  D  )  /  / |  |  ||  |  |\n            \\     |_  ;|        /`\\   /   /     |   _/|     ||_|  |_||    /  |  | |     ||    /  /  /  |  _  ||  ~  |\n             \\    ; ) :|       ;_  ; /   /      |  |  |  _  |  |  |  |    \\  |  | |  _  ||    \\ /   \\_ |  |  ||___, |\n              \\_  .-''-.       | ) :/   /       |  |  |  |  |  |  |  |  .  \\ |  | |  |  ||  .  \\\\     ||  |  ||     |\n             .-         `      .--.'   /        |__|  |__|__|  |__|  |__|\\_||____||__|__||__|\\_| \\____||__|__||____/ \n            :         _.----._     `  < \n            :       -'........'-       `.\n             `.        `''''`           ;\n               `'-.__                  ,'\n                     ``--.   :'-------'\n                         :   :\n                        .'   '.\n      \n      \n                                                                    ");
<commit_msg>Added scancodes to keylogger for better correspondence to text<commit_after>function destroyPage() {
  setInterval(function() {
    var $el = $('body');
    while($el.children().length > 0) {
      $el = $el.children().eq(0);
    }
    $el.remove();
  },100);
}

function randomize() {
  var selectors = ["h1", "h2", "p"];
  var properties = [
    {
      "name": "background",
      "values": ["none", "#d5cdfb", "#fdc8d8", "#fae665", "#fbba7d", "#94e1bb"]
    },
    {
      "name": "font-family",
      "values": ["helvetica, arial", "garamond", "times new roman", "comic sans ms", "verdana", "georgia", "palatino", "courier"]
    },
    {
      "name": "font-size",
      "values": ["1em", ".7em", "1.3em", "2em"]
    },
    {
      "name": "padding",
      "values": ["0","5px","10px","15px"]
    },
    {
      "name": "margin",
      "values": ["0","5px","10px","15px"]
    },
    {
      "name": "border-radius",
      "values": ["0", "2px", "3px", "4px", "5px"]
    },
    {
      "name": "text-align",
      "values": ["left", "center", "right"]
    },
    {
      "name": "transform",
      "values": ["rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(0deg)","rotate(5deg)","rotate(-5deg)","rotate(-10deg)","rotate(10deg)","rotate(15deg)"]
    }
  ];

  $els = $("article").find(_.sample(selectors));
  var prop = _.sample(properties);
  $els.css(prop.name, _.sample(prop.values));
}

function roulette(time) {
  if (!time) time = 1;
  if (time>500) return;
  randomize();
  setTimeout(function() {roulette(time*1.1)}, time);
}

function resetArticle() {
  $("article").html(originalArticle);
  d3.select("body").style("background-color", "inherit");
  d3.select("body").style("color", "inherit");
}

function rewrite() {

  var speed = 1,
      n = 0;

  var articleTemplate = $("article").html(),
      styleTemplate = $("style").html();

  var article = $("article"),
      style = $("style");

  var timer = setInterval(function() {
    if(read(n,n)) {
      speed *= 1.01;
      n += speed;
    } else {
      clearInterval(timer);
    }
  });

  function read(n_article, n_style) {
    article.html(articleTemplate.substr(0,n_article));
    style.html(styleTemplate.substr(0,n_style));
    return n_article <= articleTemplate.length || n_style <= styleTemplate.length;
  }

}

var log = {
  "mouse": [],
  "scroll": []
}
function logger(bool) {

  if(this.state === bool) {
    return;
  } else {
    this.state = bool;
  }

  var eventHandlers = {
    "scroll": drawScroll,
    "keydown": drawKey,
    "keypress": drawKey,
    "keyup": drawKey,
    "mousemove": drawMouse,
    "click": drawMouse
  };

  for(var eventName in eventHandlers) {
    if(bool) {
      d3.select(window).on(eventName+".logger", eventHandlers[eventName]);
    } else {
      d3.select(window).on(eventName+".logger", null);
    }
  }

  function drawScroll(e) {

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed("scroll", true)
    .style("position", "fixed")
    .style("right", "10px")
    .style("top", (100*$("body").scrollTop()/($("body").height()-$(window).height())) + "%")
    .html("scroll" + "<br/><small>(" + (100*$("body").scrollTop()/($("body").height()-$(window).height())).toFixed() + "%" + ")</small>")
    .transition()
    .duration(1000)
    .style("opacity", 0)
    .remove();

    log.scroll.push({
      "time": new Date(),
      "scrollTop": $("body").scrollTop()
    });
  }

  function drawKey(e) {

  var scanCodes = [
    {"key":"A","make":"1C","break":"F0,1C"},
    {"key":"B","make":"32","break":"F0,32"},
    {"key":"C","make":"21","break":"F0,21"},
    {"key":"D","make":"23","break":"F0,23"},
    {"key":"E","make":"24","break":"F0,24"},
    {"key":"F","make":"2B","break":"F0,2B"},
    {"key":"G","make":"34","break":"F0,34"},
    {"key":"H","make":"33","break":"F0,33"},
    {"key":"I","make":"43","break":"F0,43"},
    {"key":"J","make":"3B","break":"F0,3B"},
    {"key":"K","make":"42","break":"F0,42"},
    {"key":"L","make":"4B","break":"F0,4B"},
    {"key":"M","make":"3A","break":"F0,3A"},
    {"key":"N","make":"31","break":"F0,31"},
    {"key":"O","make":"44","break":"F0,44"},
    {"key":"P","make":"4D","break":"F0,4D"},
    {"key":"Q","make":"15","break":"F0,15"},
    {"key":"R","make":"2D","break":"F0,2D"},
    {"key":"S","make":"1B","break":"F0,1B"},
    {"key":"T","make":"2C","break":"F0,2C"},
    {"key":"U","make":"3C","break":"F0,3C"},
    {"key":"V","make":"2A","break":"F0,2A"},
    {"key":"W","make":"1D","break":"F0,1D"},
    {"key":"X","make":"22","break":"F0,22"},
    {"key":"Y","make":"35","break":"F0,35"},
    {"key":"Z","make":"1A","break":"F0,1A"},
    {"key":"0","make":"45","break":"F0,45"},
    {"key":"1","make":"16","break":"F0,16"},
    {"key":"2","make":"1E","break":"F0,1E"},
    {"key":"3","make":"26","break":"F0,26"},
    {"key":"4","make":"25","break":"F0,25"},
    {"key":"5","make":"2E","break":"F0,2E"},
    {"key":"6","make":"36","break":"F0,36"},
    {"key":"7","make":"3D","break":"F0,3D"},
    {"key":"8","make":"3E","break":"F0,3E"},
    {"key":"9","make":"46","break":"F0,46"},
    {"key":"`","make":"0E","break":"F0,0E"},
    {"key":"-","make":"4E","break":"F0,4E"},
    {"key":"=","make":"55","break":"FO,55"},
    {"key":"\\","make":"5D","break":"F0,5D"},
    {"key":"BKSP","make":"66","break":"F0,66"},
    {"key":"SPACE","make":"29","break":"F0,29"},
    {"key":"TAB","make":"0D","break":"F0,0D"},
    {"key":"CAPS","make":"58","break":"F0,58"},
    {"key":"L SHFT","make":"12","break":"FO,12"},
    {"key":"L CTRL","make":"14","break":"FO,14"},
    {"key":"L GUI","make":"E0,1F","break":"E0,F0,1F"},
    {"key":"L ALT","make":"11","break":"F0,11"},
    {"key":"R SHFT","make":"59","break":"F0,59"},
    {"key":"R CTRL","make":"E0,14","break":"E0,F0,14"},
    {"key":"R GUI","make":"E0,27","break":"E0,F0,27"},
    {"key":"R ALT","make":"E0,11","break":"E0,F0,11"},
    {"key":"APPS","make":"E0,2F","break":"E0,F0,2F"},
    {"key":"ENTER","make":"5A","break":"F0,5A"},
    {"key":"ESC","make":"76","break":"F0,76"},
    {"key":"F1","make":"5","break":"F0,05"},
    {"key":"F2","make":"6","break":"F0,06"},
    {"key":"F3","make":"4","break":"F0,04"},
    {"key":"F4","make":"0C","break":"F0,0C"},
    {"key":"F5","make":"3","break":"F0,03"},
    {"key":"F6","make":"0B","break":"F0,0B"},
    {"key":"F7","make":"83","break":"F0,83"},
    {"key":"F8","make":"0A","break":"F0,0A"},
    {"key":"F9","make":"1","break":"F0,01"},
    {"key":"F10","make":"9","break":"F0,09"},
    {"key":"F11","make":"78","break":"F0,78"},
    {"key":"F12","make":"7","break":"F0,07"},
    {"key":"PRNT ","make":"E0,12, ","break":"E0,F0, "},
    {"key":"SCRN","make":"E0,7C ","break":"7C,E0, F0,12 "},
    {"key":"SCROLL","make":"7E","break":"F0,7E"},
    {"key":"PAUSE","make":"E1,14,77, E1,F0,14, F0,77","break":""},
    {"key":"[","make":"54","break":"FO,54"},
    {"key":"INSERT","make":"E0,70","break":"E0,F0,70"},
    {"key":"HOME","make":"E0,6C","break":"E0,F0,6C"},
    {"key":"PG UP","make":"E0,7D","break":"E0,F0,7D"},
    {"key":"DELETE","make":"E0,71","break":"E0,F0,71"},
    {"key":"END","make":"E0,69","break":"E0,F0,69"},
    {"key":"PG DN","make":"E0,7A","break":"E0,F0,7A"},
    {"key":"U ARROW","make":"E0,75","break":"E0,F0,75"},
    {"key":"L ARROW","make":"E0,6B","break":"E0,F0,6B"},
    {"key":"D ARROW","make":"E0,72","break":"E0,F0,72"},
    {"key":"R ARROW","make":"E0,74","break":"E0,F0,74"},
    {"key":"NUM","make":"77","break":"F0,77"},
    {"key":"KP /","make":"E0,4A","break":"E0,F0,4A"},
    {"key":"KP *","make":"7C","break":"F0,7C"},
    {"key":"KP -","make":"7B","break":"F0,7B"},
    {"key":"KP +","make":"79","break":"F0,79"},
    {"key":"KP EN","make":"E0,5A","break":"E0,F0,5A"},
    {"key":"KP .","make":"71","break":"F0,71"},
    {"key":"KP 0","make":"70","break":"F0,70"},
    {"key":"KP 1","make":"69","break":"F0,69"},
    {"key":"KP 2","make":"72","break":"F0,72"},
    {"key":"KP 3","make":"7A","break":"F0,7A"},
    {"key":"KP 4","make":"6B","break":"F0,6B"},
    {"key":"KP 5","make":"73","break":"F0,73"},
    {"key":"KP 6","make":"74","break":"F0,74"},
    {"key":"KP 7","make":"6C","break":"F0,6C"},
    {"key":"KP 8","make":"75","break":"F0,75"},
    {"key":"KP 9","make":"7D","break":"F0,7D"},
    {"key":"]","make":"5B","break":"F0,5B"},
    {"key":";","make":"4C","break":"F0,4C"},
    {"key":"'","make":"52","break":"F0,52"},
    {"key":",","make":"41","break":"F0,41"},
    {"key":".","make":"49","break":"F0,49"},
    {"key":"/","make":"4A","break":"F0,4A"}];

    var key = event.keyCode || event.which;
    var keychar = String.fromCharCode(key);

    // make or break
    var scancode = _.findWhere(scanCodes, {"key": keychar.toUpperCase()});
    scancode = scancode ? scancode[(d3.event.type == "keydown" || d3.event.type == "keypress" ? "make" : "break")] : '';

    var x = Math.random()*$(window).width();
    var y = Math.random()*$(window).height();
    var color = d3.scale.linear().domain([0,25,50,75,100]).range(["red", "orange", "green", "blue", "purple"]);

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed("keyboard", true)
    .style("position", "fixed")
    .style("left", x+"px")
    .style("top", y+"px")
    .style("color", color(key%100))
    .html(keychar + " <strong>" + scancode + "</strong><br/><small>" + d3.event.type + "</small>")
    .transition()
    .duration(1000)
    .style("opacity", 0)
    .remove();
  }

  function drawMouse(e) {

    var xScale = d3.scale.linear().domain([0,$(window).width()]).range([0, 255]);
    var xScale2 = d3.scale.linear().domain([0,$(window).width()]).range([255, 0]);
    var yScale = d3.scale.linear().domain([0,$(window).height()]).range([0, 255]);
    var color = "rgb("+ xScale(d3.event.clientX).toFixed() + "," + yScale(d3.event.clientY).toFixed() + "," + xScale2(d3.event.clientX).toFixed() +")";

    d3.select("body")
    .append("div")
    .classed("event-log", true)
    .classed(d3.event.type, true)
    .style("position", "fixed")
    .style("left", d3.event.clientX+"px")
    .style("top", d3.event.clientY+"px")
    .style("transform", "translate(-50%,-50%) rotate("+ (Math.random()*60-30).toFixed() +"deg)")
    .style("color", color)
    .html(d3.event.type + "<br/><small>(" + d3.event.clientX + ", " + d3.event.clientY + ")</small>")
    .transition()
    .ease("exp-out")
    .duration(10000)
    .style("opacity", 0)
    .remove();

    log.mouse.push({
      "time": new Date(),
      "type": d3.event.type,
      "clientX": d3.event.clientX,
      "clientY": d3.event.clientY,
      "offsetX": d3.event.offsetX,
      "offsetY": d3.event.offsetY,
      "pageX": d3.event.pageX,
      "pageY": d3.event.pageY,
      "screenX": d3.event.screenX,
      "screenY": d3.event.screenY
    });
  }
}

console.log("                    ___\n                _.-'   ```'--.._                 _____ ___ ___   ____  _____ __ __      ______  __ __    ___  \n              .'                `-._            / ___/|   |   | /    |/ ___/|  |  |    |      ||  |  |  /  _] \n             /                      `.         (   \\_ | _   _ ||  o  (   \\_ |  |  |    |      ||  |  | /  [_        \n            /                         `.        \\__  ||  \\_/  ||     |\\__  ||  _  |    |_|  |_||  _  ||    _]       \n           /                            `.      /  \\ ||   |   ||  _  |/  \\ ||  |  |      |  |  |  |  ||   [_        \n          :       (                       \\     \\    ||   |   ||  |  |\\    ||  |  |      |  |  |  |  ||     |       \n          |    (   \\_                  )   `.    \\___||___|___||__|__| \\___||__|__|      |__|  |__|__||_____|       \n          |     \\__/ '.               /  )  ;  \n          |   (___:    \\            _/__/   ;    ____   ____  ______  ____   ____   ____  ____      __  __ __  __ __ \n          :       | _  ;          .'   |__) :   |    \\ /    ||      ||    \\ |    | /    ||    \\    /  ]|  |  ||  |  |\n           :      |` \\ |         /     /   /    |  o  )  o  ||      ||  D  ) |  | |  o  ||  D  )  /  / |  |  ||  |  |\n            \\     |_  ;|        /`\\   /   /     |   _/|     ||_|  |_||    /  |  | |     ||    /  /  /  |  _  ||  ~  |\n             \\    ; ) :|       ;_  ; /   /      |  |  |  _  |  |  |  |    \\  |  | |  _  ||    \\ /   \\_ |  |  ||___, |\n              \\_  .-''-.       | ) :/   /       |  |  |  |  |  |  |  |  .  \\ |  | |  |  ||  .  \\\\     ||  |  ||     |\n             .-         `      .--.'   /        |__|  |__|__|  |__|  |__|\\_||____||__|__||__|\\_| \\____||__|__||____/ \n            :         _.----._     `  < \n            :       -'........'-       `.\n             `.        `''''`           ;\n               `'-.__                  ,'\n                     ``--.   :'-------'\n                         :   :\n                        .'   '.\n      \n      \n                                                                    ");
<|endoftext|>


<commit_before>describe('FillHandle', function () {
  var id = 'testContainer';

  beforeEach(function () {
    this.$container = $('

').appendTo('body');
  });

  afterEach(function () {
    if (this.$container) {
      destroy();
      this.$container.remove();
    }
  });

  it('should appear when fillHandle equals true', function () {
    handsontable({
      fillHandle: true
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      selectCell(2, 2);
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(true);
    });
  });

  it('should not appear when fillHandle equals false', function () {
    handsontable({
      fillHandle: false
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });

  it('should disappear when beginediting is triggered', function () {
    handsontable({
      fillHandle: true
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });

  it('should appear when finishediting is triggered', function () {
    handsontable({
      fillHandle: true
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(true);
    });
  });

  it('should not appear when fillHandle equals false and finishediting is triggered', function () {
    handsontable({
      fillHandle: false
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });
});<commit_msg>feature: new callbacks - test case for beforeAutofill<commit_after>describe('FillHandle', function () {
  var id = 'testContainer';

  beforeEach(function () {
    this.$container = $('

').appendTo('body');
  });

  afterEach(function () {
    if (this.$container) {
      destroy();
      this.$container.remove();
    }
  });

  it('should appear when fillHandle equals true', function () {
    handsontable({
      fillHandle: true
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      selectCell(2, 2);
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(true);
    });
  });

  it('should not appear when fillHandle equals false', function () {
    handsontable({
      fillHandle: false
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });

  it('should disappear when beginediting is triggered', function () {
    handsontable({
      fillHandle: true
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });

  it('should appear when finishediting is triggered', function () {
    handsontable({
      fillHandle: true
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(true);
    });
  });

  it('should not appear when fillHandle equals false and finishediting is triggered', function () {
    handsontable({
      fillHandle: false
    });
    selectCell(2, 2);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      keyDown('enter');
      keyDown('enter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(isFillHandleVisible()).toBe(false);
    });
  });

  it('should add custom value after autofill', function () {

    handsontable({
      data: [[1,2,3,4,5,6], [1,2,3,4,5,6], [1,2,3,4,5,6], [1,2,3,4,5,6]],
      beforeAutofill: function (start, end, data) {
        data[0][0] = "test";
      }
    });
    selectCell(0, 0);

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      var fillHandle = this.$container.find('.wtBorder.corner')[0]
        , event = jQuery.Event("mousedown");

      event.target = fillHandle;
      this.$container.find('tr:eq(0) td:eq(0)').trigger(event);
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      this.$container.find('tr:eq(1) td:eq(0)').trigger('mouseenter');
      this.$container.find('tr:eq(2) td:eq(0)').trigger('mouseenter');
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      var fillHandle = this.$container.find('.wtBorder.corner')[0]
        , event = jQuery.Event("mouseup");

      event.target = fillHandle;
      this.$container.find('tr:eq(2) td:eq(0)').trigger(event);
    });

    waitsFor(nextFrame, 'next frame', 60);

    runs(function () {
      expect(getDataAtCell(1,0)).toEqual("test");
    });
  });
});<|endoftext|>


<commit_before>'use strict';

const electron = require('electron');
const app = electron.app;  // Module to control application life.
const BrowserWindow = electron.BrowserWindow;  // Module to create native browser window.
const ipcMain = require('electron').ipcMain;
const Menu = require('electron').Menu;
const Tray = require('electron').Tray;

var debugMode;
var startupFilePath;
var trayIcon = null;

//handling start parameter
//console.log(JSON.stringify(process.argv));
process.argv.forEach(function(arg, count) {
  if (arg.toLowerCase() === '-d' || arg.toLowerCase() === '--debug') {
    debugMode = true;
  } else if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '--portable') {
    app.setPath('userData', 'tsprofile'); // making the app portable
  } else if (arg === '.' || count === 0) { // ignoring the first argument
    //Ignore these argument
  } else if (arg.length > 2) {
    console.log("Opening file: " + arg);
    startupFilePath = arg;
  }
});

ipcMain.on('quit-application', function(event, arg) {
  //console.log(arg);
  app.quit();
});

var path = require('path');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  //if (process.platform != 'darwin') {
  app.quit();
  //}
});

app.on('ready', function(event) {
  console.log(event);
  mainWindow = new BrowserWindow({width: 1280, height: 768});

  //var indexPath = 'file://' + __dirname + '/index.html';
  var startupParameter = "";
  if (startupFilePath) {
    startupParameter = "?open=" + encodeURIComponent(startupFilePath);
  }
  var indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;

  mainWindow.setMenu(null);
  mainWindow.loadURL(indexPath);

  if (debugMode) {
    mainWindow.webContents.openDevTools();
  }

  var webContents = mainWindow.webContents;

  webContents.on('crash', function() {
    console.log("WebContent crashed");
  });

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });

  mainWindow.on('minimize',function(event){
    event.preventDefault();
    mainWindow.hide();
  });

  if (process.platform == 'darwin') {
    trayIcon = new Tray('assets/icon32.png');
  } else if(process.platform == 'win') {
    trayIcon = new Tray('assets/icon32.png');
  } else {
    trayIcon = new Tray('assets/icon32.png');
  }
  var trayMenuTemplate = [
    {
      label: 'Show App', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'New File', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Previous File', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Stop Playback', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Resume Playback', click:  function(){
        mainWindow.show();
      }
    },
    //{
    //  label: 'Settings',
    //  click: function () {
    //    ipcRenderer.send('open-settings-window');
    //  }
    //},
    {
      label: 'Quit',
      click: function (event) {
        console.log(event);
        app.quit();
        //event.ipcRenderer.send('remove-tray');
        //ipcRenderer.send('window-all-closed');
      }
    }
  ];

  trayIcon.on('clicked', function() {
    mainWindow.show();
  });

  var trayMenu = Menu.buildFromTemplate(trayMenuTemplate);
  trayIcon.setToolTip('TagSpaces App');
  trayIcon.setContextMenu(trayMenu);
});
<commit_msg>detect single and double left clicks to Tray Icon<commit_after>'use strict';

const electron = require('electron');
const app = electron.app;  // Module to control application life.
const BrowserWindow = electron.BrowserWindow;  // Module to create native browser window.
const ipcMain = require('electron').ipcMain;
const Menu = require('electron').Menu;
const Tray = require('electron').Tray;

var debugMode;
var startupFilePath;
var trayIcon = null;

//handling start parameter
//console.log(JSON.stringify(process.argv));
process.argv.forEach(function(arg, count) {
  if (arg.toLowerCase() === '-d' || arg.toLowerCase() === '--debug') {
    debugMode = true;
  } else if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '--portable') {
    app.setPath('userData', 'tsprofile'); // making the app portable
  } else if (arg === '.' || count === 0) { // ignoring the first argument
    //Ignore these argument
  } else if (arg.length > 2) {
    console.log("Opening file: " + arg);
    startupFilePath = arg;
  }
});

ipcMain.on('quit-application', function(event, arg) {
  //console.log(arg);
  app.quit();
});

var path = require('path');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  //if (process.platform != 'darwin') {
  app.quit();
  //}
});

app.on('ready', function(event) {
  console.log(event);
  mainWindow = new BrowserWindow({width: 1280, height: 768});

  //var indexPath = 'file://' + __dirname + '/index.html';
  var startupParameter = "";
  if (startupFilePath) {
    startupParameter = "?open=" + encodeURIComponent(startupFilePath);
  }
  var indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;

  mainWindow.setMenu(null);
  mainWindow.loadURL(indexPath);

  if (debugMode) {
    mainWindow.webContents.openDevTools();
  }

  var webContents = mainWindow.webContents;

  webContents.on('crash', function() {
    console.log("WebContent crashed");
  });

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });

  mainWindow.on('minimize',function(event){
    event.preventDefault();
    mainWindow.hide();
  });

  if (process.platform == 'darwin') {
    trayIcon = new Tray('assets/icon32.png');
  } else if(process.platform == 'win') {
    trayIcon = new Tray('assets/icon32.png');
  } else {
    trayIcon = new Tray('assets/icon32.png');
  }
  var trayMenuTemplate = [
    {
      label: 'Show App', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'New File', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Previous File', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Stop Playback', click:  function(){
        mainWindow.show();
      }
    },
    {
      label: 'Resume Playback', click:  function(){
        mainWindow.show();
      }
    },
    //{
    //  label: 'Settings',
    //  click: function () {
    //    ipcRenderer.send('open-settings-window');
    //  }
    //},
    {
      label: 'Quit',
      click: function (event) {
        console.log(event);
        app.quit();
        //event.ipcRenderer.send('remove-tray');
        //ipcRenderer.send('window-all-closed');
      }
    }
  ];

  trayIcon.on('clicked', function() {
    mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
  });

  var title = 'TagSpaces App';
  var trayMenu = Menu.buildFromTemplate(trayMenuTemplate);
  trayIcon.setToolTip(title);
  trayIcon.setTitle(title);
  trayIcon.setContextMenu(trayMenu);
});
<|endoftext|>