<commit_before>define(function(require) {

    var Base = require('../core/Base');
    var Vector3 = require('../math/Vector3');
    var Matrix4 = require('../math/Matrix4');

    /**
     * @constructor qtek.plugin.OrbitControl
     *
     * @example
     *
     *     var control = new qtek.plugin.OrbitControl({
     *         target: camera,
     *         domElement: renderer.canvas
     *     });
     *     // Rotate around car
     *     control.origin.copy(car.position);
     *     ...
     *     animation.on('frame', function(frameTime) {
     *         control.update(frameTime);
     *         renderer.render(scene, camera);
     *     });
     */
    var OrbitControl = Base.derive(function() {
        return /** @lends qtek.plugin.OrbitControl# */ {
            /**
             * Scene node to control, mostly it is a camera
             * @type {qtek.Node}
             */
            target: null,

            /**
             * Target dom to bind with mouse events
             * @type {HTMLElement}
             */
            domElement: null,

            /**
             * Mouse move sensitivity
             * @type {number}
             */
            sensitivity: 1,

            /**
             * Origin to rotate around
             * @type {qtek.math.Vector3}
             */
            origin: new Vector3(),

            /**
             * Up axis
             * @type {qtek.math.Vector3}
             */
            up: new Vector3(0, 1, 0),

            /**
             * Minimum distance from origin to target when zooming in
             * @type {number}
             */
            minDistance: 0,
            /**
             * Maximum distance from origin to target when zooming out
             * @type {number}
             */
            maxDistance: Infinity,

            /**
             * Minimum polar angle when rotate up, it is 0 when the direction origin point to target is same with up axis
             * @type {number}
             */
            minPolarAngle: 0, // [0, Math.PI/2]

            /**
             * Maximum polar angle when rotate down. It is PI when the direction origin point to target is opposite to up axis
             * @type {number}
             */
            maxPolarAngle: Math.PI, // [Math.PI/2, Math.PI]

            // Rotate around origin
            _offsetPitch: 0,
            _offsetRoll: 0,

            // Pan the origin
            _panX: 0,
            _panY: 0,

            // Offset of mouse move
            _offsetX: 0,
            _offsetY: 0,

            // Zoom with mouse wheel
            _forward: 0,

            _op: -1  //0: ROTATE, 1: PAN
        };
    }, function() {
        this._mouseDown = this._mouseDown.bind(this);
        this._mouseUp = this._mouseUp.bind(this);
        this._mouseMove = this._mouseMove.bind(this);
        this._mouseOut = this._mouseOut.bind(this);
        this._mouseWheel = this._mouseWheel.bind(this);

        if (this.domElement) {
            this.enable();
        }
    },
    /** @lends qtek.plugin.OrbitControl.prototype */
    {
        /**
         * Enable control
         */
        enable: function() {
            var domElement = this.domElement;
            domElement.addEventListener('mousedown', this._mouseDown);
            domElement.addEventListener('mousewheel', this._mouseWheel);
            domElement.addEventListener('DOMMouseScroll', this._mouseWheel);

            domElement.addEventListener('touchstart', this._mouseDown);

        },

        /**
         * Disable control
         */
        disable: function() {
            this.domElement.removeEventListener('mousedown', this._mouseDown);
            this.domElement.removeEventListener('mousewheel', this._mouseWheel);
            this.domElement.removeEventListener('DOMMouseScroll', this._mouseWheel);

            this.domElement.removeEventListener('touchstart', this._mouseDown);

            this._mouseUp();
        },

        _mouseWheel: function(e) {
            e.preventDefault();
            var delta = e.wheelDelta // Webkit
                        || -e.detail; // Firefox

            this._forward += delta * this.sensitivity;
        },

        _mouseDown: function(e) {
            document.addEventListener('mousemove', this._mouseMove);
            document.addEventListener('mouseup', this._mouseUp);
            document.addEventListener('mouseout', this._mouseOut);

            document.addEventListener('touchend', this._mouseUp);
            document.addEventListener('touchmove', this._mouseMove);

            this._offsetX = e.pageX;
            this._offsetY = e.pageY;

            // Rotate
            if (e.button === 0) {
                this._op = 0;
            } else if (e.button === 1) {
                this._op = 1;
            }
        },

        _mouseMove: function(e) {
            var dx = e.pageX - this._offsetX;
            var dy = e.pageY - this._offsetY;

            if (this._op === 0) {
                this._offsetPitch += dx * this.sensitivity / 100;
                this._offsetRoll += dy * this.sensitivity / 100;
            } else if (this._op === 1) {
                var len = this.origin.distance(this.target.position);
                var divider;
                if (this.target.fov) {
                    divider = Math.sin(this.target.fov * Math.PI / 360) / 200;
                } else {
                    divider = 1 / 200;
                }
                this._panX += dx * this.sensitivity * len * divider;
                this._panY += dy * this.sensitivity * len * divider;
            }

            this._offsetX = e.pageX;
            this._offsetY = e.pageY;
        },

        _mouseUp: function() {

            document.removeEventListener('mousemove', this._mouseMove);
            document.removeEventListener('mouseup', this._mouseUp);
            document.removeEventListener('mouseout', this._mouseOut);

            document.removeEventListener('touchend', this._mouseUp);
            document.removeEventListener('touchmove', this._mouseMove);

            this._op = -1;
        },

        _mouseOut: function() {
            this._mouseUp();
        },

        /**
         * Control update. Should be invoked every frame
         * @param {number} frameTime Frame time
         */
        update: function(frameTime) {
            var target = this.target;
            var zAxis = target.localTransform.z.normalize();
            var yAxis = target.localTransform.y.normalize();
            if (this._op === 0 && this._offsetPitch !== 0 && this._offsetRoll !== 0) {
                // Rotate
                target.rotateAround(this.origin, this.up, -this._offsetPitch);
                var xAxis = target.localTransform.x;
                target.rotateAround(this.origin, xAxis, -this._offsetRoll);

                var zAxis = target.worldTransform.z.normalize();
                var phi = Math.acos(this.up.dot(zAxis));
                // Rotate back a bit
                if (this._offsetRoll > 0 && phi <= this.minPolarAngle) {
                    target.rotateAround(this.origin, xAxis, -phi + this.minPolarAngle);
                }
                else if (this._offsetRoll < 0 && phi >= this.maxPolarAngle) {
                    target.rotateAround(this.origin, xAxis, -phi + this.maxPolarAngle);
                }
                this._offsetRoll = this._offsetPitch = 0;
            } else if (this._op === 1) {
                // Pan
                var xAxis = target.localTransform.x.normalize().scale(-this._panX);
                var yAxis = target.localTransform.y.normalize().scale(this._panY);
                target.position.add(xAxis).add(yAxis);
                this.origin.add(xAxis).add(yAxis);
                this._panX = this._panY = 0;
            }
            if (this._forward !== 0) {
                // Zoom
                var distance = target.position.distance(this.origin);
                var nextDistance = distance + this._forward * distance / 5000;
                if (nextDistance < this.maxDistance && nextDistance > this.minDistance) {
                    target.position.scaleAndAdd(zAxis, this._forward * distance / 5000);
                }
                this._forward = 0;
            }

        }
    });

    return OrbitControl;
});<commit_msg>Orbit control bugfix<commit_after>define(function(require) {

    var Base = require('../core/Base');
    var Vector3 = require('../math/Vector3');
    var Matrix4 = require('../math/Matrix4');

    /**
     * @constructor qtek.plugin.OrbitControl
     *
     * @example
     *
     *     var control = new qtek.plugin.OrbitControl({
     *         target: camera,
     *         domElement: renderer.canvas
     *     });
     *     // Rotate around car
     *     control.origin.copy(car.position);
     *     ...
     *     animation.on('frame', function(frameTime) {
     *         control.update(frameTime);
     *         renderer.render(scene, camera);
     *     });
     */
    var OrbitControl = Base.derive(function() {
        return /** @lends qtek.plugin.OrbitControl# */ {
            /**
             * Scene node to control, mostly it is a camera
             * @type {qtek.Node}
             */
            target: null,

            /**
             * Target dom to bind with mouse events
             * @type {HTMLElement}
             */
            domElement: null,

            /**
             * Mouse move sensitivity
             * @type {number}
             */
            sensitivity: 1,

            /**
             * Origin to rotate around
             * @type {qtek.math.Vector3}
             */
            origin: new Vector3(),

            /**
             * Up axis
             * @type {qtek.math.Vector3}
             */
            up: new Vector3(0, 1, 0),

            /**
             * Minimum distance from origin to target when zooming in
             * @type {number}
             */
            minDistance: 0,
            /**
             * Maximum distance from origin to target when zooming out
             * @type {number}
             */
            maxDistance: Infinity,

            /**
             * Minimum polar angle when rotate up, it is 0 when the direction origin point to target is same with up axis
             * @type {number}
             */
            minPolarAngle: 0, // [0, Math.PI/2]

            /**
             * Maximum polar angle when rotate down. It is PI when the direction origin point to target is opposite to up axis
             * @type {number}
             */
            maxPolarAngle: Math.PI, // [Math.PI/2, Math.PI]

            // Rotate around origin
            _offsetPitch: 0,
            _offsetRoll: 0,

            // Pan the origin
            _panX: 0,
            _panY: 0,

            // Offset of mouse move
            _offsetX: 0,
            _offsetY: 0,

            // Zoom with mouse wheel
            _forward: 0,

            _op: -1  //0: ROTATE, 1: PAN
        };
    }, function() {
        this._mouseDown = this._mouseDown.bind(this);
        this._mouseUp = this._mouseUp.bind(this);
        this._mouseMove = this._mouseMove.bind(this);
        this._mouseOut = this._mouseOut.bind(this);
        this._mouseWheel = this._mouseWheel.bind(this);

        if (this.domElement) {
            this.enable();
        }
    },
    /** @lends qtek.plugin.OrbitControl.prototype */
    {
        /**
         * Enable control
         */
        enable: function() {
            var domElement = this.domElement;
            domElement.addEventListener('mousedown', this._mouseDown);
            domElement.addEventListener('mousewheel', this._mouseWheel);
            domElement.addEventListener('DOMMouseScroll', this._mouseWheel);

            domElement.addEventListener('touchstart', this._mouseDown);

        },

        /**
         * Disable control
         */
        disable: function() {
            this.domElement.removeEventListener('mousedown', this._mouseDown);
            this.domElement.removeEventListener('mousewheel', this._mouseWheel);
            this.domElement.removeEventListener('DOMMouseScroll', this._mouseWheel);

            this.domElement.removeEventListener('touchstart', this._mouseDown);

            this._mouseUp();
        },

        _mouseWheel: function(e) {
            e.preventDefault();
            var delta = e.wheelDelta // Webkit
                        || -e.detail; // Firefox

            this._forward += delta * this.sensitivity;
        },

        _mouseDown: function(e) {
            document.addEventListener('mousemove', this._mouseMove);
            document.addEventListener('mouseup', this._mouseUp);
            document.addEventListener('mouseout', this._mouseOut);

            document.addEventListener('touchend', this._mouseUp);
            document.addEventListener('touchmove', this._mouseMove);

            this._offsetX = e.pageX;
            this._offsetY = e.pageY;

            // Rotate
            if (e.button === 0) {
                this._op = 0;
            } else if (e.button === 1) {
                this._op = 1;
            }
        },

        _mouseMove: function(e) {
            var dx = e.pageX - this._offsetX;
            var dy = e.pageY - this._offsetY;

            if (this._op === 0) {
                this._offsetPitch += dx * this.sensitivity / 100;
                this._offsetRoll += dy * this.sensitivity / 100;
            } else if (this._op === 1) {
                var len = this.origin.distance(this.target.position);
                var divider;
                if (this.target.fov) {
                    divider = Math.sin(this.target.fov * Math.PI / 360) / 200;
                } else {
                    divider = 1 / 200;
                }
                this._panX += dx * this.sensitivity * len * divider;
                this._panY += dy * this.sensitivity * len * divider;
            }

            this._offsetX = e.pageX;
            this._offsetY = e.pageY;
        },

        _mouseUp: function() {

            document.removeEventListener('mousemove', this._mouseMove);
            document.removeEventListener('mouseup', this._mouseUp);
            document.removeEventListener('mouseout', this._mouseOut);

            document.removeEventListener('touchend', this._mouseUp);
            document.removeEventListener('touchmove', this._mouseMove);

            this._op = -1;
        },

        _mouseOut: function() {
            this._mouseUp();
        },

        /**
         * Control update. Should be invoked every frame
         * @param {number} frameTime Frame time
         */
        update: function(frameTime) {
            var target = this.target;
            var zAxis = target.localTransform.z.normalize();
            var yAxis = target.localTransform.y.normalize();

            if (this._op === 0 && (this._offsetPitch !== 0 || this._offsetRoll !== 0)) {
                // Rotate
                target.rotateAround(this.origin, this.up, -this._offsetPitch);
                var xAxis = target.localTransform.x;
                target.rotateAround(this.origin, xAxis, -this._offsetRoll);

                var zAxis = target.worldTransform.z.normalize();
                var phi = Math.acos(this.up.dot(zAxis));
                // Rotate back a bit
                if (this._offsetRoll > 0 && phi <= this.minPolarAngle) {
                    target.rotateAround(this.origin, xAxis, -phi + this.minPolarAngle);
                }
                else if (this._offsetRoll < 0 && phi >= this.maxPolarAngle) {
                    target.rotateAround(this.origin, xAxis, -phi + this.maxPolarAngle);
                }
                this._offsetRoll = this._offsetPitch = 0;
            } else if (this._op === 1) {
                // Pan
                var xAxis = target.localTransform.x.normalize().scale(-this._panX);
                var yAxis = target.localTransform.y.normalize().scale(this._panY);
                target.position.add(xAxis).add(yAxis);
                this.origin.add(xAxis).add(yAxis);
                this._panX = this._panY = 0;
            }
            if (this._forward !== 0) {
                // Zoom
                var distance = target.position.distance(this.origin);
                var nextDistance = distance + this._forward * distance / 5000;
                if (nextDistance < this.maxDistance && nextDistance > this.minDistance) {
                    target.position.scaleAndAdd(zAxis, this._forward * distance / 5000);
                }
                this._forward = 0;
            }

        }
    });

    return OrbitControl;
});<|endoftext|>


<commit_before>/**
 * ansi-viewer
 * ANSI art viewer for node.
 * Copyright (c) 2015, Christopher Jeffrey and contributors (MIT License).
 * https://github.com/chjj/blessed
 */

var blessed = require('blessed')
  , request = require('request')
  , fs = require('fs')
  , cp = require('child_process')
  , singlebyte = require('./singlebyte');

// $ wget -r -o log --tries=10 'http://artscene.textfiles.com/ansi/'
// $ grep 'http.*\.ans$' log | awk '{ print $3 }' > ansi-art.list

var urls = fs.readFileSync(__dirname + '/ansi-art.list', 'utf8').trim().split('\n');

var map = urls.reduce(function(map, url) {
  map[/([^.\/]+\/[^.\/]+)\.ans$/.exec(url)[1]] = url;
  return map;
}, {});

var max = Object.keys(map).reduce(function(out, text) {
  return Math.max(out, text.length);
}, 0) + 6;

var screen = blessed.screen({
  smartCSR: true,
  dockBorders: true
});

var art = blessed.terminal({
  parent: screen,
  left: 0,
  top: 0,
  height: 60,
  // some are 78/80, some are 80/82
  width: 82,
  border: 'line',
  tags: true,
  label: ' {bold}{cyan-fg}ANSI Art{/cyan-fg}{/bold} (Drag Me) ',
  handler: function() {},
  draggable: true
});

var list = blessed.list({
  parent: screen,
  label: ' {bold}{cyan-fg}Art List{/cyan-fg}{/bold} (Drag Me) ',
  tags: true,
  draggable: true,
  top: 0,
  right: 0,
  width: max,
  height: '50%',
  keys: true,
  vi: true,
  mouse: true,
  border: 'line',
  scrollbar: {
    ch: ' ',
    track: {
      bg: 'cyan'
    },
    style: {
      inverse: true
    }
  },
  style: {
    item: {
      hover: {
        bg: 'blue'
      }
    },
    selected: {
      bg: 'blue',
      bold: true
    }
  },
  search: function(callback) {
    prompt.input('Search:', '', function(err, value) {
      if (err) return;
      return callback(null, value);
    });
  }
});

var status = blessed.box({
  parent: screen,
  bottom: 0,
  right: 0,
  height: 1,
  width: 'shrink',
  style: {
    bg: 'blue'
  },
  content: 'Select your piece of ANSI art (`/` to search).'
});

var loader = blessed.loading({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 5,
  align: 'center',
  width: '50%',
  tags: true,
  hidden: true,
  border: 'line'
});

var msg = blessed.message({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 'shrink',
  width: '50%',
  align: 'center',
  tags: true,
  hidden: true,
  border: 'line'
});

var prompt = blessed.prompt({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 'shrink',
  width: 'shrink',
  keys: true,
  vi: true,
  mouse: true,
  tags: true,
  border: 'line',
  hidden: true
});

list.setItems(Object.keys(map));

list.on('select', function(url, selected) {
  if (list._.rendering) return;

  url = map[url.getText()];
  status.setContent(url);

  list._.rendering = true;
  loader.load('Loading...');

  request({
    uri: url,
    encoding: null
  }, function(err, res, body) {
    list._.rendering = false;
    loader.stop();

    if (err) {
      return msg.error(err.message);
    }

    if (!body) {
      return msg.error('No body.');
    }

    return cp437ToUtf8(body, function(err, body) {
      if (err) {
        return msg.error(err.message);
      }

      if (process.argv[2] === '--debug') {
        fs.writeFileSync(__dirname + '/../../output.ans', body);
      }

      // Remove text:
      body = body.replace('Downloaded From P-80 International Information Systems 304-744-2253', '');

      // Remove MCI codes:
      body = body.replace(/%[A-Z0-9]{2}/g, '');

      // ^A (SOH) seems to need to produce CRLF in some cases??
      // body = body.replace(/\x01/g, '\r\n');

      // Reset and write the art:
      art.term.reset();
      art.term.write(body);
      art.term.cursorHidden = true;

      screen.render();
    });
  });
});

list.focus();

screen.key('q', function() {
  return process.exit(0);
});

screen.key('h', function() {
  list.toggle();
  if (list.visible) list.focus();
});

screen.render();

/**
 * Helpers
 */

// https://github.com/chjj/blessed/issues/127
// https://github.com/Mithgol/node-singlebyte

function cp437ToUtf8(buf, callback) {
  try {
    return callback(null, singlebyte.bufToStr(buf, 'cp437'));
  } catch (e) {
    return callback(e);
  }
}
<commit_msg>save art to regular utf8 sgr-only file.<commit_after>/**
 * ansi-viewer
 * ANSI art viewer for node.
 * Copyright (c) 2015, Christopher Jeffrey and contributors (MIT License).
 * https://github.com/chjj/blessed
 */

var blessed = require('blessed')
  , request = require('request')
  , fs = require('fs')
  , cp = require('child_process')
  , singlebyte = require('./singlebyte');

// $ wget -r -o log --tries=10 'http://artscene.textfiles.com/ansi/'
// $ grep 'http.*\.ans$' log | awk '{ print $3 }' > ansi-art.list

var urls = fs.readFileSync(__dirname + '/ansi-art.list', 'utf8').trim().split('\n');

var map = urls.reduce(function(map, url) {
  map[/([^.\/]+\/[^.\/]+)\.ans$/.exec(url)[1]] = url;
  return map;
}, {});

var max = Object.keys(map).reduce(function(out, text) {
  return Math.max(out, text.length);
}, 0) + 6;

var screen = blessed.screen({
  smartCSR: true,
  dockBorders: true
});

var art = blessed.terminal({
  parent: screen,
  left: 0,
  top: 0,
  height: 60,
  // some are 78/80, some are 80/82
  width: 82,
  border: 'line',
  tags: true,
  label: ' {bold}{cyan-fg}ANSI Art{/cyan-fg}{/bold} (Drag Me) ',
  handler: function() {},
  draggable: true
});

var list = blessed.list({
  parent: screen,
  label: ' {bold}{cyan-fg}Art List{/cyan-fg}{/bold} (Drag Me) ',
  tags: true,
  draggable: true,
  top: 0,
  right: 0,
  width: max,
  height: '50%',
  keys: true,
  vi: true,
  mouse: true,
  border: 'line',
  scrollbar: {
    ch: ' ',
    track: {
      bg: 'cyan'
    },
    style: {
      inverse: true
    }
  },
  style: {
    item: {
      hover: {
        bg: 'blue'
      }
    },
    selected: {
      bg: 'blue',
      bold: true
    }
  },
  search: function(callback) {
    prompt.input('Search:', '', function(err, value) {
      if (err) return;
      return callback(null, value);
    });
  }
});

var status = blessed.box({
  parent: screen,
  bottom: 0,
  right: 0,
  height: 1,
  width: 'shrink',
  style: {
    bg: 'blue'
  },
  content: 'Select your piece of ANSI art (`/` to search).'
});

var loader = blessed.loading({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 5,
  align: 'center',
  width: '50%',
  tags: true,
  hidden: true,
  border: 'line'
});

var msg = blessed.message({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 'shrink',
  width: '50%',
  align: 'center',
  tags: true,
  hidden: true,
  border: 'line'
});

var prompt = blessed.prompt({
  parent: screen,
  top: 'center',
  left: 'center',
  height: 'shrink',
  width: 'shrink',
  keys: true,
  vi: true,
  mouse: true,
  tags: true,
  border: 'line',
  hidden: true
});

list.setItems(Object.keys(map));

list.on('select', function(el, selected) {
  if (list._.rendering) return;

  var name = el.getText();
  var url = map[name];

  status.setContent(url);

  list._.rendering = true;
  loader.load('Loading...');

  request({
    uri: url,
    encoding: null
  }, function(err, res, body) {
    list._.rendering = false;
    loader.stop();

    if (err) {
      return msg.error(err.message);
    }

    if (!body) {
      return msg.error('No body.');
    }

    return cp437ToUtf8(body, function(err, body) {
      if (err) {
        return msg.error(err.message);
      }

      if (process.argv[2] === '--debug') {
        var filename = name.replace(/\//g, '.') + '.ans';
        fs.writeFileSync(__dirname + '/' + filename, body);
      }

      // Remove text:
      body = body.replace('Downloaded From P-80 International Information Systems 304-744-2253', '');

      // Remove MCI codes:
      body = body.replace(/%[A-Z0-9]{2}/g, '');

      // ^A (SOH) seems to need to produce CRLF in some cases??
      // body = body.replace(/\x01/g, '\r\n');

      // Reset and write the art:
      art.term.reset();
      art.term.write(body);
      art.term.cursorHidden = true;

      screen.render();

      if (process.argv[2] === '--debug' || process.argv[2] === '--save') {
        // XXX Could just save from terminal, that way the image doesn't get
        // cut off. Add a `lines` param and convert special fg and bg values
        // used in term.js.
        var sgr = screen.sgrRegion(
          art.lpos.xi + art.ileft,
          art.lpos.xl - art.iright,
          art.lpos.yi + art.itop,
          art.lpos.yl - art.ibottom);
        fs.writeFileSync(__dirname + '/' + filename + '.sgr', sgr);
      }
    });
  });
});

list.focus();

screen.key('q', function() {
  return process.exit(0);
});

screen.key('h', function() {
  list.toggle();
  if (list.visible) list.focus();
});

screen.render();

/**
 * Helpers
 */

// https://github.com/chjj/blessed/issues/127
// https://github.com/Mithgol/node-singlebyte

function cp437ToUtf8(buf, callback) {
  try {
    return callback(null, singlebyte.bufToStr(buf, 'cp437'));
  } catch (e) {
    return callback(e);
  }
}

screen.__proto__.sgrRegion = function(xi, xl, yi, yl) {
  var x
    , y
    , line
    , out
    , ch
    , data
    , attr
    , cwid
    , point;

  var main = '';

  var acs;

  var angles = {
    '\u2518': true, // '┘'
    '\u2510': true, // '┐'
    '\u250c': true, // '┌'
    '\u2514': true, // '└'
    '\u253c': true, // '┼'
    '\u251c': true, // '├'
    '\u2524': true, // '┤'
    '\u2534': true, // '┴'
    '\u252c': true, // '┬'
    '\u2502': true, // '│'
    '\u2500': true  // '─'
  };

  for (y = yi; y < yl; y++) {
    line = this.lines[y];

    out = '';
    attr = this.dattr;

    for (x = xi; x < xl; x++) {
      data = line[x][0];
      ch = line[x][1];

      if (data !== attr) {
        if (attr !== this.dattr) {
          out += '\x1b[m';
        }
        if (data !== this.dattr) {
          out += screen.codeAttr(data);
        }
      }

      if (this.fullUnicode) {
        point = blessed.unicode.codePointAt(line[x][1], 0);
        if (point <= 0x00ffff) {
          cwid = blessed.unicode.charWidth(point);
          if (cwid === 2) {
            if (x === line.length - 1 || angles[line[x + 1][1]]) {
              ch = ' ';
            } else {
              ++x;
            }
          }
        }
      }

      /*
      if (this.tput.strings.enter_alt_charset_mode
          && !this.tput.brokenACS && (this.tput.acscr[ch] || acs)) {
        if (this.tput.acscr[ch]) {
          if (acs) {
            ch = this.tput.acscr[ch];
          } else {
            ch = this.tput.smacs()
              + this.tput.acscr[ch];
            acs = true;
          }
        } else if (acs) {
          ch = this.tput.rmacs() + ch;
          acs = false;
        }
      } else {
        if (!this.tput.unicode && this.tput.numbers.U8 !== 1 && ch > '~') {
          ch = this.tput.utoa[ch] || '?';
        }
      }
      */

      out += ch;
      attr = data;
    }

    if (attr !== this.dattr) {
      out += '\x1b[m';
    }

    if (out) {
      main += (y > 0 ? '\n' : '') + out;
    }
  }

  /*
  if (acs) {
    main += this.tput.rmacs();
    acs = false;
  }
  */

  main = main.replace(/(?:\s*\x1b\[40m\s*\x1b\[m\s*)*$/, '') + '\n';

  return main;
};
<|endoftext|>


<commit_before>(function () {
    'use strict';
    angular.module('Tombola.Games.Bingo90.Core')
        .service('BingoCall',  ['$interval','$state','BingoTicket','GameProxy','EndOfGame','SessionDetails', function ($interval, $state, bingoTicket, gameProxy, endOfGame, sessionDetails) {
            var me = this,
                sessionDetailsLogin = sessionDetails.login;
            me.lastCallsDisplay = [];
            var getCallData = {
                    gameId: 1,
                    userId: sessionDetails.login.username,
                    balance: sessionDetails.login.balance,
                    callnumber: 0
                },

                removeFirstElement = function () {
                    if(me.lastCallsDisplay.length >= 6){
                        me.lastCallsDisplay.splice(0, 1);
                    }
                },

                checkForNumber = function (callNumber) {
                    if(callNumber.toString().length < 2){
                        callNumber = "0"+callNumber.toString();
                    }

                    if(bingoTicket.balls.indexOf(callNumber.toString()) !== -1){
                        bingoTicket.markedNumbers[bingoTicket.balls.indexOf(callNumber.toString())] = "markedCell";
                    }
                },

                makeApiCall = function(apiName, action, data){
                    gameProxy.callApi(apiName, action, data)
                        .then(function (data) {
                            me.callMessage = data;
                            me.lastCallsDisplay.push(data.payload.call);
                            removeFirstElement();
                            endOfGame.checkForWinner(data);
                            checkForNumber(data.payload.call);
                        }).catch(function (data) {
                            /* Error stub */
                            console.log(data);
                        });
                };

            me.getCall = function () {
                me.gameLoop = $interval(function(){
                    makeApiCall("game/getcall", "POST", getCallData);
                    getCallData.callnumber += 1;
                },1000, 90);

            };

        }]);
})();<commit_msg>Fixing more things<commit_after>(function () {
    'use strict';
    angular.module('Tombola.Games.Bingo90.Core')
        .service('BingoCall',  ['$interval','$state','BingoTicket','GameProxy','EndOfGame','SessionDetails', function ($interval, $state, bingoTicket, gameProxy, endOfGame, sessionDetails) {
            var me = this,
                sessionDetailsLogin = sessionDetails.login;
            me.lastCallsDisplay = [];
            var getCallData = {
                    gameId: 1,
                    userId: sessionDetails.login.username,
                    balance: sessionDetails.login.balance,
                    callnumber: 0
                },

                removeFirstElement = function () {
                    if(me.lastCallsDisplay.length >= 6){
                        me.lastCallsDisplay.splice(0, 1);
                    }
                },

                checkForNumber = function (callNumber) {
                    if(callNumber.toString().length < 2){
                        callNumber = "0"+callNumber.toString();
                    }

                    if(bingoTicket.balls.indexOf(callNumber.toString()) !== -1){
                        bingoTicket.markedNumbers[bingoTicket.balls.indexOf(callNumber.toString())] = "markedCell";
                    }
                },

                makeApiCall = function(apiName, action, data){
                    gameProxy.callApi(apiName, action, data)
                        .then(function (data) {
                            me.callMessage = data;
                            me.lastCallsDisplay.push(data.payload.call);
                            removeFirstElement();
                            endOfGame.checkForWinner(data);
                            checkForNumber(data.payload.call);
                        }).catch(function (data) {
                            /* Error stub */
                            console.log(data);
                        });
                };

            me.getCall = function () {
                me.gameLoop = $interval(function(){
                    makeApiCall("game/getcall", "POST", getCallData);
                    console.log(getCallData);
                    getCallData.callnumber += 1;
                },1000, 90);

            };

        }]);
})();<|endoftext|>


<commit_before>/*
 * Copyright (c) 2013 Taye Adeyemi
 * Open source under the MIT License.
 * https://raw.github.com/taye/interact.js/master/LICENSE
 */

(function(interact) {
    'use strict';

    var canvas,
        context,
        guidesCanvas,
        guidesContext,
        width = 800,
        height = 800,
        status,
        prevX = 0,
        prevY = 0,
        blue = '#2299ee',
        lightBlue = '#88ccff',
        peppermint = '#44ee44',
        tango = '#ff4400',
        draggingAnchor = null;

    function drawGrid (grid, gridOffset, range) {
        if (!grid.x || !grid.y) { return; }

        var barLength = 16;

        guidesContext.clearRect(0, 0, width, height);

        guidesContext.fillStyle = lightBlue;

        if (range < 0 || range === Infinity) {
            guidesContext.fillRect(0, 0, width, height);
        }

        for (var i = -(1 + gridOffset.x / grid.x | 0), lenX = width / grid.x + 1; i < lenX; i++) {
            for (var j = -( 1 + gridOffset.y / grid.y | 0), lenY = height / grid.y + 1; j < lenY; j++) {
                if (range > 0 && range !== Infinity) {
                    guidesContext.circle(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y, range, blue).fill();
                }

                guidesContext.beginPath();
                guidesContext.moveTo(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y - barLength / 2);
                guidesContext.lineTo(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y + barLength / 2);
                guidesContext.stroke();

                guidesContext.beginPath();
                guidesContext.moveTo(i * grid.x + gridOffset.x - barLength / 2, j * grid.y + gridOffset.y);
                guidesContext.lineTo(i * grid.x + gridOffset.x + barLength / 2, j * grid.y + gridOffset.y);
                guidesContext.stroke();
            }
        }
    }

    function drawAnchors (anchors, defaultRange) {
        var barLength = 16;

        guidesContext.clearRect(0, 0, width, height);

        if (range < 0 && range !== Infinity) {
            guidesContext.fillStyle = lightBlue;
            guidesContext.fillRect(0, 0, width, height);
        }

        for (var i = 0, len = anchors.length; i < len; i++) {
            var anchor = anchors[i],
                range = typeof anchor.range === 'number'? anchor.range: defaultRange;

            if (range > 0 && range !== Infinity) {
                guidesContext.circle(anchor.x, anchor.y, range, blue).fill();
            }

            guidesContext.beginPath();
            guidesContext.moveTo(anchor.x, anchor.y - barLength / 2);
            guidesContext.lineTo(anchor.x, anchor.y + barLength / 2);
            guidesContext.stroke();

            guidesContext.beginPath();
            guidesContext.moveTo(anchor.x - barLength / 2, anchor.y);
            guidesContext.lineTo(anchor.x + barLength / 2, anchor.y);
            guidesContext.stroke();
        }
    }

    function drawSnap (snap) {
        context.clearRect(0, 0, width, height);
        guidesContext.clearRect(0, 0, width, height);

        if (!status.offMode.checked) {
            if (snap.mode === 'grid') {
                drawGrid(snap.grid, snap.gridOffset, snap.range);
            }
            else if (snap.mode === 'anchor') {
                drawAnchors(snap.anchors, snap.range);
            }
        }
    }

    function circle (x, y, radius, color) {
        this.fillStyle = color || this.fillStyle;
        this.beginPath();
        this.arc(x, y, radius, 0, 2*Math.PI);

        return this;
    }
    window.CanvasRenderingContext2D.prototype.circle = circle;

    function dragMove (event) {
        var snap = event.snap;

        context.clearRect(0, 0, width, height);

        if (snap && snap.range !== Infinity && typeof snap.x === 'number' && typeof snap.y === 'number') {
            context.circle(snap.x, snap.y, snap.range + 1, 'rgba(102, 225, 117, 0.8)').fill();
        }

        context.circle(event.pageX, event.pageY, 10, tango).fill();

        prevX = event.pageX;
        prevY = event.pageY;
    }

    function dragEnd (event) {
        context.clearRect(0, 0, width, height);
        context.circle(event.pageX, event.pageY, 10, tango).fill();

        prevX = event.pageX;
        prevY = event.pageY;
    }

    function anchorDragStart (event) {
        if (event.snap.locked) {
            interact(canvas).snap(false);
            draggingAnchor = event.snap.anchors.closest;
        }
    }

    function anchorDragMove (event) {
        if (draggingAnchor) {
            var snap = interact(canvas).snap();

            draggingAnchor.x += event.dx;
            draggingAnchor.y += event.dy;

            drawAnchors(snap.anchors, snap.range);
        }
    }

    function anchorDragEnd (event) {
        interact(canvas).snap(true);
        draggingAnchor = null;
    }

    function sliderChange (event, valid) {
        if (!valid) {
            return;
        }

        interact(canvas).snap({
            grid: {
                x: Number(status.gridX.value),
                y: Number(status.gridY.value)
            },
            gridOffset: {
                x: Number(status.offsetX.value),
                y: Number(status.offsetY.value)
            },
            range: Number(status.range.value)
        });

        drawSnap(interact(canvas).snap());
    }

    function modeChange (event) {
        var snap = interact(canvas).snap(true).snap();

        if (status.anchorDrag.checked && !status.anchorMode.checked) {
            status.anchorMode.checked = true;
        }

        if (status.anchorDrag.checked) {
            status.anchorMode.disabled = status.offMode.disabled = status.gridMode.disabled = true;
            status.modes.classList.add('disabled');

            interact(canvas)
                .off('dragstart', dragMove)
                .off('dragmove', dragMove)
                .off('dragend', dragEnd)
                .on('dragstart', anchorDragStart)
                .on('dragmove', anchorDragMove)
                .on('dragend', anchorDragEnd);
        }
        else {
            status.anchorMode.disabled = status.offMode.disabled = status.gridMode.disabled = false;
            status.modes.classList.remove('disabled');

            interact(canvas)
                .on('dragstart', dragMove)
                .on('dragmove', dragMove)
                .on('dragend', dragEnd)
                .off('dragstart', anchorDragStart)
                .off('dragmove', anchorDragMove)
                .off('dragend', anchorDragEnd);
        }

        interact(canvas)
            .snap({
                mode: status.anchorMode.checked? 'anchor': 'grid',
                endOnly: status.endOnly.checked
            })
            .inertia(status.inertia.checked);

        interact(canvas).snap(status.offMode.checked? false: true);

        drawSnap(interact(canvas).snap());
    }

    function sliderInput (event) {
        if (event.target.type === 'range' &&
            (Number(event.target.value) > Number(event.target.max)) ||
            Number(event.target.value) < Number(event.target.min)) {

            return;
        }

        sliderChange(event, true);
    }

    interact.styleCursor(false);

    interact(document).on('DOMContentLoaded', function () {
        canvas = document.getElementById('drag');
        canvas.width = width;
        canvas.height = height;
        context = canvas.getContext('2d');

        interact(canvas)
            .snap({
                mode: 'grid',
                endOnly: true,
                grid: {x: 0, y: 0},
                gridOffset: {x: 0, y: 0},
                range: Infinity,
                anchors: [
                    {x: 100, y: 100, range: 200},
                    {x: 600, y: 400},
                    {x: 500, y: 150},
                    {x: 250, y: 250}
                ]
            })
            .draggable(true);

        guidesCanvas = document.getElementById('grid');
        guidesCanvas.width = width;
        guidesCanvas.height = height;
        guidesContext = guidesCanvas.getContext('2d');

        status = {
            container: document.getElementById('status'),

            sliders: document.getElementById('sliders'),
            gridX: document.getElementById('grid-x'),
            gridY: document.getElementById('grid-y'),
            offsetX: document.getElementById('offset-x'),
            offsetY: document.getElementById('offset-y'),
            range: document.getElementById('snap-range'),

            modes: document.getElementById('modes'),
            offMode: document.getElementById('off-mode'),
            gridMode: document.getElementById('grid-mode'),
            anchorMode: document.getElementById('anchor-mode'),
            anchorDrag: document.getElementById('drag-anchors'),
            endOnly: document.getElementById('end-only'),
            inertia: document.getElementById('inertia')
        };

        interact(status.sliders)
            .on('change', sliderChange)
            .on('input', sliderInput);

        interact(document.getElementById('modes'))
            .on('change', modeChange);

        sliderChange(null, true);
        modeChange();
    });

    window.grid = {
        drawGrid: drawGrid
    };

}(window.interact));
<commit_msg>Modify snap demo to work in IE9<commit_after>/*
 * Copyright (c) 2013 Taye Adeyemi
 * Open source under the MIT License.
 * https://raw.github.com/taye/interact.js/master/LICENSE
 */

(function(interact) {
    'use strict';

    var canvas,
        context,
        guidesCanvas,
        guidesContext,
        width = 800,
        height = 800,
        status,
        prevX = 0,
        prevY = 0,
        blue = '#2299ee',
        lightBlue = '#88ccff',
        peppermint = '#44ee44',
        tango = '#ff4400',
        draggingAnchor = null;

    function drawGrid (grid, gridOffset, range) {
        if (!grid.x || !grid.y) { return; }

        var barLength = 16;

        guidesContext.clearRect(0, 0, width, height);

        guidesContext.fillStyle = lightBlue;

        if (range < 0 || range === Infinity) {
            guidesContext.fillRect(0, 0, width, height);
        }

        for (var i = -(1 + gridOffset.x / grid.x | 0), lenX = width / grid.x + 1; i < lenX; i++) {
            for (var j = -( 1 + gridOffset.y / grid.y | 0), lenY = height / grid.y + 1; j < lenY; j++) {
                if (range > 0 && range !== Infinity) {
                    guidesContext.circle(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y, range, blue).fill();
                }

                guidesContext.beginPath();
                guidesContext.moveTo(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y - barLength / 2);
                guidesContext.lineTo(i * grid.x + gridOffset.x, j * grid.y + gridOffset.y + barLength / 2);
                guidesContext.stroke();

                guidesContext.beginPath();
                guidesContext.moveTo(i * grid.x + gridOffset.x - barLength / 2, j * grid.y + gridOffset.y);
                guidesContext.lineTo(i * grid.x + gridOffset.x + barLength / 2, j * grid.y + gridOffset.y);
                guidesContext.stroke();
            }
        }
    }

    function drawAnchors (anchors, defaultRange) {
        var barLength = 16;

        guidesContext.clearRect(0, 0, width, height);

        if (range < 0 && range !== Infinity) {
            guidesContext.fillStyle = lightBlue;
            guidesContext.fillRect(0, 0, width, height);
        }

        for (var i = 0, len = anchors.length; i < len; i++) {
            var anchor = anchors[i],
                range = typeof anchor.range === 'number'? anchor.range: defaultRange;

            if (range > 0 && range !== Infinity) {
                guidesContext.circle(anchor.x, anchor.y, range, blue).fill();
            }

            guidesContext.beginPath();
            guidesContext.moveTo(anchor.x, anchor.y - barLength / 2);
            guidesContext.lineTo(anchor.x, anchor.y + barLength / 2);
            guidesContext.stroke();

            guidesContext.beginPath();
            guidesContext.moveTo(anchor.x - barLength / 2, anchor.y);
            guidesContext.lineTo(anchor.x + barLength / 2, anchor.y);
            guidesContext.stroke();
        }
    }

    function drawSnap (snap) {
        context.clearRect(0, 0, width, height);
        guidesContext.clearRect(0, 0, width, height);

        if (!status.offMode.checked) {
            if (snap.mode === 'grid') {
                drawGrid(snap.grid, snap.gridOffset, snap.range);
            }
            else if (snap.mode === 'anchor') {
                drawAnchors(snap.anchors, snap.range);
            }
        }
    }

    function circle (x, y, radius, color) {
        this.fillStyle = color || this.fillStyle;
        this.beginPath();
        this.arc(x, y, radius, 0, 2*Math.PI);

        return this;
    }
    window.CanvasRenderingContext2D.prototype.circle = circle;

    function dragMove (event) {
        var snap = event.snap;

        context.clearRect(0, 0, width, height);

        if (snap && snap.range !== Infinity && typeof snap.x === 'number' && typeof snap.y === 'number') {
            context.circle(snap.x, snap.y, snap.range + 1, 'rgba(102, 225, 117, 0.8)').fill();
        }

        context.circle(event.pageX, event.pageY, 10, tango).fill();

        prevX = event.pageX;
        prevY = event.pageY;
    }

    function dragEnd (event) {
        context.clearRect(0, 0, width, height);
        context.circle(event.pageX, event.pageY, 10, tango).fill();

        prevX = event.pageX;
        prevY = event.pageY;
    }

    function anchorDragStart (event) {
        if (event.snap.locked) {
            interact(canvas).snap(false);
            draggingAnchor = event.snap.anchors.closest;
        }
    }

    function anchorDragMove (event) {
        if (draggingAnchor) {
            var snap = interact(canvas).snap();

            draggingAnchor.x += event.dx;
            draggingAnchor.y += event.dy;

            drawAnchors(snap.anchors, snap.range);
        }
    }

    function anchorDragEnd (event) {
        interact(canvas).snap(true);
        draggingAnchor = null;
    }

    function sliderChange (event, valid) {
        if (!valid) {
            return;
        }

        interact(canvas).snap({
            grid: {
                x: Number(status.gridX.value),
                y: Number(status.gridY.value)
            },
            gridOffset: {
                x: Number(status.offsetX.value),
                y: Number(status.offsetY.value)
            },
            range: Number(status.range.value)
        });

        drawSnap(interact(canvas).snap());
    }

    function modeChange (event) {
        var snap = interact(canvas).snap(true).snap();

        if (status.anchorDrag.checked && !status.anchorMode.checked) {
            status.anchorMode.checked = true;
        }

        if (status.anchorDrag.checked) {
            status.anchorMode.disabled = status.offMode.disabled = status.gridMode.disabled = true;
            status.modes.className += ' disabled';

            interact(canvas)
                .off('dragstart', dragMove)
                .off('dragmove', dragMove)
                .off('dragend', dragEnd)
                .on('dragstart', anchorDragStart)
                .on('dragmove', anchorDragMove)
                .on('dragend', anchorDragEnd);
        }
        else {
            status.anchorMode.disabled = status.offMode.disabled = status.gridMode.disabled = false;
            status.modes.className = status.modes.className.replace(/ *\<disabled\>/g, '');

            interact(canvas)
                .on('dragstart', dragMove)
                .on('dragmove', dragMove)
                .on('dragend', dragEnd)
                .off('dragstart', anchorDragStart)
                .off('dragmove', anchorDragMove)
                .off('dragend', anchorDragEnd);
        }

        interact(canvas)
            .snap({
                mode: status.anchorMode.checked? 'anchor': 'grid',
                endOnly: status.endOnly.checked
            })
            .inertia(status.inertia.checked);

        interact(canvas).snap(status.offMode.checked? false: true);

        drawSnap(interact(canvas).snap());
    }

    function sliderInput (event) {
        if (event.target.type === 'range' &&
            (Number(event.target.value) > Number(event.target.max)) ||
            Number(event.target.value) < Number(event.target.min)) {

            return;
        }

        sliderChange(event, true);
    }

    interact.styleCursor(false);

    interact(document).on('DOMContentLoaded', function () {
        canvas = document.getElementById('drag');
        canvas.width = width;
        canvas.height = height;
        context = canvas.getContext('2d');

        interact(canvas)
            .snap({
                mode: 'grid',
                endOnly: true,
                grid: {x: 0, y: 0},
                gridOffset: {x: 0, y: 0},
                range: Infinity,
                anchors: [
                    {x: 100, y: 100, range: 200},
                    {x: 600, y: 400},
                    {x: 500, y: 150},
                    {x: 250, y: 250}
                ]
            })
            .draggable(true);

        guidesCanvas = document.getElementById('grid');
        guidesCanvas.width = width;
        guidesCanvas.height = height;
        guidesContext = guidesCanvas.getContext('2d');

        status = {
            container: document.getElementById('status'),

            sliders: document.getElementById('sliders'),
            gridX: document.getElementById('grid-x'),
            gridY: document.getElementById('grid-y'),
            offsetX: document.getElementById('offset-x'),
            offsetY: document.getElementById('offset-y'),
            range: document.getElementById('snap-range'),

            modes: document.getElementById('modes'),
            offMode: document.getElementById('off-mode'),
            gridMode: document.getElementById('grid-mode'),
            anchorMode: document.getElementById('anchor-mode'),
            anchorDrag: document.getElementById('drag-anchors'),
            endOnly: document.getElementById('end-only'),
            inertia: document.getElementById('inertia')
        };

        interact(status.sliders)
            .on('change', sliderChange)
            .on('input', sliderInput);

        interact(document.getElementById('modes'))
            .on('change', modeChange);

        sliderChange(null, true);
        modeChange();
    });

    window.grid = {
        drawGrid: drawGrid
    };

}(window.interact));
<|endoftext|>


<commit_before>
/*
 |--------------------------------------------------------------------------
 | Browser-sync config file
 |--------------------------------------------------------------------------
 |
 | For up-to-date information about the options:
 |   http://www.browsersync.io/docs/options/
 |
 | There are more options than you see here, these are just the ones that are
 | set internally. See the website for more info.
 |
 |
 */
module.exports = {
  ui: false,
  files: "build/*",
  server: {
    baseDir: "build",
    directory: true
  },
  port: 3000,
  open: false,
  cors: true
};
<commit_msg>Using port 8000 on browsersync (to avoid conflicts with our projects)<commit_after>
/*
 |--------------------------------------------------------------------------
 | Browser-sync config file
 |--------------------------------------------------------------------------
 |
 | For up-to-date information about the options:
 |   http://www.browsersync.io/docs/options/
 |
 | There are more options than you see here, these are just the ones that are
 | set internally. See the website for more info.
 |
 |
 */
module.exports = {
  ui: false,
  files: "build/*",
  server: {
    baseDir: "build",
    directory: true
  },
  port: 8000,
  open: false,
  cors: true
};
<|endoftext|>


<commit_before>// Generated by CoffeeScript 1.7.0
(function() {
  var fs, optimist, path, preresolve, resolve;

  fs = require('fs');

  path = require('path');

  resolve = require('resolve');

  preresolve = function(infile, basedir) {
    "Takes a file path to a JS file and transforms all the `require` statements\nin it into ones that have already been `require.resolve`d. This should make\nstarting up faster.";
    var input, output;
    if (basedir == null) {
      basedir = path.resolve(path.dirname(infile));
    }
    input = fs.readFileSync(infile, 'utf-8');
    output = input.replace(/^([^"]*\b)require\(([^\)]*)\)/g, function(_fullMatch, before, toRequireExpr) {
      var resolved, toRequire;
      toRequire = eval(toRequireExpr);
      if (resolve.isCore(toRequire)) {
        return "" + before + "require(" + (JSON.stringify(toRequire)) + ")";
      } else {
        resolved = resolve.sync(toRequire, {
          basedir: basedir
        });
        return "" + before + "require(" + (JSON.stringify("./" + (path.relative(basedir, resolved)))) + ")";
      }
    });
    return output;
  };

  if (require.main === module) {
    optimist = require('optimist');
    console.log(preresolve(optimist.argv._[0]));
  }

  module.exports = preresolve;

}).call(this);
<commit_msg>Forgot to build :(<commit_after>// Generated by CoffeeScript 1.7.0
(function() {
  var File, fs, infile, optimist, path, preresolve, resolve;

  fs = require('fs');

  path = require('path');

  resolve = require('resolve');

  File = require('vinyl');

  preresolve = function(file) {
    "Takes a vinyl-like JS file object and transforms all the `require` statements\nin it into ones that have already been `require.resolve`d. This should make\nstarting up faster.";
    var basedir, infile, input, output;
    basedir = path.resolve(path.dirname(infile));
    infile = file.path;
    input = file.contents.toString('utf-8');
    output = input.replace(/^([^"]*\b)require\(([^\)]*)\)/g, function(_fullMatch, before, toRequireExpr) {
      var resolved, toRequire;
      toRequire = eval(toRequireExpr);
      if (resolve.isCore(toRequire)) {
        return "" + before + "require(" + (JSON.stringify(toRequire)) + ")";
      } else {
        resolved = resolve.sync(toRequire, {
          basedir: basedir
        });
        return "" + before + "require(" + (JSON.stringify("./" + (path.relative(basedir, resolved)))) + ")";
      }
    });
    return new Buffer(output, 'utf-8');
  };

  if (require.main === module) {
    optimist = require('optimist');
    infile = optimist.argv._[0];
    console.log((preresolve(new File({
      cwd: process.cwd(),
      base: path.dirname(infile),
      path: infile,
      contents: fs.readFileSync(infile)
    }))).toString('utf-8'));
  }

  module.exports = preresolve;

}).call(this);
<|endoftext|>


<commit_before>(function(){
window.FactView = Backbone.View.extend({
  tagName: "div",

  className: "fact-block",

  _currentVisibleDropdown: undefined,

  events: {
    "click a.remove": "removeFactFromChannel",
    "click li.destroy": "destroyFact",
	  "click .controls .supporting, .controls .weakening": "toggleEvidence",
    "click .controls .supporting a.add-button,    .controls .weakening a.add-button": "showAddRelation",
    "click .controls .supporting a.cancel-button, .controls .weakening a.cancel-button": "hideAddRelation"
  },

  initialize: function(opts) {
    this.useTemplate('facts','_fact'); // use after setting this.tmpl
    this.model.bind('destroy', this.remove, this);

    $(this.el).attr('data-fact-id', this.model.id);
  },

  partials: {},

  render: function() {
    $( this.el )
      .html( Mustache.to_html(this.tmpl, this.model.toJSON(), this.partials)).factlink();

    this.initAddToChannel();
    this.initFactRelationsViews();
    this.initUserPassportViews();

    return this;
  },

  remove: function() {
    $(this.el).fadeOut('fast', function() {
      $(this.el).remove();
    });

    // Hides the popup (if necessary)
    if ( parent.remote ) {
      parent.remote.hide();
      parent.remote.stopHighlightingFactlink(this.model.id);
    }
  },

  removeFactFromChannel: function() {
    this.model.destroy({
      error: function() {
        alert("Error while removing Factlink from Channel" );
      },
      forChannel: true
    });
  },

  destroyFact: function() {
    this.model.destroy({
      error: function() {
        alert("Error while removing the Factlink" );
      },
      forChannel: false
    });
  },

  initAddToChannel: function() {
    if ( $(this.el).find('.channel-listing') && typeof currentUser !== "undefined" ) {

      var addToChannelView = new AddToChannelView({
        collection: currentUser.channels,

        el: $(this.el).find('.channel-listing'),

        model: this.model,

        forFact: this.model
      }).render();

      // Channels are in the container
      $('.add-to-channel', this.el)
        .hoverIntent(function(e) {
          addToChannelView.el.fadeIn("fast");
        }, function() {
          addToChannelView.el.delay(600).fadeOut("fast");
        });
    }
  },

  initFactRelationsViews: function() {
    var supportingFactRelations = new SupportingFactRelations([], { fact: this.model } );
    var weakeningFactRelations = new WeakeningFactRelations([], { fact: this.model } );

    this.supportingFactRelationsView = new FactRelationsView({
      collection: supportingFactRelations,
      type: "supporting"
    });

    this.weakeningFactRelationsView = new FactRelationsView({
      collection: weakeningFactRelations,
      type: "weakening"
    });

    $('.dropdown-container', this.el)
      .append( this.supportingFactRelationsView.render().el )
      .append( this.weakeningFactRelationsView.render().el );
  },

  showDropdownContainer: function(className) {
    if (typeof this._currentVisibleDropdown === "undefined") {
      $('.dropdown-container', this.el).slideDown('fast');
    }

    $(this.el).addClass("active");
  },

  hideDropdownContainer: function(className) {
    $(this.el).removeClass("active");

    $('.dropdown-container', this.el).slideUp('fast');
  },

  switchToRelationDropdown: function(type){
    if (type === "supporting") {
      this.weakeningFactRelationsView.hide();
      this.supportingFactRelationsView.showAndFetch();
    } else {
      this.supportingFactRelationsView.hide();
      this.weakeningFactRelationsView.showAndFetch();
    }
  },

  toggleEvidence: function(e) {
    var $target = $(e.target).closest('li');
    var $tabButtons = $(this.el).find('.controls li');
    var type = $target.hasClass('supporting') ? 'supporting' : 'weakening';

    $tabButtons.removeClass("active");

    if ( type !== this._currentVisibleDropdown ) {
      this.showDropdownContainer(type);

      this._currentVisibleDropdown = type;

      this.switchToRelationDropdown(type);

      $target.addClass("active");
    } else {
      this.hideDropdownContainer();

      this._currentVisibleDropdown = undefined;
    }
  },

  showAddRelation: function(e) {
    e.stopPropagation();

    $(e.target).toggleClass('add-button cancel-button');

    if ( this._currentVisibleDropdown === "supporting" ) {
      this.supportingFactRelationsView.showSearch();
    } else {
      this.weakeningFactRelationsView.showSearch();
    }
  },

  hideAddRelation: function(e) {
    e.stopPropagation();

    $(e.target).toggleClass('add-button cancel-button');

    if ( this._currentVisibleDropdown === "supporting" ) {
      this.supportingFactRelationsView.hideSearch();
    } else {
      this.weakeningFactRelationsView.hideSearch();
    }
  },

  initUserPassportViews: function() {
    var self = this;
    $(this.model.get("last_active_users")).each(function()  {
      var el = $("li.user[data-user-id="+ this.graph_id + "]", self.el);
      var model = new User(this);
      var view = new UserPassportView({model: model, el: el});
    });
  }
});
})();
<commit_msg>Bind "Add evidence to" to triggering of adding evidence<commit_after>(function(){
window.FactView = Backbone.View.extend({
  tagName: "div",

  className: "fact-block",

  _currentVisibleDropdown: undefined,

  events: {
    "click a.remove": "removeFactFromChannel",
    "click li.destroy": "destroyFact",
	  "click .controls .supporting, .controls .weakening": "toggleEvidence",
    "click .controls .supporting a.add-button,    .controls .weakening a.add-button, .no-evidence-message .do-add": "showAddRelation",
    "click .controls .supporting a.cancel-button, .controls .weakening a.cancel-button": "hideAddRelation"
  },

  initialize: function(opts) {
    this.useTemplate('facts','_fact'); // use after setting this.tmpl
    this.model.bind('destroy', this.remove, this);

    $(this.el).attr('data-fact-id', this.model.id);
  },

  partials: {},

  render: function() {
    $( this.el )
      .html( Mustache.to_html(this.tmpl, this.model.toJSON(), this.partials)).factlink();

    this.initAddToChannel();
    this.initFactRelationsViews();
    this.initUserPassportViews();

    return this;
  },

  remove: function() {
    $(this.el).fadeOut('fast', function() {
      $(this.el).remove();
    });

    // Hides the popup (if necessary)
    if ( parent.remote ) {
      parent.remote.hide();
      parent.remote.stopHighlightingFactlink(this.model.id);
    }
  },

  removeFactFromChannel: function() {
    this.model.destroy({
      error: function() {
        alert("Error while removing Factlink from Channel" );
      },
      forChannel: true
    });
  },

  destroyFact: function() {
    this.model.destroy({
      error: function() {
        alert("Error while removing the Factlink" );
      },
      forChannel: false
    });
  },

  initAddToChannel: function() {
    if ( $(this.el).find('.channel-listing') && typeof currentUser !== "undefined" ) {

      var addToChannelView = new AddToChannelView({
        collection: currentUser.channels,

        el: $(this.el).find('.channel-listing'),

        model: this.model,

        forFact: this.model
      }).render();

      // Channels are in the container
      $('.add-to-channel', this.el)
        .hoverIntent(function(e) {
          addToChannelView.el.fadeIn("fast");
        }, function() {
          addToChannelView.el.delay(600).fadeOut("fast");
        });
    }
  },

  initFactRelationsViews: function() {
    var supportingFactRelations = new SupportingFactRelations([], { fact: this.model } );
    var weakeningFactRelations = new WeakeningFactRelations([], { fact: this.model } );

    this.supportingFactRelationsView = new FactRelationsView({
      collection: supportingFactRelations,
      type: "supporting"
    });

    this.weakeningFactRelationsView = new FactRelationsView({
      collection: weakeningFactRelations,
      type: "weakening"
    });

    $('.dropdown-container', this.el)
      .append( this.supportingFactRelationsView.render().el )
      .append( this.weakeningFactRelationsView.render().el );
  },

  showDropdownContainer: function(className) {
    if (typeof this._currentVisibleDropdown === "undefined") {
      $('.dropdown-container', this.el).slideDown('fast');
    }

    $(this.el).addClass("active");
  },

  hideDropdownContainer: function(className) {
    $(this.el).removeClass("active");

    $('.dropdown-container', this.el).slideUp('fast');
  },

  switchToRelationDropdown: function(type){
    if (type === "supporting") {
      this.weakeningFactRelationsView.hide();
      this.supportingFactRelationsView.showAndFetch();
    } else {
      this.supportingFactRelationsView.hide();
      this.weakeningFactRelationsView.showAndFetch();
    }
  },

  toggleEvidence: function(e) {
    var $target = $(e.target).closest('li');
    var $tabButtons = $(this.el).find('.controls li');
    var type = $target.hasClass('supporting') ? 'supporting' : 'weakening';

    $tabButtons.removeClass("active");

    if ( type !== this._currentVisibleDropdown ) {
      this.showDropdownContainer(type);

      this._currentVisibleDropdown = type;

      this.switchToRelationDropdown(type);

      $target.addClass("active");
    } else {
      this.hideDropdownContainer();

      this._currentVisibleDropdown = undefined;
    }
  },

  showAddRelation: function(e) {
    e.stopPropagation();

    $(e.target).toggleClass('add-button cancel-button');

    if ( this._currentVisibleDropdown === "supporting" ) {
      this.supportingFactRelationsView.showSearch();
    } else {
      this.weakeningFactRelationsView.showSearch();
    }
  },

  hideAddRelation: function(e) {
    e.stopPropagation();

    $(e.target).toggleClass('add-button cancel-button');

    if ( this._currentVisibleDropdown === "supporting" ) {
      this.supportingFactRelationsView.hideSearch();
    } else {
      this.weakeningFactRelationsView.hideSearch();
    }
  },

  initUserPassportViews: function() {
    var self = this;
    $(this.model.get("last_active_users")).each(function()  {
      var el = $("li.user[data-user-id="+ this.graph_id + "]", self.el);
      var model = new User(this);
      var view = new UserPassportView({model: model, el: el});
    });
  }
});
})();
<|endoftext|>


<commit_before>'use strict';

// Fractal Continuum
[{
  zoneRegex: /^The Fractal Continuum$/,
  timelineFile: 'fractal_continuum.txt',
  timelineTriggers: [
    {
      id: 'Fractal Atmospheric Displacement',
      regex: /Atmospheric Displacement/,
      beforeSeconds: 5,
      condition: function(data) {
        return data.role == healer;
      },
      infoText: {
        en: 'AoE',
      },
    },
    {
      id: 'Fractal Sanctification',
      regex: /Sanctification/,
      beforeSeconds: 5,
      infoText: function(data) {
        if (data.role == 'tank') {
          return {
            en: 'Tank cleave on YOU',
          };
        }
        return {
          en: 'Avoid tank cleave',
        };
      },
    },
    {
      id: 'Fractal Unholy',
      regex: /Unholy/,
      beforeSeconds: 5,
      condition: function(data) {
        return data.role == 'healer';
      },
      infoText: {
        en: 'AoE',
      },
    },
  ],
  triggers: [
    {
      id: 'Fractal Rapid Sever',
      regex: / 14:F7A:Phantom Ray starts using Rapid Sever on (\y{Name})/,
      regexDe: / 14:F7A:Phantomschimmer starts using Radikale Abtrennung on (\y{Name})/,
      regexFr: / 14:F7A:Rayon Fantomatique starts using Tranchage Rapide on (\y{Name})/,
      regexJa: / 14:F7A:ファントムレイ starts using 滅多斬り on (\y{Name})/,
      infoText: function(data, matches) {
        if (data.me == matches[1]) {
          return {
            en: 'Tank buster on YOU',
          };
        }
        if (data.role == 'healer') {
          return {
            en: 'Buster on ' + data.shortName(matches[1]),
          };
        }
      },
    },
    {
      id: 'Fractal Slash',
      regex: / 14:F83:Minotaur starts using 10-Tonze Slash/,
      regexDe: / 14:F83:Minotaurus starts using 11-Tonzen-Schlag/,
      regexFr: / 14:F83:Minotaure starts using Taillade De 10 Tonz/,
      regexJa: / 14:F83:ミノタウロス starts using 10トンズ・スラッシュ/,
      infoText: {
        en: 'Out of front',
      },
    },
    {
      id: 'Fractal Swipe',
      regex: / 14:F81:Minotaur starts using 11-Tonze Swipe/,
      regexDe: / 14:F81:Minotaurus starts using 11-Tonzen-Hieb/,
      regexFr: / 14:F81:Minotaure starts using Fauche De 11 Tonz/,
      regexJa: / 14:F81:ミノタウロス starts using 11トンズ・スワイプ/,
      infoText: {
        en: 'Out of front',
      },
    },
    {
      id: 'Fractal Small Swing',
      regex: / 14:F82:Minotaur starts using 111-Tonze Swing/,
      regexDe: / 14:F82:Minotaurus starts using 111-Tonzen-Schwung/,
      regexFr: / 14:F82:Minotaure starts using Swing De 111 Tonz/,
      regexJa: / 14:F82:ミノタウロス starts using 111トンズ・スイング/,
      infoText: {
        en: 'Get out',
      },
    },
    {
      id: 'Fractal Big Swing',
      regex: / 14:F87:Minotaur starts using 1111-Tonze Swing/,
      regexDe: / 14:F87:Minotaurus starts using 1111-Tonzen-Schwung/,
      regexFr: / 14:F87:Minotaure starts using Swing De 1111 Tonz/,
      regexJa: / 14:F87:ミノタウロス starts using 1111トンズ・スイング/,
      alertText: {
        en: 'Use a cage',
      },
    },
    {
      id: 'Fractal Aetherochemical Bomb',
      regex: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Aetherochemical Bomb/,
      regexDe: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Ätherochemischer Sprengkörper/,
      regexFr: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Magismobombe/,
      regexJa: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of 魔爆弾/,
      condition: function(data) {
        return data.CanCleanse();
      },
      infoText: {
        en: 'Cleanse bomb',
      },
    },
    {
      id: 'Fractal Alarums',
      regex: / 03:(\y{ObjectId}):Added new combatant Clockwork Alarum/,
      regexDe: / 03:(\y{ObjectId}):Added new combatant Uhrwerk-Alarm/,
      regexFr: / 03:(\y{ObjectId}):Added new combatant Alarum Mécanique/,
      regexJa: / 03:(\y{ObjectId}):Added new combatant アラガンワーク・アラーム/,
      suppressSeconds: 5,
      infoText: {
        en: 'Kill adds',
      },
    },
  ],
  timelineReplace: [
    {
      'locale': 'de',
      'replaceSync': {
        'Phantom Ray': 'Phantomschimmer',
        'Minotaur': 'Minotaurus',
        'The Curator': 'Kurator',

        'Exhibit level III will be sealed off': 'Ausstellungssektor III schließt',
        'The high-level incubation bay will be sealed off': 'Inkubationskammer schließt',
        'The reality augmentation bay will be sealed off': 'Dilatationskammer schließt',
      },
      'replaceText': {
        'Rapid Sever': 'Radikale Abtrennung',
        'Atmospheric Displacement': 'Schnitttest',
        'Double Sever': 'Zweifachabtrennung',
        'Damage Up': 'Schaden +',
        'Atmospheric Compression': 'Schnittdruck',

        '11-Tonze Swipe': '11-Tonzen-Hieb',
        '111-Tonze Swing': '111-Tonzen-Schwung',
        'Disorienting Groan': 'Kampfgebrüll',
        'Zoom': 'Heranholen',
        '10-Tonze Slash': '11-Tonzen-Schlag', // FIXME: Check XIVAPI's correctness on this one
        '1111-Tonze Swing': '1111-Tonzen-Schwung',
        'Feast': 'Festmahl',

        'Sanctification': 'Sanktifikation',
        'Unholy': 'Unheilig',
        'Aetherochemical Explosive': 'Ätherochemisches Explosivum',
        'The Educator': 'Zuchtmeister',
        'Aetherochemical Mine': 'Ätherochemische Mine',
      },
    },
    {
      'locale': 'fr',
      'replaceSync': {
        'Phantom Ray': 'Rayon Fantomatique',
        'Minotaur': 'Minotaure',
        'The Curator': 'Conservateur',

        // FIXME
        'Exhibit level III will be sealed off': 'Exhibit level III will be sealed off',
        'The high-level incubation bay will be sealed off': 'The high-level incubation bay will be sealed off',
        'The reality augmentation bay will be sealed off': 'The reality augmentation bay will be sealed off',
      },
      'replaceText': {
        'Rapid Sever': 'Tranchage rapide',
        'Atmospheric Displacement': 'Moulinet infernal',
        'Double Sever': 'Double tranchage',
        'Damage Up': 'Bonus de dégâts physiques',
        'Atmospheric Compression': 'Écrasement',

        '11-Tonze Swipe': 'Fauche de 11 tonz',
        '111-Tonze Swing': 'Swing de 111 tonz',
        'Disorienting Groan': 'Cri désorientant',
        'Zoom': 'Charge',
        '10-Tonze Slash': 'Taillade de 10 tonz',
        '1111-Tonze Swing': 'Swing de 1111 tonz',
        'Feast': 'Festin',

        'Sanctification': 'Sanctification',
        'Unholy': 'Sombre miracle',
        'Aetherochemical Explosive': 'Bombe magismologique',
        'The Educator': 'Disciplinaire',
        'Aetherochemical Mine': 'Mine magismologique',
      },
    },
    {
      'locale': 'ja',
      'replaceSync': {
        'Phantom Ray': 'ファントムレイ',
        'Minotaur': 'ミノタウロス',
        'The Curator': 'キュレーター',

        // FIXME
        'Exhibit level III will be sealed off': 'Exhibit level III will be sealed off',
        'The high-level incubation bay will be sealed off': 'The high-level incubation bay will be sealed off',
        'The reality augmentation bay will be sealed off': 'The reality augmentation bay will be sealed off',
      },
      'replaceText': {
        'Rapid Sever': '滅多斬り',
        'Atmospheric Displacement': '剣風',
        'Double Sever': '多重斬り',
        'Damage Up': 'ダメージ上昇',
        'Atmospheric Compression': '剣圧',

        '11-Tonze Swipe': '11トンズ・スワイプ',
        '111-Tonze Swing': '111トンズ・スイング',
        'Disorienting Groan': '雄叫び',
        'Zoom': 'ズームイン',
        '10-Tonze Slash': '10トンズ・スラッシュ',
        '1111-Tonze Swing': '1111トンズ・スイング',
        'Feast': 'フィースト',

        'Sanctification': '聖別の光',
        'Unholy': 'アンホーリー',
        'Aetherochemical Explosive': '魔科学爆弾',
        'The Educator': 'エデュケーター',
        'Aetherochemical Mine': '魔科学地雷',
      },
    },
  ],
}];
<commit_msg>raidboss: Fix Missing Quotes for Healer Conditional (#653)<commit_after>'use strict';

// Fractal Continuum
[{
  zoneRegex: /^The Fractal Continuum$/,
  timelineFile: 'fractal_continuum.txt',
  timelineTriggers: [
    {
      id: 'Fractal Atmospheric Displacement',
      regex: /Atmospheric Displacement/,
      beforeSeconds: 5,
      condition: function(data) {
        return data.role == 'healer';
      },
      infoText: {
        en: 'AoE',
      },
    },
    {
      id: 'Fractal Sanctification',
      regex: /Sanctification/,
      beforeSeconds: 5,
      infoText: function(data) {
        if (data.role == 'tank') {
          return {
            en: 'Tank cleave on YOU',
          };
        }
        return {
          en: 'Avoid tank cleave',
        };
      },
    },
    {
      id: 'Fractal Unholy',
      regex: /Unholy/,
      beforeSeconds: 5,
      condition: function(data) {
        return data.role == 'healer';
      },
      infoText: {
        en: 'AoE',
      },
    },
  ],
  triggers: [
    {
      id: 'Fractal Rapid Sever',
      regex: / 14:F7A:Phantom Ray starts using Rapid Sever on (\y{Name})/,
      regexDe: / 14:F7A:Phantomschimmer starts using Radikale Abtrennung on (\y{Name})/,
      regexFr: / 14:F7A:Rayon Fantomatique starts using Tranchage Rapide on (\y{Name})/,
      regexJa: / 14:F7A:ファントムレイ starts using 滅多斬り on (\y{Name})/,
      infoText: function(data, matches) {
        if (data.me == matches[1]) {
          return {
            en: 'Tank buster on YOU',
          };
        }
        if (data.role == 'healer') {
          return {
            en: 'Buster on ' + data.shortName(matches[1]),
          };
        }
      },
    },
    {
      id: 'Fractal Slash',
      regex: / 14:F83:Minotaur starts using 10-Tonze Slash/,
      regexDe: / 14:F83:Minotaurus starts using 11-Tonzen-Schlag/,
      regexFr: / 14:F83:Minotaure starts using Taillade De 10 Tonz/,
      regexJa: / 14:F83:ミノタウロス starts using 10トンズ・スラッシュ/,
      infoText: {
        en: 'Out of front',
      },
    },
    {
      id: 'Fractal Swipe',
      regex: / 14:F81:Minotaur starts using 11-Tonze Swipe/,
      regexDe: / 14:F81:Minotaurus starts using 11-Tonzen-Hieb/,
      regexFr: / 14:F81:Minotaure starts using Fauche De 11 Tonz/,
      regexJa: / 14:F81:ミノタウロス starts using 11トンズ・スワイプ/,
      infoText: {
        en: 'Out of front',
      },
    },
    {
      id: 'Fractal Small Swing',
      regex: / 14:F82:Minotaur starts using 111-Tonze Swing/,
      regexDe: / 14:F82:Minotaurus starts using 111-Tonzen-Schwung/,
      regexFr: / 14:F82:Minotaure starts using Swing De 111 Tonz/,
      regexJa: / 14:F82:ミノタウロス starts using 111トンズ・スイング/,
      infoText: {
        en: 'Get out',
      },
    },
    {
      id: 'Fractal Big Swing',
      regex: / 14:F87:Minotaur starts using 1111-Tonze Swing/,
      regexDe: / 14:F87:Minotaurus starts using 1111-Tonzen-Schwung/,
      regexFr: / 14:F87:Minotaure starts using Swing De 1111 Tonz/,
      regexJa: / 14:F87:ミノタウロス starts using 1111トンズ・スイング/,
      alertText: {
        en: 'Use a cage',
      },
    },
    {
      id: 'Fractal Aetherochemical Bomb',
      regex: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Aetherochemical Bomb/,
      regexDe: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Ätherochemischer Sprengkörper/,
      regexFr: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of Magismobombe/,
      regexJa: / 1A:(\y{ObjectId}):(\y{Name}) gains the effect of 魔爆弾/,
      condition: function(data) {
        return data.CanCleanse();
      },
      infoText: {
        en: 'Cleanse bomb',
      },
    },
    {
      id: 'Fractal Alarums',
      regex: / 03:(\y{ObjectId}):Added new combatant Clockwork Alarum/,
      regexDe: / 03:(\y{ObjectId}):Added new combatant Uhrwerk-Alarm/,
      regexFr: / 03:(\y{ObjectId}):Added new combatant Alarum Mécanique/,
      regexJa: / 03:(\y{ObjectId}):Added new combatant アラガンワーク・アラーム/,
      suppressSeconds: 5,
      infoText: {
        en: 'Kill adds',
      },
    },
  ],
  timelineReplace: [
    {
      'locale': 'de',
      'replaceSync': {
        'Phantom Ray': 'Phantomschimmer',
        'Minotaur': 'Minotaurus',
        'The Curator': 'Kurator',

        'Exhibit level III will be sealed off': 'Ausstellungssektor III schließt',
        'The high-level incubation bay will be sealed off': 'Inkubationskammer schließt',
        'The reality augmentation bay will be sealed off': 'Dilatationskammer schließt',
      },
      'replaceText': {
        'Rapid Sever': 'Radikale Abtrennung',
        'Atmospheric Displacement': 'Schnitttest',
        'Double Sever': 'Zweifachabtrennung',
        'Damage Up': 'Schaden +',
        'Atmospheric Compression': 'Schnittdruck',

        '11-Tonze Swipe': '11-Tonzen-Hieb',
        '111-Tonze Swing': '111-Tonzen-Schwung',
        'Disorienting Groan': 'Kampfgebrüll',
        'Zoom': 'Heranholen',
        '10-Tonze Slash': '11-Tonzen-Schlag', // FIXME: Check XIVAPI's correctness on this one
        '1111-Tonze Swing': '1111-Tonzen-Schwung',
        'Feast': 'Festmahl',

        'Sanctification': 'Sanktifikation',
        'Unholy': 'Unheilig',
        'Aetherochemical Explosive': 'Ätherochemisches Explosivum',
        'The Educator': 'Zuchtmeister',
        'Aetherochemical Mine': 'Ätherochemische Mine',
      },
    },
    {
      'locale': 'fr',
      'replaceSync': {
        'Phantom Ray': 'Rayon Fantomatique',
        'Minotaur': 'Minotaure',
        'The Curator': 'Conservateur',

        // FIXME
        'Exhibit level III will be sealed off': 'Exhibit level III will be sealed off',
        'The high-level incubation bay will be sealed off': 'The high-level incubation bay will be sealed off',
        'The reality augmentation bay will be sealed off': 'The reality augmentation bay will be sealed off',
      },
      'replaceText': {
        'Rapid Sever': 'Tranchage rapide',
        'Atmospheric Displacement': 'Moulinet infernal',
        'Double Sever': 'Double tranchage',
        'Damage Up': 'Bonus de dégâts physiques',
        'Atmospheric Compression': 'Écrasement',

        '11-Tonze Swipe': 'Fauche de 11 tonz',
        '111-Tonze Swing': 'Swing de 111 tonz',
        'Disorienting Groan': 'Cri désorientant',
        'Zoom': 'Charge',
        '10-Tonze Slash': 'Taillade de 10 tonz',
        '1111-Tonze Swing': 'Swing de 1111 tonz',
        'Feast': 'Festin',

        'Sanctification': 'Sanctification',
        'Unholy': 'Sombre miracle',
        'Aetherochemical Explosive': 'Bombe magismologique',
        'The Educator': 'Disciplinaire',
        'Aetherochemical Mine': 'Mine magismologique',
      },
    },
    {
      'locale': 'ja',
      'replaceSync': {
        'Phantom Ray': 'ファントムレイ',
        'Minotaur': 'ミノタウロス',
        'The Curator': 'キュレーター',

        // FIXME
        'Exhibit level III will be sealed off': 'Exhibit level III will be sealed off',
        'The high-level incubation bay will be sealed off': 'The high-level incubation bay will be sealed off',
        'The reality augmentation bay will be sealed off': 'The reality augmentation bay will be sealed off',
      },
      'replaceText': {
        'Rapid Sever': '滅多斬り',
        'Atmospheric Displacement': '剣風',
        'Double Sever': '多重斬り',
        'Damage Up': 'ダメージ上昇',
        'Atmospheric Compression': '剣圧',

        '11-Tonze Swipe': '11トンズ・スワイプ',
        '111-Tonze Swing': '111トンズ・スイング',
        'Disorienting Groan': '雄叫び',
        'Zoom': 'ズームイン',
        '10-Tonze Slash': '10トンズ・スラッシュ',
        '1111-Tonze Swing': '1111トンズ・スイング',
        'Feast': 'フィースト',

        'Sanctification': '聖別の光',
        'Unholy': 'アンホーリー',
        'Aetherochemical Explosive': '魔科学爆弾',
        'The Educator': 'エデュケーター',
        'Aetherochemical Mine': '魔科学地雷',
      },
    },
  ],
}];
<|endoftext|>


<commit_before>/** @jsx React.DOM */

var React = require('react')
, url = require('url')
, parsedUrl = url.parse(location.href, true)
, query = parsedUrl.query
, $lgtmForm = $('#lgtm-form')
, transparentGIFUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='
, store = require('store')
;

if (!store.enabled) {
  alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.');
}

var LGTMSubmitImage = React.createClass({
  getInitialState: function() {
    return {lgtm: {hash: '', actualImageUrl: transparentGIFUrl}};
  }
  , lgtmEndPoint: function(mode) {
    if (mode == 'random') {
      return 'http://www.lgtm.in/g';
    } else {
      return 'http://www.lgtm.in/g/' + this.props.loginUser;
    }
  }
  , updateLGTMs: function(mode) {
    var self = this;
    $.getJSON(this.lgtmEndPoint(mode) + '?' + this.props.requestId)
      .done(function (data) {
        self.setState({lgtm: data})
      });
  }
  , componentDidMount: function() {
    var self = this;
    $(window).on('lgtm:text-change', function(ev, text) {
      $(self.refs.text.getDOMNode()).val(text);
    });
  }
  , componentWillUnmount: function() {
    $(window).off('lgtm:text-change');
  }
  , componentWillReceiveProps: function(nextProps) {
    if (this.props.mode != nextProps.mode) {
      this.replaceState(this.getInitialState());
      this.updateLGTMs(nextProps.mode);
    }
  }
  , render: function() {
    return (
      <form className='lgtm-form' method='post' action='/lgtm'
            data-mode={this.props.mode}>
        <input className='lgtm-form__item' type='hidden'
               name='_csrf' value={this.props.csrf} />
        <input className='lgtm-form__item' type='hidden'
               name='text' ref='text' />
        <input className='lgtm-form__item' type='hidden'
               name='user' value={this.props.user} />
        <input className='lgtm-form__item' type='hidden'
               name='repo' value={this.props.repo} />
        <input className='lgtm-form__item' type='hidden'
               name='number' value={this.props.number} />
        <input className='lgtm-form__item' type='hidden'
               name='hash' value={this.state.lgtm.hash} />
        <button className='lgtm-form__item.is-submit' typo='submit'>

        </button>
      </form>
    );
  }
});

var LGTMSubmitImageList = React.createClass({
  getInitialState: function() {
    return {indexes: [1, 2, 3], mode: 'notinit'};
  }
  , componentDidMount: function() {
    var self = this;
    $(window).on('lgtm:mode-change', function(ev, mode) {
      self.setState({mode: mode});
    });
  }
  , componentWillUnmount: function() {
    $(window).off('lgtm:mode-change');
  }
  , render: function() {
    var self = this;
    return (

      {this.state.indexes.map(function(idx) {
        return (

            <LGTMSubmitImage user={query.user} repo={query.repo}
                             number={query.number}
                             csrf={self.props.csrf}
                             loginUser={self.props.loginUser}
                             mode={self.state.mode}
                             requestId={idx} />

        );
      })}

    );
  }
});

var TextForm = React.createClass({
  getInitialState: function() {
    return {value: store.get('text') || 'LGTM!'};
  }
  , componentDidMount: function() {
    var self = this;
    setTimeout(function() { self.handleChange(); }, 500);
  }
  , handleChange: function() {
    var value = this.refs.textarea.getDOMNode().value.trim()
    store.set('text', value)
    this.setState({value: value});
  }
  , componentWillUpdate: function(nextProps, nextState) {
    $(this.getDOMNode()).trigger('lgtm:text-change', nextState.value);
  }
  , render: function() {
    return (

        <textarea placeholder='Additional text here..'
                  onChange={this.handleChange}
                  defaultValue={this.state.value}
                  ref='textarea' />

    );
  }
});

var ModeSelector = React.createClass({
  getInitialState: function() {
    return {mode: store.get('mode') || 'random'};
  }
  , componentDidMount: function() {
    var self = this;
    setTimeout(function() {
      $(self.getDOMNode()).trigger('lgtm:mode-change', self.state.mode);
    }, 500);
  }
  , handleModeChange: function(mode) {
    this.setState({mode: mode});
    store.set('mode', mode)
  }
  , modeToMyList: function() {
    this.handleModeChange('mylist');
  }
  , modeToRandom: function() {
    this.handleModeChange('random');
  }
  , componentWillUpdate: function(nextProps, nextState) {
    $(this.getDOMNode()).trigger('lgtm:mode-change', nextState.mode);
  }
  , render: function() {
    return (

        {(this.state.mode === 'random') ?

            Random
            My List

          :

            Random
            My List

        }

    );
  }
});

var LGTMForm = React.createClass({
  render: function() {
    return (

        <ModeSelector />
        <TextForm />
        <LGTMSubmitImageList csrf={this.props.csrf}
                             loginUser={this.props.loginUser}/>

    );
  }
});

React.renderComponent(<LGTMForm csrf={$lgtmForm.data('csrf')}
                                loginUser={$lgtmForm.data('login-user')} />,
                      $lgtmForm.get(0)
                     );
<commit_msg>add link to browse<commit_after>/** @jsx React.DOM */

var React = require('react')
, url = require('url')
, parsedUrl = url.parse(location.href, true)
, query = parsedUrl.query
, $lgtmForm = $('#lgtm-form')
, transparentGIFUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='
, store = require('store')
;

if (!store.enabled) {
  alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.');
}

var LGTMSubmitImage = React.createClass({
  getInitialState: function() {
    return {lgtm: {hash: '', actualImageUrl: transparentGIFUrl}};
  }
  , lgtmEndPoint: function(mode) {
    if (mode == 'random') {
      return 'http://www.lgtm.in/g';
    } else {
      return 'http://www.lgtm.in/g/' + this.props.loginUser;
    }
  }
  , updateLGTMs: function(mode) {
    var self = this;
    $.getJSON(this.lgtmEndPoint(mode) + '?' + this.props.requestId)
      .done(function (data) {
        self.setState({lgtm: data})
      });
  }
  , componentDidMount: function() {
    var self = this;
    $(window).on('lgtm:text-change', function(ev, text) {
      $(self.refs.text.getDOMNode()).val(text);
    });
  }
  , componentWillUnmount: function() {
    $(window).off('lgtm:text-change');
  }
  , componentWillReceiveProps: function(nextProps) {
    if (this.props.mode != nextProps.mode) {
      this.replaceState(this.getInitialState());
      this.updateLGTMs(nextProps.mode);
    }
  }
  , render: function() {
    return (
      <form className='lgtm-form' method='post' action='/lgtm'
            data-mode={this.props.mode}>
        <input className='lgtm-form__item' type='hidden'
               name='_csrf' value={this.props.csrf} />
        <input className='lgtm-form__item' type='hidden'
               name='text' ref='text' />
        <input className='lgtm-form__item' type='hidden'
               name='user' value={this.props.user} />
        <input className='lgtm-form__item' type='hidden'
               name='repo' value={this.props.repo} />
        <input className='lgtm-form__item' type='hidden'
               name='number' value={this.props.number} />
        <input className='lgtm-form__item' type='hidden'
               name='hash' value={this.state.lgtm.hash} />
        <button className='lgtm-form__item.is-submit' typo='submit'>

        </button>
      </form>
    );
  }
});

var LGTMSubmitImageList = React.createClass({
  getInitialState: function() {
    return {indexes: [1, 2, 3], mode: 'notinit'};
  }
  , componentDidMount: function() {
    var self = this;
    $(window).on('lgtm:mode-change', function(ev, mode) {
      self.setState({mode: mode});
    });
  }
  , componentWillUnmount: function() {
    $(window).off('lgtm:mode-change');
  }
  , render: function() {
    var self = this;
    return (

        { (self.state.mode == 'mylist') ? (

                 Add more to My List.

          )
         :

 }

        {this.state.indexes.map(function(idx) {
          return (

              <LGTMSubmitImage user={query.user} repo={query.repo}
                               number={query.number}
                               csrf={self.props.csrf}
                               loginUser={self.props.loginUser}
                               mode={self.state.mode}
                               requestId={idx} />

          );
        })}

    );
  }
});

var TextForm = React.createClass({
  getInitialState: function() {
    return {value: store.get('text') || 'LGTM!'};
  }
  , componentDidMount: function() {
    var self = this;
    setTimeout(function() { self.handleChange(); }, 500);
  }
  , handleChange: function() {
    var value = this.refs.textarea.getDOMNode().value.trim()
    store.set('text', value)
    this.setState({value: value});
  }
  , componentWillUpdate: function(nextProps, nextState) {
    $(this.getDOMNode()).trigger('lgtm:text-change', nextState.value);
  }
  , render: function() {
    return (

        <textarea placeholder='Additional text here..'
                  onChange={this.handleChange}
                  defaultValue={this.state.value}
                  ref='textarea' />

    );
  }
});

var ModeSelector = React.createClass({
  getInitialState: function() {
    return {mode: store.get('mode') || 'random'};
  }
  , componentDidMount: function() {
    var self = this;
    setTimeout(function() {
      $(self.getDOMNode()).trigger('lgtm:mode-change', self.state.mode);
    }, 500);
  }
  , handleModeChange: function(mode) {
    this.setState({mode: mode});
    store.set('mode', mode)
  }
  , modeToMyList: function() {
    this.handleModeChange('mylist');
  }
  , modeToRandom: function() {
    this.handleModeChange('random');
  }
  , componentWillUpdate: function(nextProps, nextState) {
    $(this.getDOMNode()).trigger('lgtm:mode-change', nextState.mode);
  }
  , render: function() {
    return (

        {(this.state.mode === 'random') ?

            Random
            My List

          :

            Random
            My List

        }

    );
  }
});

var LGTMForm = React.createClass({
  render: function() {
    return (

        <ModeSelector />
        <TextForm />
        <LGTMSubmitImageList csrf={this.props.csrf}
                             loginUser={this.props.loginUser}/>

    );
  }
});

React.renderComponent(<LGTMForm csrf={$lgtmForm.data('csrf')}
                                loginUser={$lgtmForm.data('login-user')} />,
                      $lgtmForm.get(0)
                     );
<|endoftext|>


<commit_before>'use babel';

const Nico = require('nicolive');
const AppDispacher = require('../dispacher/AppDispacher');
const CommentActionType = require('./types/CommentActionTypes');
const Immutable = require('immutable');

let CommentAction = {
  getComment(viewer) {
    viewer.on('comment', comment => {
      let come = Immutable.fromJS(comment);
      this.fetchNickname(come);
      AppDispacher.dispatch({
        actionType: CommentActionType.GET_COMMENT,
        comment: come
      });
    });
  },

  postComment(comment) {
    Nico.comment(comment, {mail: ''}, (error, result) => {
      if (error) throw error;
      console.log('<=== postComment:result %o', result);
    });
  },

  fetchNickname(comment) {
    let userId = comment.getIn(['attr', 'user_id']);
    let no = comment.getIn(['attr', 'no']);
    let anonymous = '184';
    if (isNaN(userId)) {
      AppDispacher.dispatch({
        actionType: CommentActionType.FETCH_NICKNAME,
        nickname: anonymous,
        userId: userId
      });
    } else {
      Nico.fetchNickname(userId, (error, nickname) => {
        if (error) throw error;
        AppDispacher.dispatch({
          actionType: CommentActionType.FETCH_NICKNAME,
          nickname: nickname,
          userId: userId
        });
      });
    }
  }

}

module.exports = CommentAction;
<commit_msg>Refactoring<commit_after>'use babel';

const Nico = require('nicolive');
const AppDispacher = require('../dispacher/AppDispacher');
const CommentActionType = require('./types/CommentActionTypes');
const Immutable = require('immutable');

let dispatchNickname = (userId, nickname) => {
  AppDispacher.dispatch({
    actionType: CommentActionType.FETCH_NICKNAME,
    nickname: nickname,
    userId: userId
  });
};

let CommentAction = {
  getComment(viewer) {
    viewer.on('comment', comment => {
      let come = Immutable.fromJS(comment);
      this.fetchNickname(come);
      AppDispacher.dispatch({
        actionType: CommentActionType.GET_COMMENT,
        comment: come
      });
    });
  },

  postComment(comment) {
    Nico.comment(comment, {mail: ''}, (error, result) => {
      if (error) throw error;
      console.log('<=== postComment:result %o', result);
    });
  },

  fetchNickname(comment) {
    let userId = comment.getIn(['attr', 'user_id']);
    let anonymous = '184';
    if (isNaN(userId)) {
      dispatchNickname(userId, anonymous);
    } else {
      Nico.fetchNickname(userId, (error, nickname) => {
        if (error) throw error;
        dispatchNickname(userId, nickname);
      });
    }
  }

};

module.exports = CommentAction;
<|endoftext|>


<commit_before>module.exports = function(network, chan, cmd, args) {
    if (cmd != "mode" && cmd != "op" && cmd != "voice" && cmd != "deop" && cmd != "devoice") {
        return;
    } else if (args.length === 0) {
        return;
    }

    var mode;
    var user;
    if (cmd != "mode") {
        user = args[0];
        mode = {
             "op": "+o",
          "voice": "+v",
           "deop": "-o",
        "devoice": "-v"
        }[cmd];
    } else if (args.length === 1) {
        return;
    } else {
        mode = args[0];
        user = args[1];
    }
    var irc = network.irc;
    irc.mode(
        chan.name,
        mode,
        user
    );
};
<commit_msg>Lint fix: mode.js<commit_after>/*eslint quotes: [2, "single"]*/
'use strict';

module.exports = function(network, chan, cmd, args) {
    if (cmd !== 'mode' && cmd !== 'op' && cmd !== 'voice' && cmd !== 'deop' && cmd !== 'devoice') {
        return;
    } else if (args.length === 0) {
        return;
    }

    var mode;
    var user;
    if (cmd !== 'mode') {
        user = args[0];
        mode = {
             'op': '+o',
          'voice': '+v',
           'deop': '-o',
        'devoice': '-v'
        }[cmd];
    } else if (args.length === 1) {
        return;
    } else {
        mode = args[0];
        user = args[1];
    }
    var irc = network.irc;
    irc.mode(
        chan.name,
        mode,
        user
    );
};
<|endoftext|>


<commit_before>import {
  PerspectiveCamera,
  Shader,
  Component,
  Geometry,
  Material,
  Context,
  Frame,
  Mesh,
} from '../../src'

import PrimitiveCube from 'primitive-cube'

import ready from 'domready'
import Bunny from 'bunny'
import Stats from 'stats.js'
import quat from 'gl-quat'

for (const p of Bunny.positions) {
  p[1] = p[1] - 4
}

const ctx = new Context()
const material = new Material(ctx)
const camera = new PerspectiveCamera(ctx)
const frame = new Frame(ctx)
const Box = PrimitiveCube(20, 20, 20)
const bunny = new Mesh(ctx, {geometry: Bunny})
const box = new Mesh(ctx, {geometry: Box})

window.bunny = bunny

const rotation = quat.identity([])
const position = [25, 25, 25]
const angle = quat.identity([])
const color = [0, 0, 1]
const stats = new Stats()

ctx.on('error', (err) => console.error(err.message, err.stack || err))
window.ctx = ctx

ready(() => document.body.appendChild(stats.dom))
frame(() => stats.begin())
frame(scene)
frame(() => stats.end())

function scene({time, cancelAll}) {
  quat.setAxisAngle(angle, [0, 1, 0], 0.5*time)
  quat.slerp(rotation, rotation, angle, 0.5)
  camera({rotation, position}, ({view}) => {
    material({color}, ({}) => {
      box({scale: 1, wireframe: true}, ({size, transform, matrix}) => {
        const [x, y, z] = size
        //const [x, y, z] = [20, 20, 20]
        bunny([
          {position: [0, 0, 0,]},
          {position: [0.5*x, 0.5*y, 0.5*z]},
          {position: [-0.5*x, -0.5*y, -0.5*z]},
          {position: [0.5*x, -0.5*y, 0.5*z]},
          {position: [-0.5*x, 0.5*y, -0.5*z]},
          {position: [0.5*x, 0.5*y, -0.5*z]},
          {position: [-0.5*x, -0.5*y, 0.5*z]},
          {position: [0.5*x, -0.5*y, -0.5*z]},
          {position: [-0.5*x, 0.5*y, 0.5*z]}
        ])
      })
    })
  })
}
<commit_msg>chore(example/hello-world): Clean up<commit_after>import {
  PerspectiveCamera,
  Shader,
  Component,
  Geometry,
  Material,
  Context,
  Frame,
  Mesh,
} from '../../src'

import PrimitiveCube from 'primitive-cube'

import ready from 'domready'
import Bunny from 'bunny'
import Stats from 'stats.js'
import quat from 'gl-quat'

for (const p of Bunny.positions) {
  p[1] = p[1] - 4
}

const ctx = new Context()
const material = new Material(ctx)
const camera = new PerspectiveCamera(ctx)
const frame = new Frame(ctx)
const Box = PrimitiveCube(20, 20, 20)
const bunny = new Mesh(ctx, {geometry: Bunny})
const box = new Mesh(ctx, {geometry: Box})

window.bunny = bunny

const rotation = quat.identity([])
const position = [25, 25, 25]
const angle = quat.identity([])
const color = [0, 0, 1]
const stats = new Stats()

ctx.on('error', (err) => console.error(err.message, err.stack || err))
window.ctx = ctx

ready(() => document.body.appendChild(stats.dom))
frame(() => stats.begin())
frame(scene)
frame(() => stats.end())

function scene({time, cancelAll}) {
  quat.setAxisAngle(angle, [0, 1, 0], 0.5*time)
  quat.slerp(rotation, rotation, angle, 0.5)
  camera({rotation, position}, ({view}) => {
    material({color}, ({}) => {
      box({scale: 1, wireframe: true}, ({size, transform, matrix}) => {
        const [x, y, z] = size
        bunny([
          {position: [0, 0, 0,]},
          {position: [0.5*x, 0.5*y, 0.5*z]},
          {position: [-0.5*x, -0.5*y, -0.5*z]},
          {position: [0.5*x, -0.5*y, 0.5*z]},
          {position: [-0.5*x, 0.5*y, -0.5*z]},
          {position: [0.5*x, 0.5*y, -0.5*z]},
          {position: [-0.5*x, -0.5*y, 0.5*z]},
          {position: [0.5*x, -0.5*y, -0.5*z]},
          {position: [-0.5*x, 0.5*y, 0.5*z]}
        ])
      })
    })
  })
}
<|endoftext|>