<commit_before>
/*!
 * page.js
 * Copyright(c) 2011 Lucas Mazza <luc4smazza@gmail.com>
 * MIT Licensed
 */

;(function(global) {

  var slice = Array.prototype.slice,
      initializers = {};

  function runChain(chain, scope) {
    var block, result;
    for (var index = 0, len = chain.length; index < len; index++) {
      block = chain[index];
      result = block(scope);
      if (result === false) return;
    }
  }

  function createChain(blocks) {
    var beforeBlocks = initializers[':before'] || [],
        afterBlocks  = initializers[':after']  || [];

    return beforeBlocks.concat(blocks).concat(afterBlocks);
  }

  // Stores a function on one or more scopes
  // to be executed on a specific scope is called with the `run()` function.
  //
  // Accepts on or more Strings as scopes and a function as the last argument.
  //
  // Returns nothing.
  var page = function() {
    var args  = slice.call(arguments),
        block = args.pop(),
        blocks, scope;

    for (var index = 0, len = args.length; index < len; index++) {
      scope = args[index];
      blocks = initializers[scope] || [];
      blocks.push(block);
      initializers[scope] = blocks;
    }
  };

  // Run all the registered functions for a given `scope`.
  // If none is given, uses the `page.identify()` to discover
  // the scope for the current page.
  //
  // If any function is registered under the scopes of `:before` or
  // `:after`, they will be executed around the registered functions.
  // If any call returns `false`, the execution chain will be halted
  // and the following functions won't be called.
  //
  // All functions will receive the current `scope` as the only argument.
  page.run = function(scope) {
    var blocks, chain;
    scope = scope || page.identify();
    blocks = initializers[scope] || [];
    chain = createChain(blocks);
    runChain(chain, scope);
  };

  // Tries to read the `content` attribute of a meta tag
  // named `page'. If none named tag is found, returns nothing.
  // Replace this function to implement your own method of
  // scope lookup.
  page.identify = function() {
    var tags = document.getElementsByTagName('meta'),
        tag;

    for (var index = 0, len = tags.length; index < len; index++) {
      tag = tags[index];
      if (tag.name === 'page' && tag.content) return tag.content;
    }
  };

  // Internal: Initializes a 'Page' object.
  // Browser environments does not need to call this constructor
  // since a 'page' object will be exported in the global namespace.
  var Page = function() {
    this.initializers = {};
  };

  // Public: registers a function under the given scope to be executed
  // when the a scope is called.
  // These functions will be called with the current scope as its only
  // argument, and returning 'false' from any function will stop the
  // execution and the next registered functions will not be called.
  //
  // Examples
  //
  // # scope will be 'home'.
  // page.at('home', function(scope) { });
  //
  // # This second function will be called.
  // page.at('home', function() { return false; });
  // page.at('home', function() { });
  //
  // Returns nothing.
  Page.prototype.at = function(scope, fn) {
    this.initializers[scope] = this.initializers[scope] || [];
    this.initializers[scope].push(fn);
  };

  // Public: recognizes the current scope and execute all the registered
  // functions. If there is any functions registered under the ':before'
  // and ':after' scopes they will always be executed around the current
  // scope functions.
  //
  // Examples
  //
  // page.recognize();
  //
  // Returns nothing.
  Page.prototype.recognize = function() {
    var scope = this._detect(),
        chain = this._buildChain(scope);

    this._executeChain(chain, scope);
  };

  // Internal: detects the current scope through the 'data-page'
  // attribute on the 'body' tag.
  //
  // Returns a String.
  Page.prototype._detect = function() {
    var body = global.document.getElementsByTagName('body')[0];

    return body && body.getAttribute('data-page');
  };

  // Internal: builds a collection of functions to be called for the given
  // scope. The functions under the ':before' and ':after' scopes will be
  // inserted before and after the scope functions.
  //
  // Returns an Array.
  Page.prototype._buildChain = function(scope) {
    var before  = this.initializers[':before'] || [],
        current = this.initializers[scope] || [],
        after   = this.initializers[':after'] || [];

    return before.concat(current).concat(after);
  };

  // Internal: executes the chain of given functions using the
  // scope as the only argument. If the
  //
  // Returns nothing.
  Page.prototype._executeChain = function(chain, scope) {
    var result;
    for (var index = 0, len = chain.length; index < len; index++) {
      result = chain[index](scope);
      if(result === false) {
        return;
      }
    };
  };

  // Export the page object for Node.JS
  if (typeof module !== 'undefined') {
    module.exports = Page;
  } else {
    global.page = new Page;
  }
})(this);
<commit_msg>:fire:<commit_after>;(function(global) {

  var slice = Array.prototype.slice,
      document = global.document;

  // Internal: Initializes a 'Page' object.
  // Browser environments does not need to call this constructor
  // since a 'page' object will be exported in the global namespace.
  var Page = function() {
    this.initializers = {};
  };

  // Public: registers a function under the given scope to be executed
  // when the a scope is called.
  // These functions will be called with the current scope as its only
  // argument, and returning 'false' from any function will stop the
  // execution and the next registered functions will not be called.
  //
  // Examples
  //
  // # scope will be 'home'.
  // page.at('home', function(scope) { });
  //
  // # This second function will be called.
  // page.at('home', function() { return false; });
  // page.at('home', function() { });
  //
  // Returns nothing.
  Page.prototype.at = function(scope, fn) {
    this.initializers[scope] = this.initializers[scope] || [];
    this.initializers[scope].push(fn);
  };

  // Public: recognizes the current scope and execute all the registered
  // functions. If there is any functions registered under the ':before'
  // and ':after' scopes they will always be executed around the current
  // scope functions.
  //
  // Examples
  //
  // page.recognize();
  //
  // Returns nothing.
  Page.prototype.recognize = function() {
    var scope = this._detect(),
        chain = this._buildChain(scope);

    this._executeChain(chain, scope);
  };

  // Internal: detects the current scope through the 'data-page'
  // attribute on the 'body' tag.
  //
  // Returns a String.
  Page.prototype._detect = function() {
    var body = document.getElementsByTagName('body')[0];

    return body && body.getAttribute('data-page');
  };

  // Internal: builds a collection of functions to be called for the given
  // scope. The functions under the ':before' and ':after' scopes will be
  // inserted before and after the scope functions.
  //
  // Returns an Array.
  Page.prototype._buildChain = function(scope) {
    var before  = this.initializers[':before'] || [],
        current = this.initializers[scope] || [],
        after   = this.initializers[':after'] || [];

    return before.concat(current).concat(after);
  };

  // Internal: executes the chain of given functions using the
  // scope as the only argument. If the
  //
  // Returns nothing.
  Page.prototype._executeChain = function(chain, scope) {
    var result;
    for (var index = 0, len = chain.length; index < len; index++) {
      result = chain[index](scope);
      if(result === false) {
        return;
      }
    };
  };

  // Export the page object for Node.JS
  if (typeof module !== 'undefined') {
    module.exports = Page;
  } else {
    global.page = new Page;
  }
})(this);
<|endoftext|>


<commit_before>/*global define*/
define([
        '../Core/Cartesian2',
        '../Core/Cartesian3',
        '../Core/Cartesian4',
        '../Core/Color',
        '../Core/defined',
        '../Core/defineProperties',
        '../Core/DeveloperError',
        '../Core/FeatureDetection',
        '../Core/Matrix2',
        '../Core/Matrix3',
        '../Core/Matrix4',
        '../Core/RuntimeError'
    ], function(
        Cartesian2,
        Cartesian3,
        Cartesian4,
        Color,
        defined,
        defineProperties,
        DeveloperError,
        FeatureDetection,
        Matrix2,
        Matrix3,
        Matrix4,
        RuntimeError) {
    "use strict";
    /*global console*/

    /**
     * @private
     */
    var UniformArray = function(gl, activeUniform, uniformName, locations) {
        var length = locations.length;

        this._gl = gl;
        this._activeUniform = activeUniform;
        this._uniformName = uniformName;
        this.value = new Array(length);
        this._location = locations[0];

// TODO: default value for these?
        this._scratchFloat = undefined;
        this._scratchInt = undefined;

        /**
         * @private
         */
        this.textureUnitIndex = undefined;

        var set;
        switch (activeUniform.type) {
            case gl.FLOAT:
                set = this.setFloat;
                this._scratchFloat = new Float32Array(length);
                break;
            case gl.FLOAT_VEC2:
                set = this.setFloatVec2;
                this._scratchFloat = new Float32Array(length * 2);
                break;
            case gl.FLOAT_VEC3:
                set = this.setFloatVec3;
                this._scratchFloat = new Float32Array(length * 3);
                break;
            case gl.FLOAT_VEC4:
                this._scratchFloat = new Float32Array(length * 4);
                set = this.setFloatVec4;
                break;
            case gl.SAMPLER_2D:
            case gl.SAMPLER_CUBE:
                set = this.setSampler;
                break;
            case gl.INT:
            case gl.BOOL:
                set = this.setInt;
                this._scratchInt = new Int32Array(length);
                break;
            case gl.INT_VEC2:
            case gl.BOOL_VEC2:
                set = this.setIntVec2;
                this._scratchInt = new Int32Array(length * 2);
                break;
            case gl.INT_VEC3:
            case gl.BOOL_VEC3:
                this._scratchInt = new Int32Array(length * 3);
                set = this.setIntVec3;
                break;
            case gl.INT_VEC4:
            case gl.BOOL_VEC4:
                this._scratchInt = new Int32Array(length * 4);
                set = this.setIntVec4;
                break;
            case gl.FLOAT_MAT2:
                this._scratchFloat = new Float32Array(length * 4);
                set = this.setMat2;
                break;
            case gl.FLOAT_MAT3:
                this._scratchFloat = new Float32Array(length * 9);
                set = this.setMat3;
                break;
            case gl.FLOAT_MAT4:
                this._scratchFloat = new Float32Array(length * 16);
                set = this.setMat4;
                break;
            default:
                throw new RuntimeError('Unrecognized uniform type: ' + activeUniform.type + ' for uniform "' + uniformName + '".');
        }

        this._set = set;

        if ((activeUniform.type === gl.SAMPLER_2D) || (activeUniform.type === gl.SAMPLER_CUBE)) {
            this._setSampler = function(textureUnitIndex) {
                this.textureUnitIndex = textureUnitIndex;

                var length = locations.length;
                for (var i = 0; i < length; ++i) {
                    var index = textureUnitIndex + i;
                    gl.uniform1i(locations[i], index);
                }

                return textureUnitIndex + length;
            };
        }
    };

    defineProperties(UniformArray.prototype, {
        name : {
            get : function() {
                return this._uniformName;
            }
        },
        datatype : {
            get : function() {
                return this._activeUniform.type;
            }
        }
    });

    UniformArray.prototype.setFloat = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (v !== scratch[i]) {
                scratch[i] = v;
                changed = true;
            }
        }

        if (changed) {
            this._gl.uniform1fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian2.equalsArray(v, scratch, j)) {
                Cartesian2.pack(v, scratch, j);
                changed = true;
            }
            j += 2;
        }

        if (changed) {
            this._gl.uniform2fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (defined(v.red)) {
                if ((v.red !== scratch[j]) ||
                    (v.green !== scratch[j + 1]) ||
                    (v.blue !== scratch[j + 2])) {

                    scratch[j] = v.red;
                    scratch[j + 1] = v.green;
                    scratch[j + 2] = v.blue;
                    changed = true;
                }
            } else if (defined(v.x)) {
                if (!Cartesian3.equalsArray(v, scratch, j)) {
                    Cartesian3.pack(v, scratch, j);
                    changed = true;
                }
            } else {
                throw new DeveloperError('Invalid vec4 value.');
            }

            j += 3;
        }

        if (changed) {
            this._gl.uniform3fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec4 = function() {
        // PERFORMANCE_IDEA: if it is a common case that only a few elements
        // in a uniform array change, we could use heuristics to determine
        // when it is better to call uniform4f for each element that changed
        // vs. call uniform4fv once to set the entire array.  This applies
        // to all uniform array types, not just vec4.  We might not care
        // once we have uniform buffers since that will be the fast path.

        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (defined(v.red)) {
                if (!Color.equalsArray(v, scratch, j)) {
                    Color.pack(v, scratch, j);
                    changed = true;
                }
            } else if (defined(v.x)) {
                if (!Cartesian4.equalsArray(v, scratch, j)) {
                    Cartesian4.pack(v, scratch, j);
                    changed = true;
                }
            } else {
                throw new DeveloperError('Invalid vec4 value.');
            }

            j += 4;
        }

        if (changed) {
            this._gl.uniform4fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setSampler = function() {
        var gl = this._gl;
        var locations = this._locations;
        var textureUnitIndex = gl.TEXTURE0 + this.textureUnitIndex;

        var value = this.value;
        var length = value.length;
        for (var i = 0; i < length; ++i) {
            var v = value[i];
            gl.activeTexture(textureUnitIndex + i);
            gl.bindTexture(v._target, v._texture);
        }
    };

    UniformArray.prototype.setInt = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (v !== scratch[i]) {
                scratch[i] = v;
                changed = true;
            }
        }

        if (changed) {
            this._gl.uniform1iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian2.equalsArray(v, scratch, j)) {
                Cartesian2.pack(v, scratch, j);
                changed = true;
            }
            j += 2;
        }

        if (changed) {
            this._gl.uniform2iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian3.equalsArray(v, scratch, j)) {
                Cartesian3.pack(v, scratch, j);
                changed = true;
            }
            j += 3;
        }

        if (changed) {
            this._gl.uniform3iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec4 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian4.equalsArray(v, scratch, j)) {
                Cartesian4.pack(v, scratch, j);
                changed = true;
            }
            j += 4;
        }

        if (changed) {
            this._gl.uniform4iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setMat2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix2.equalsArray(v, scratch, j)) {
                Matrix2.pack(v, scratch, j);
                changed = true;
            }
            j += 4;
        }

        if (changed) {
            this._gl.uniformMatrix2fv(this._location, false, scratch);
        }
    };

    UniformArray.prototype.setMat3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix3.equalsArray(v, scratch, j)) {
                Matrix3.pack(v, scratch, j);
                changed = true;
            }
            j += 9;
        }

        if (changed) {
            this._gl.uniformMatrix3fv(this._location, false, scratch);
        }
    };

    UniformArray.prototype.setMat4 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix4.equalsArray(v, scratch, j)) {
                Matrix4.pack(v, scratch, j);
                changed = true;
            }
            j += 16;
        }

        if (changed) {
            this._gl.uniformMatrix4fv(this._location, false, scratch);
        }
    };

    return UniformArray;
});
<commit_msg>Misc uniform array cleanup<commit_after>/*global define*/
define([
        '../Core/Cartesian2',
        '../Core/Cartesian3',
        '../Core/Cartesian4',
        '../Core/Color',
        '../Core/defined',
        '../Core/defineProperties',
        '../Core/DeveloperError',
        '../Core/FeatureDetection',
        '../Core/Matrix2',
        '../Core/Matrix3',
        '../Core/Matrix4',
        '../Core/RuntimeError'
    ], function(
        Cartesian2,
        Cartesian3,
        Cartesian4,
        Color,
        defined,
        defineProperties,
        DeveloperError,
        FeatureDetection,
        Matrix2,
        Matrix3,
        Matrix4,
        RuntimeError) {
    "use strict";
    /*global console*/

    /**
     * @private
     */
    var UniformArray = function(gl, activeUniform, uniformName, locations) {
        var length = locations.length;
        var type = activeUniform.type;

        this._gl = gl;
        this._type = type;
        this._name = uniformName;
        this.value = new Array(length);
        this._location = locations[0];

        this._scratchFloat = undefined;
        this._scratchInt = undefined;

        /**
         * @private
         */
        this.textureUnitIndex = undefined;

        var set;
        switch (type) {
            case gl.FLOAT:
                set = this.setFloat;
                this._scratchFloat = new Float32Array(length);
                break;
            case gl.FLOAT_VEC2:
                set = this.setFloatVec2;
                this._scratchFloat = new Float32Array(length * 2);
                break;
            case gl.FLOAT_VEC3:
                set = this.setFloatVec3;
                this._scratchFloat = new Float32Array(length * 3);
                break;
            case gl.FLOAT_VEC4:
                this._scratchFloat = new Float32Array(length * 4);
                set = this.setFloatVec4;
                break;
            case gl.SAMPLER_2D:
            case gl.SAMPLER_CUBE:
                set = this.setSampler;
                break;
            case gl.INT:
            case gl.BOOL:
                set = this.setInt;
                this._scratchInt = new Int32Array(length);
                break;
            case gl.INT_VEC2:
            case gl.BOOL_VEC2:
                set = this.setIntVec2;
                this._scratchInt = new Int32Array(length * 2);
                break;
            case gl.INT_VEC3:
            case gl.BOOL_VEC3:
                this._scratchInt = new Int32Array(length * 3);
                set = this.setIntVec3;
                break;
            case gl.INT_VEC4:
            case gl.BOOL_VEC4:
                this._scratchInt = new Int32Array(length * 4);
                set = this.setIntVec4;
                break;
            case gl.FLOAT_MAT2:
                this._scratchFloat = new Float32Array(length * 4);
                set = this.setMat2;
                break;
            case gl.FLOAT_MAT3:
                this._scratchFloat = new Float32Array(length * 9);
                set = this.setMat3;
                break;
            case gl.FLOAT_MAT4:
                this._scratchFloat = new Float32Array(length * 16);
                set = this.setMat4;
                break;
            default:
                throw new RuntimeError('Unrecognized uniform type: ' + type + ' for uniform "' + uniformName + '".');
        }

        this._set = set;

        if ((type === gl.SAMPLER_2D) || (type === gl.SAMPLER_CUBE)) {
            this._setSampler = function(textureUnitIndex) {
                this.textureUnitIndex = textureUnitIndex;

                var length = locations.length;
                for (var i = 0; i < length; ++i) {
                    var index = textureUnitIndex + i;
                    gl.uniform1i(locations[i], index);
                }

                return textureUnitIndex + length;
            };
        }
    };

    defineProperties(UniformArray.prototype, {
        name : {
            get : function() {
                return this._name;
            }
        },
        datatype : {
            get : function() {
                return this._type;
            }
        }
    });

    UniformArray.prototype.setFloat = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (v !== scratch[i]) {
                scratch[i] = v;
                changed = true;
            }
        }

        if (changed) {
            this._gl.uniform1fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian2.equalsArray(v, scratch, j)) {
                Cartesian2.pack(v, scratch, j);
                changed = true;
            }
            j += 2;
        }

        if (changed) {
            this._gl.uniform2fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (defined(v.red)) {
                if ((v.red !== scratch[j]) ||
                    (v.green !== scratch[j + 1]) ||
                    (v.blue !== scratch[j + 2])) {

                    scratch[j] = v.red;
                    scratch[j + 1] = v.green;
                    scratch[j + 2] = v.blue;
                    changed = true;
                }
            } else if (defined(v.x)) {
                if (!Cartesian3.equalsArray(v, scratch, j)) {
                    Cartesian3.pack(v, scratch, j);
                    changed = true;
                }
            } else {
                throw new DeveloperError('Invalid vec3 value.');
            }

            j += 3;
        }

        if (changed) {
            this._gl.uniform3fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setFloatVec4 = function() {
        // PERFORMANCE_IDEA: if it is a common case that only a few elements
        // in a uniform array change, we could use heuristics to determine
        // when it is better to call uniform4f for each element that changed
        // vs. call uniform4fv once to set the entire array.  This applies
        // to all uniform array types, not just vec4.  We might not care
        // once we have uniform buffers since that will be the fast path.

        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (defined(v.red)) {
                if (!Color.equalsArray(v, scratch, j)) {
                    Color.pack(v, scratch, j);
                    changed = true;
                }
            } else if (defined(v.x)) {
                if (!Cartesian4.equalsArray(v, scratch, j)) {
                    Cartesian4.pack(v, scratch, j);
                    changed = true;
                }
            } else {
                throw new DeveloperError('Invalid vec4 value.');
            }

            j += 4;
        }

        if (changed) {
            this._gl.uniform4fv(this._location, scratch);
        }
    };

    UniformArray.prototype.setSampler = function() {
        var gl = this._gl;
        var locations = this._locations;
        var textureUnitIndex = gl.TEXTURE0 + this.textureUnitIndex;

        var value = this.value;
        var length = value.length;
        for (var i = 0; i < length; ++i) {
            var v = value[i];
            gl.activeTexture(textureUnitIndex + i);
            gl.bindTexture(v._target, v._texture);
        }
    };

    UniformArray.prototype.setInt = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (v !== scratch[i]) {
                scratch[i] = v;
                changed = true;
            }
        }

        if (changed) {
            this._gl.uniform1iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian2.equalsArray(v, scratch, j)) {
                Cartesian2.pack(v, scratch, j);
                changed = true;
            }
            j += 2;
        }

        if (changed) {
            this._gl.uniform2iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian3.equalsArray(v, scratch, j)) {
                Cartesian3.pack(v, scratch, j);
                changed = true;
            }
            j += 3;
        }

        if (changed) {
            this._gl.uniform3iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setIntVec4 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchInt;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Cartesian4.equalsArray(v, scratch, j)) {
                Cartesian4.pack(v, scratch, j);
                changed = true;
            }
            j += 4;
        }

        if (changed) {
            this._gl.uniform4iv(this._location, scratch);
        }
    };

    UniformArray.prototype.setMat2 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix2.equalsArray(v, scratch, j)) {
                Matrix2.pack(v, scratch, j);
                changed = true;
            }
            j += 4;
        }

        if (changed) {
            this._gl.uniformMatrix2fv(this._location, false, scratch);
        }
    };

    UniformArray.prototype.setMat3 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix3.equalsArray(v, scratch, j)) {
                Matrix3.pack(v, scratch, j);
                changed = true;
            }
            j += 9;
        }

        if (changed) {
            this._gl.uniformMatrix3fv(this._location, false, scratch);
        }
    };

    UniformArray.prototype.setMat4 = function() {
        var value = this.value;
        var length = value.length;
        var scratch = this._scratchFloat;
        var changed = false;
        var j = 0;

        for (var i = 0; i < length; ++i) {
            var v = value[i];

            if (!Matrix4.equalsArray(v, scratch, j)) {
                Matrix4.pack(v, scratch, j);
                changed = true;
            }
            j += 16;
        }

        if (changed) {
            this._gl.uniformMatrix4fv(this._location, false, scratch);
        }
    };

    return UniformArray;
});
<|endoftext|>


<commit_before>(function ($) {
	var methods,
		utils,
		SIDES = {
			/* cen...ter */
			center: 'center',
			/* ...left */
			left: 'left',
			/* right... */
			right: 'right'
		},
		WIDTH = {
			auto: 'auto'
		},
		settings = {
			fill: '…',
			lines: 1,
			side: SIDES.right,
			tooltip: true,
			width: WIDTH.auto
		};

	function truncate() {
		var width = settings.width,
			side = settings.side,
			fill = settings.fill,
			line_height = parseInt(this.css('line-height')) * settings.lines,
			str = this.attr('title') || this.text(),
			length = str.length,
			i = 1,
			max_bite = '',
			bite_size,
			bite;

		/* Reset the field to the original string. */
		this.html(str);

		if (width === WIDTH.auto) {
			/* Assuming there is no "overflow: hidden". */
			if (this.height() <= line_height) {
				/* Text is already at the optimal trunkage. */
				return;
			}

			/* Binary search technique for finding the optimal trunkage. */
			/* Find the maximum bite without overflowing. */
			bite_size = length >> i; // Halve the length.

			do {
				bite = utils.eatStr(str, side, bite_size, fill);

				this.html(bite);

				i++;

				if (this.height() > line_height) {
					bite_size += length >> i; // Length divided by 2**i
				}
				else {
					bite_size -= length >> i; // Length divided by 2**i

					/* Save the bigger bite. */
					max_bite = (max_bite.length > bite.length) ? max_bite : bite;
				}
			}
			while (length >> i > 0);

			/* Display the biggest bite. */
			this.html(max_bite);

			if (settings.tooltip) {
				this.attr('title', str);
			}
		}
		else if (!isNaN(width)) {
			bite_size = width;

			bite = utils.eatStr(str, side, bite_size, fill);

			this.html(bite);

			if (settings.tooltip) {
				this.attr('title', str);
			}
		}
		else {
			$.error('Invalid width "' + width + '".');
		}
	}

	methods = {
		init: function (options) {
			settings = $.extend(settings, options);

			return this.each(function () {
				truncate.call($(this));
			});
		},

		/** Updates the text value of the elements while maintaining truncation. */
		update: function (text) {
			return this.each(function () {
				/* Update text. */
				if (text) {
					this.text(text);
				}

				/* Truncate accordingly. */
				truncate.call($(this));
			});
		},

		/** Returns this instance's settings object. NOT CHAINABLE. */
		getSettings: function () {
			return settings;
		}
	};

	utils = {
		/** Replaces [bite_size] [side]-most chars in [str] with [fill]. */
		eatStr: function (str, side, bite_size, fill) {
		    var length = str.length,
		    	key = utils.eatStr.generateKey.apply(null, arguments),
		        half_length,
		        half_bite_size;

	        /* If the result is already in the cache, return it. */
	        if (utils.eatStr.cache[key]) {
				return utils.eatStr.cache[key];
	        }

			/* Common error handling. */
		    if ((typeof str !== 'string') || (length === 0)) {
		    	$.error('Invalid source string "' + str + '".');
		    }
		    if ((bite_size < 0) || (bite_size > length)) {
		    	$.error('Invalid bite size "' + bite_size + '".');
		    }
		    else if (bite_size === 0) {
			    /* No bite should show no truncation. */
				return str;
		    }
		    if (typeof (fill + '') !== 'string') {
				$.error('Fill unable to be converted to a string.');
		    }

			/* Compute the result, store it in the cache, and return it. */
		    switch (side) {
		        case SIDES.right:
			        /* str... */
		            return utils.eatStr.cache[key] =
			            	$.trim(str.substr(0, length - bite_size)) + fill;

		        case SIDES.left:
			        /* ...str */
		            return utils.eatStr.cache[key] =
			            	fill + $.trim(str.substr(bite_size));

		        case SIDES.center:
			        /* Bit-shift to the right by one === Math.floor(x / 2) */
		            half_length = length >> 1; // halve the length
		            half_bite_size = bite_size >> 1; // halve the bite_size

			        /* st...r */
		            return utils.eatStr.cache[key] =
			            	$.trim(utils.eatStr(str.substr(0, length - half_length), SIDES.right, bite_size - half_bite_size, '')) +
		            		fill +
		            		$.trim(utils.eatStr(str.substr(length - half_length), SIDES.left, half_bite_size, ''));

		        default:
		        	$.error('Invalid side "' + side + '".');
		    }
		}
	};

	utils.eatStr.cache = {};
	utils.eatStr.generateKey = function () {
		return Array.prototype.join.call(arguments, '');
	};

	$.fn.trunk8 = function (method) {
		if (methods[method]) {
			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
		}
		else if (typeof method === 'object' || !method) {
			return methods.init.apply(this, arguments);
		}
		else {
			$.error('Method ' + method + ' does not exist on jQuery.trunk8');
		}
	};
})(jQuery);<commit_msg>moving trunk8.js to top-level<commit_after><|endoftext|>


<commit_before>/* Undecided? Pass a question, like 'Should I buy this expensive 64 inches tv?'. The question will be ignored, but you'll have your answer. */
var decideForMe = function (question) {
  var choice = Math.floor(Math.random() * 5);
  switch (choice) {
    case 0:
      return "Yes";
    case 1:
      return "No";
    case 2:
      return "Maybe";
    case 3:
      return "Not yet";
    case 4:
      return "Knock yourself out";
  }
};

anything.prototype.decideForMe = decideForMe;
<commit_msg>Refactored decideForMe; added decideForMeFinalAnswer for more definitive responses.<commit_after>anything.prototype.MAX_DECISION_RESPONSES = 6;

/**
 * Undecided? Pass a question, like 'Should I buy this expensive 64 inche TV?'. The
 * question will be ignored, but you'll have your answer.
 **/
var decideForMe = function (question) {
  var choice = Math.floor(Math.random() * this.MAX_DECISION_RESPONSES);
  return decideResponseForValue(choice);
};

/**
 * Want a definitive answer locked into the specific question? No second chances?
 * Go ahead. Roll the die.
 **/
var decideForMeFinalAnswer = function( question )
{
  var total = 0;

  for( var ch in question ) {
    total += question.charCodeAt( ch );
  }

  // NOTE: -1 to avoid getting default "outlook hazy" response
  return decideResponseForValue( total % ( this.MAX_DECISION_RESPONSES - 1 ) );
};

// TODO: Shouldn't this be tucked away somewhere out of the global space?
var decideResponseForValue = function(choice)
{
  console.info("choice = " + choice);
  switch ( choice ) {
    case 0:
      return "Yes";
    case 1:
      return "No";
    case 2:
      return "Maybe";
    case 3:
      return "Not yet";
    case 4:
      return "Knock yourself out";
    default:
      return "Outlook hazy, ask again";
  }
};

anything.prototype.decideForMe = decideForMe;
anything.prototype.decideForMeFinalAnswer = decideForMeFinalAnswer;<|endoftext|>


<commit_before>import assert from 'power-assert';
import {
  assertThat,
  promiseThat, is, fulfilled,
  allOf, truthy
} from 'hamjest';

import fs from 'fs';
import path from 'path';

function convertOneFile(fileName, destFileName) {
  const fileReadPromise = new Promise(resolve => {
    fs.readFile(fileName, 'utf8', (error, content) => {
      if (!error) resolve(content);
    });
  });
  return fileReadPromise.then(fileContent => {
    return new Promise(resolve => {
      fs.writeFile(destFileName, minifyJson(fileContent), 'utf8', resolve);
    });
  });
}

function minifyJson(content) {
  return JSON.stringify(JSON.parse(content));
}

describe('converting', () => {

  describe('existing file `stars.json`', () => {

    const destFile = path.join(__dirname, '../../dist/data/stars.json');
    const sourceFile = path.join(__dirname, '../../data/stars.json');
    let promise;

    beforeEach(() => {
      if (fs.existsSync(destFile)) fs.unlinkSync(destFile);
      promise = convertOneFile(sourceFile, destFile);
    });

    it('returns a promise that fulfills', () => {
      return promiseThat(promise, is(fulfilled()));
    });

    it('writes the destination file', () => {
      return promise.then(() => assert(fs.existsSync(destFile), 'Destination file missing.'));
    });

    it('is minified', () => {
      return promise.then(() => {
        const jsonFile = fs.readFileSync(destFile, 'utf8');
        assertThat(jsonFile, is(JSON.stringify(JSON.parse(jsonFile))))
      });
    });

  });

});
<commit_msg>Handle a missing file.<commit_after>import assert from 'power-assert';
import {
  assertThat,
  promiseThat, is, fulfilled, rejected,
  allOf, truthy
} from 'hamjest';

import fs from 'fs';
import path from 'path';

function convertOneFile(fileName, destFileName) {
  const fileReadPromise = new Promise((resolve, reject) => {
    fs.readFile(fileName, 'utf8', (error, content) => {
      if (!error) resolve(content)
      else reject();
    });
  });
  return fileReadPromise.then(fileContent => {
    return new Promise(resolve => {
      fs.writeFile(destFileName, minifyJson(fileContent), 'utf8', resolve);
    });
  });
}

function minifyJson(content) {
  return JSON.stringify(JSON.parse(content));
}

describe('converting', () => {

  describe('existing file `stars.json`', () => {

    const destFile = path.join(__dirname, '../../dist/data/stars.json');
    const sourceFile = path.join(__dirname, '../../data/stars.json');
    let promise;

    beforeEach(() => {
      if (fs.existsSync(destFile)) fs.unlinkSync(destFile);
      promise = convertOneFile(sourceFile, destFile);
    });

    it('returns a promise that fulfills', () => {
      return promiseThat(promise, is(fulfilled()));
    });

    it('writes the destination file', () => {
      return promise.then(() => assert(fs.existsSync(destFile), 'Destination file missing.'));
    });

    it('is minified', () => {
      return promise.then(() => {
        const jsonFile = fs.readFileSync(destFile, 'utf8');
        assertThat(jsonFile, is(JSON.stringify(JSON.parse(jsonFile))))
      });
    });

  });

  describe('fails', () => {

    const notExistingFile = path.join(__dirname, '../../not-an-existing-file');
    const nonJsonFile = path.join(__dirname, '../../README.md');
    let promise;

    it('for a not existing file', () => {
      const promise = convertOneFile(notExistingFile, '');
      return promiseThat(promise, is(rejected()));
    });

  });

});
<|endoftext|>


<commit_before>describe('Akodo Zentaro', function() {
    integration(function() {
        describe('Akodo Zentaro\'s ability', function() {
            beforeEach(function() {
                this.setupTest({
                    phase: 'conflict',
                    player1: {
                        inPlay: ['akodo-zentaro', 'miya-mystic'],
                        dynastyDiscard: ['matsu-berserker']
                    },
                    player2: {
                        inPlay: ['wandering-ronin'],
                        dynastyDiscard: ['the-imperial-palace', 'imperial-storehouse']
                    }
                });

                this.akodoZentaro = this.player1.findCardByName('akodo-zentaro');
                this.miyaMystic = this.player1.findCardByName('miya-mystic');
                this.shamefulDisplay1 = this.player1.findCardByName('shameful-display', 'province 1');
                this.shamefulDisplay2 = this.player1.findCardByName('shameful-display', 'province 2');
                this.shamefulDisplay2.isBroken = true;
                this.shamefulDisplay3 = this.player1.findCardByName('shameful-display', 'province 3');
                this.matsuBerserker = this.player1.placeCardInProvince('matsu-berserker', 'province 3');
                this.shamefulDisplay4 = this.player1.findCardByName('shameful-display', 'province 4');
                this.shamefulDisplaySH = this.player1.findCardByName('shameful-display', 'stronghold province');

                this.wanderingRonin = this.player2.findCardByName('wandering-ronin');
                this.imperialStorehouse = this.player2.placeCardInProvince('imperial-storehouse', 'province 1');
                this.theImperialPalace = this.player2.placeCardInProvince('the-imperial-palace', 'province 2');
            });

            it('should not trigger if Zentaro is not attacking', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.miyaMystic],
                    defenders: []
                });
                this.player2.pass();
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should not trigger if Zentaro is defending', function() {
                this.noMoreActions();
                this.player1.passConflict();
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.wanderingRonin],
                    defenders: [this.akodoZentaro]
                });
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should not trigger if there is not a non-unqiue holding in the attacked province', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.miyaMystic],
                    defenders: [],
                    province: this.player2.provinces['province 2'].provinceCard
                });
                this.player2.pass();
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should prompt to choose a target non-unique holding in the attacked province', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose a holding');
                expect(this.player1).toBeAbleToSelect(this.imperialStorehouse);
                expect(this.player1).not.toBeAbleToSelect(this.theImperialPalace);
            });

            it('should prompt to choose a non-stronghold unbroken province to move the chosen holding to', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                expect(this.player1).toHavePrompt('Choose a Province');
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay1);
                expect(this.player1).not.toBeAbleToSelect(this.shamefulDisplay2);
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay3);
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay4);
                expect(this.player1).not.toBeAbleToSelect(this.shamefulDisplaySH);
            });

            it('should take control of the chosen holding', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                this.player1.clickCard(this.shamefulDisplay3);
                expect(this.imperialStorehouse.controller).toBe(this.player1.player);
            });

            it('should move the chosen holding to the chosen province and remove all other cards there', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                expect(this.matsuBerserker.location).toBe('province 3');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                this.player1.clickCard(this.shamefulDisplay3);
                expect(this.imperialStorehouse.location).toBe('province 3');
                expect(this.player1.player.provinceThree.toArray()).toContain(this.imperialStorehouse);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
            });

            it('should discard the chosen holding if there is no valid province to move it to', function() {
                this.shamefulDisplay1.isBroken = true;
                this.shamefulDisplay2.isBroken = true;
                this.shamefulDisplay3.isBroken = true;
                this.shamefulDisplay4.isBroken = true;
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                expect(this.imperialStorehouse.location).toBe('dynasty discard pile');
            });
        });

        describe('Akodo Zentaro\'s Disguised keyword', function() {
            beforeEach(function() {
                this.setupTest({
                    phase: 'dynasty',
                    player1: {
                        inPlay: ['matsu-berserker', 'kitsu-spiritcaller', 'akodo-toturi'],
                        dynastyDiscard: ['akodo-zentaro', 'hidden-moon-dojo', 'iron-mine'],
                        hand: ['fine-katana', 'ornate-fan', 'peasant-s-advice']
                    },
                    player2: {
                        inPlay: ['brash-samurai']
                    }
                });

                this.akodoZentaro = this.player1.placeCardInProvince('akodo-zentaro', 'province 1');
                this.hiddenMoonDojo = this.player1.findCardByName('hidden-moon-dojo');
                this.matsuBerserker = this.player1.findCardByName('matsu-berserker');
                this.matsuBerserker.fate = 2;
                this.kitsuSpiritcaller = this.player1.findCardByName('kitsu-spiritcaller');
                this.akodoToturi = this.player1.findCardByName('akodo-toturi');
                this.fineKatana = this.player1.findCardByName('fine-katana');
                this.ornateFan = this.player1.findCardByName('ornate-fan');
                this.peasantsAdvice = this.player1.findCardByName('peasant-s-advice');
                this.ironMine = this.player1.findCardByName('iron-mine');

                this.brashSamurai = this.player2.findCardByName('brash-samurai');
            });

            it('should not work outside of the conflict phase', function() {
                this.player1.togglePromptedActionWindow('draw', true);
                this.player1.togglePromptedActionWindow('fate', true);
                this.player1.togglePromptedActionWindow('regroup', true);
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose additional fate');
                expect(this.player1).toHavePromptButton('Cancel');
                this.player1.clickPrompt('Cancel');
                this.noMoreActions();
                this.player1.clickPrompt('1');
                this.player2.clickPrompt('1');
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.pass();
                this.advancePhases('fate');
                this.player1.clickPrompt('Done');
                this.player2.clickPrompt('Done');
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.pass();
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
            });

            it('should prompt to choose a non-unique character with the \'bushi\' trait', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose a character to replace');
                expect(this.player1).toBeAbleToSelect(this.matsuBerserker);
                expect(this.player1).not.toBeAbleToSelect(this.kitsuSpiritcaller);
                expect(this.player1).not.toBeAbleToSelect(this.akodoToturi);
                expect(this.player1).not.toBeAbleToSelect(this.brashSamurai);
            });

            it('should reduce the cost by the printed cost of the character in play', function() {
                let fate = this.player1.player.fate;
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1.player.fate).toBe(fate - this.akodoZentaro.getCost() + this.matsuBerserker.getCost());
            });

            it('should put itself into play', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.location).toBe('play area');
            });

            it('should discard the replaced character', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
                expect(this.getChatLogs(1)).toContain('player1 plays Akodo Zentarō using Disguised, choosing to replace Matsu Berserker');
            });

            it('should transfer fate', function() {
                let fate = this.matsuBerserker.fate;
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.fate).toBe(fate);
            });

            it('should transfer attachments', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.fineKatana);
                this.player1.clickCard(this.matsuBerserker);
                this.player2.pass();
                this.player1.clickCard(this.ornateFan);
                this.player1.clickCard(this.matsuBerserker);
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.fineKatana.parent).toBe(this.akodoZentaro);
                expect(this.ornateFan.parent).toBe(this.akodoZentaro);
            });

            it('should transfer status tokens', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.peasantsAdvice);
                this.player1.clickCard(this.player2.provinces['province 1'].provinceCard);
                this.player1.clickCard(this.matsuBerserker);
                this.player1.clickPrompt('Done');
                expect(this.matsuBerserker.isDishonored).toBe(true);
                this.player2.pass();
                expect(this.player1).toHavePrompt('Action Window');
                let honor = this.player1.player.honor;
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.isDishonored).toBe(true);
                expect(this.player1.player.honor).toBe(honor);
            });

            it('should prompt how to play if other play options are available', function() {
                this.advancePhases('conflict');
                this.player1.placeCardInProvince(this.hiddenMoonDojo, 'province 2');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Akodo Zentarō');
                expect(this.player1).toHavePromptButton('Play this character with Disguise');
                expect(this.player1).toHavePromptButton('Play this character');
                expect(this.player1).toHavePromptButton('Cancel');
            });

            it('should prompt to play in or out of the conflict if the replaced character is in a conflict', function() {
                this.advancePhases('conflict');
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.matsuBerserker],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1).toHavePromptButton('Conflict');
                expect(this.player1).toHavePromptButton('Home');
                this.player1.clickPrompt('Conflict');
                expect(this.akodoZentaro.isParticipating()).toBe(true);
            });

            it('should enter play as ready even if the replaced character is bowed', function() {
                this.advancePhases('conflict');
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.matsuBerserker],
                    defenders: []
                });
                this.noMoreActions();
                this.player1.clickPrompt('No');
                this.player1.clickPrompt('Don\'t Resolve');
                expect(this.matsuBerserker.bowed).toBe(true);
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.bowed).toBe(false);
            });

            it('should not allow the discard of the replaced character to be prevented', function() {
                this.advancePhases('conflict');
                this.player1.placeCardInProvince(this.ironMine, 'province 2');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1).not.toHavePrompt('Triggered Abilities');
                expect(this.player1).not.toBeAbleToSelect(this.ironMine);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
                expect(this.player2).toHavePrompt('Action Window');
            });
        });
    });
});

<commit_msg>Adjust Zentaro test<commit_after>describe('Akodo Zentaro', function() {
    integration(function() {
        describe('Akodo Zentaro\'s ability', function() {
            beforeEach(function() {
                this.setupTest({
                    phase: 'conflict',
                    player1: {
                        inPlay: ['akodo-zentaro', 'miya-mystic'],
                        dynastyDiscard: ['matsu-berserker']
                    },
                    player2: {
                        inPlay: ['wandering-ronin'],
                        dynastyDiscard: ['the-imperial-palace', 'imperial-storehouse']
                    }
                });

                this.akodoZentaro = this.player1.findCardByName('akodo-zentaro');
                this.miyaMystic = this.player1.findCardByName('miya-mystic');
                this.shamefulDisplay1 = this.player1.findCardByName('shameful-display', 'province 1');
                this.shamefulDisplay2 = this.player1.findCardByName('shameful-display', 'province 2');
                this.shamefulDisplay2.isBroken = true;
                this.shamefulDisplay3 = this.player1.findCardByName('shameful-display', 'province 3');
                this.matsuBerserker = this.player1.placeCardInProvince('matsu-berserker', 'province 3');
                this.shamefulDisplay4 = this.player1.findCardByName('shameful-display', 'province 4');
                this.shamefulDisplaySH = this.player1.findCardByName('shameful-display', 'stronghold province');

                this.wanderingRonin = this.player2.findCardByName('wandering-ronin');
                this.imperialStorehouse = this.player2.placeCardInProvince('imperial-storehouse', 'province 1');
                this.theImperialPalace = this.player2.placeCardInProvince('the-imperial-palace', 'province 2');
            });

            it('should not trigger if Zentaro is not attacking', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.miyaMystic],
                    defenders: []
                });
                this.player2.pass();
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should not trigger if Zentaro is defending', function() {
                this.noMoreActions();
                this.player1.passConflict();
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.wanderingRonin],
                    defenders: [this.akodoZentaro]
                });
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should not trigger if there is not a non-unqiue holding in the attacked province', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.miyaMystic],
                    defenders: [],
                    province: this.player2.provinces['province 2'].provinceCard
                });
                this.player2.pass();
                expect(this.player1).toHavePrompt('Conflict Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Conflict Action Window');
            });

            it('should prompt to choose a target non-unique holding in the attacked province', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose a holding');
                expect(this.player1).toBeAbleToSelect(this.imperialStorehouse);
                expect(this.player1).not.toBeAbleToSelect(this.theImperialPalace);
            });

            it('should prompt to choose a non-stronghold unbroken province to move the chosen holding to', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                expect(this.player1).toHavePrompt('Choose a Province');
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay1);
                expect(this.player1).not.toBeAbleToSelect(this.shamefulDisplay2);
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay3);
                expect(this.player1).toBeAbleToSelect(this.shamefulDisplay4);
                expect(this.player1).not.toBeAbleToSelect(this.shamefulDisplaySH);
            });

            it('should take control of the chosen holding', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                this.player1.clickCard(this.shamefulDisplay3);
                expect(this.imperialStorehouse.controller).toBe(this.player1.player);
            });

            it('should move the chosen holding to the chosen province and remove all other cards there', function() {
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                expect(this.matsuBerserker.location).toBe('province 3');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                this.player1.clickCard(this.shamefulDisplay3);
                expect(this.imperialStorehouse.location).toBe('province 3');
                expect(this.player1.player.provinceThree.toArray()).toContain(this.imperialStorehouse);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
            });

            it('should discard the chosen holding if there is no valid province to move it to', function() {
                this.shamefulDisplay1.isBroken = true;
                this.shamefulDisplay2.isBroken = true;
                this.shamefulDisplay3.isBroken = true;
                this.shamefulDisplay4.isBroken = true;
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.akodoZentaro],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.imperialStorehouse);
                expect(this.imperialStorehouse.location).toBe('dynasty discard pile');
            });
        });

        describe('Akodo Zentaro\'s Disguised keyword', function() {
            beforeEach(function() {
                this.setupTest({
                    phase: 'dynasty',
                    player1: {
                        inPlay: ['matsu-berserker', 'kitsu-spiritcaller', 'akodo-toturi'],
                        dynastyDiscard: ['akodo-zentaro', 'hidden-moon-dojo', 'iron-mine'],
                        hand: ['fine-katana', 'ornate-fan', 'peasant-s-advice', 'court-mask']
                    },
                    player2: {
                        inPlay: ['brash-samurai']
                    }
                });

                this.akodoZentaro = this.player1.placeCardInProvince('akodo-zentaro', 'province 1');
                this.hiddenMoonDojo = this.player1.findCardByName('hidden-moon-dojo');
                this.matsuBerserker = this.player1.findCardByName('matsu-berserker');
                this.matsuBerserker.fate = 2;
                this.kitsuSpiritcaller = this.player1.findCardByName('kitsu-spiritcaller');
                this.akodoToturi = this.player1.findCardByName('akodo-toturi');
                this.fineKatana = this.player1.findCardByName('fine-katana');
                this.ornateFan = this.player1.findCardByName('ornate-fan');
                this.peasantsAdvice = this.player1.findCardByName('peasant-s-advice');
                this.courtMask = this.player1.findCardByName('court-mask');
                this.ironMine = this.player1.findCardByName('iron-mine');

                this.brashSamurai = this.player2.findCardByName('brash-samurai');
            });

            it('should not work outside of the conflict phase', function() {
                this.player1.togglePromptedActionWindow('draw', true);
                this.player1.togglePromptedActionWindow('fate', true);
                this.player1.togglePromptedActionWindow('regroup', true);
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose additional fate');
                expect(this.player1).toHavePromptButton('Cancel');
                this.player1.clickPrompt('Cancel');
                this.noMoreActions();
                this.player1.clickPrompt('1');
                this.player2.clickPrompt('1');
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.pass();
                this.advancePhases('fate');
                this.player1.clickPrompt('Done');
                this.player2.clickPrompt('Done');
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.pass();
                expect(this.player1).toHavePrompt('Action Window');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Action Window');
            });

            it('should prompt to choose a non-unique character with the \'bushi\' trait', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Choose a character to replace');
                expect(this.player1).toBeAbleToSelect(this.matsuBerserker);
                expect(this.player1).not.toBeAbleToSelect(this.kitsuSpiritcaller);
                expect(this.player1).not.toBeAbleToSelect(this.akodoToturi);
                expect(this.player1).not.toBeAbleToSelect(this.brashSamurai);
            });

            it('should reduce the cost by the printed cost of the character in play', function() {
                let fate = this.player1.player.fate;
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1.player.fate).toBe(fate - this.akodoZentaro.getCost() + this.matsuBerserker.getCost());
            });

            it('should put itself into play', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.location).toBe('play area');
            });

            it('should discard the replaced character', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
                expect(this.getChatLogs(1)).toContain('player1 plays Akodo Zentarō using Disguised, choosing to replace Matsu Berserker');
            });

            it('should transfer fate', function() {
                let fate = this.matsuBerserker.fate;
                this.advancePhases('conflict');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.fate).toBe(fate);
            });

            it('should transfer attachments', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.fineKatana);
                this.player1.clickCard(this.matsuBerserker);
                this.player2.pass();
                this.player1.clickCard(this.ornateFan);
                this.player1.clickCard(this.matsuBerserker);
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.fineKatana.parent).toBe(this.akodoZentaro);
                expect(this.ornateFan.parent).toBe(this.akodoZentaro);
            });

            it('should transfer status tokens', function() {
                this.advancePhases('conflict');
                this.player1.clickCard(this.courtMask);
                this.player1.clickCard(this.matsuBerserker);
                this.player2.pass();
                this.player1.clickCard(this.courtMask);
                expect(this.matsuBerserker.isDishonored).toBe(true);
                this.player2.pass();
                expect(this.player1).toHavePrompt('Action Window');
                let honor = this.player1.player.honor;
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.isDishonored).toBe(true);
                expect(this.player1.player.honor).toBe(honor);
            });

            it('should prompt how to play if other play options are available', function() {
                this.advancePhases('conflict');
                this.player1.placeCardInProvince(this.hiddenMoonDojo, 'province 2');
                this.player1.clickCard(this.akodoZentaro);
                expect(this.player1).toHavePrompt('Akodo Zentarō');
                expect(this.player1).toHavePromptButton('Play this character with Disguise');
                expect(this.player1).toHavePromptButton('Play this character');
                expect(this.player1).toHavePromptButton('Cancel');
            });

            it('should prompt to play in or out of the conflict if the replaced character is in a conflict', function() {
                this.advancePhases('conflict');
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.matsuBerserker],
                    defenders: []
                });
                this.player2.pass();
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1).toHavePromptButton('Conflict');
                expect(this.player1).toHavePromptButton('Home');
                this.player1.clickPrompt('Conflict');
                expect(this.akodoZentaro.isParticipating()).toBe(true);
            });

            it('should enter play as ready even if the replaced character is bowed', function() {
                this.advancePhases('conflict');
                this.noMoreActions();
                this.initiateConflict({
                    attackers: [this.matsuBerserker],
                    defenders: []
                });
                this.noMoreActions();
                this.player1.clickPrompt('No');
                this.player1.clickPrompt('Don\'t Resolve');
                expect(this.matsuBerserker.bowed).toBe(true);
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.akodoZentaro.bowed).toBe(false);
            });

            it('should not allow the discard of the replaced character to be prevented', function() {
                this.advancePhases('conflict');
                this.player1.placeCardInProvince(this.ironMine, 'province 2');
                this.player1.clickCard(this.akodoZentaro);
                this.player1.clickCard(this.matsuBerserker);
                expect(this.player1).not.toHavePrompt('Triggered Abilities');
                expect(this.player1).not.toBeAbleToSelect(this.ironMine);
                expect(this.matsuBerserker.location).toBe('dynasty discard pile');
                expect(this.player2).toHavePrompt('Action Window');
            });
        });
    });
});

<|endoftext|>


<commit_before>/*
 HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}</style>";
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);
if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
<commit_msg>Delete html5shiv.js<commit_after><|endoftext|>


<commit_before>const appLocaleData = require('react-intl/locale-data/zh');

module.exports = {
  locale: 'zh-CN',
  data: appLocaleData,
  messages: {
    'app.header.search': '全文本搜索...',
    'app.header.menu.home': '首页',
    'app.header.menu.practice': '实践',
    'app.header.menu.pattern': '模式',
    'app.header.menu.components': '组件',
    'app.header.menu.spec': '设计语言',
    'app.header.menu.resource': '资源',
    'app.header.menu.mobile': '移动版',
    'app.header.menu.pro': 'PRO',
    'app.header.lang': 'English',
    'app.content.edit-page': '在 Github 上编辑此页！',
    'app.content.edit-demo': '在 Github 上编辑此示例！',
    'app.component.examples': '代码演示',
    'app.component.examples.expand': '展开全部代码',
    'app.component.examples.collpse': '收起全部代码',
    'app.demo.copy': '复制代码',
    'app.demo.copied': '复制成功',
    'app.demo.codepen': '在 CodePen 中打开',
    'app.demo.codesandbox': '在 CodeSandbox 中打开',
    'app.demo.riddle': '在 Riddle 中打开',
    'app.home.slogan': '一个 UI 设计语言',
    'app.home.introduce': '服务于企业级产品的设计体系，基于确定和自然的设计价值观上的模块化解决方案，让设计者和开发者专注于更好的用户体验。',
    'app.home.design-language': '设计语言',
    'app.home.solution': '解决方案',
    'app.home.components-explain': '基于 Ant Design 设计语言，我们提供了一套开箱即用的高质量 React 组件，用于开发和服务于企业级中后台产品，除官方的 React 实现，还有 Angular、Vue 的实现',
    'app.home.product-pro-slogan': '开箱即用的中台前端/设计解决方案',
    'app.home.product-mobile-slogan': 'antd-mobile 是 Ant Design 移动规范的实现',
    'app.home.product-antv-slogan': '简单、专业、拥有无限可能的数据可视化解决方案',
    'app.home.tool-title': '工具和资源',
    'app.home.tool-package-title': 'Ant Design 资源包',
    'app.home.tool-package-content': 'Ant Design 相关设计资源下载',
    'app.home.tool-library-title': 'Axure Library',
    'app.home.tool-library-content': '一套精美得像视觉稿的 Axure 组件库',
    'app.home.tool-kitchen-title': 'Kitchen',
    'app.home.tool-kitchen-content': '一个为设计师提效的 Sketch 工具集',
    'app.home.getting-started': '开始使用',
    'app.home.more': '查看更多',
    'app.home.more-mobile-react': 'Ant Design Mobile of React',
    'app.home.more-mobile-angular': 'Ant Design Mobile of Angular',
    'app.footer.repo': 'GitHub 仓库',
    'app.footer.awesome': 'Awesome Ant Design',
    'app.footer.course': 'Ant Design 实战教程',
    'app.footer.chinamirror': '国内镜像站点 🇨🇳',
    'app.footer.primary-color-changed': '修改主题色成功！',
    'app.footer.kitchen': 'Sketch 工具集',
    'app.footer.scaffold': '脚手架',
    'app.footer.scaffolds': '脚手架市场',
    'app.footer.dev-tools': '开发工具',
    'app.footer.umi': 'React 应用开发框架',
    'app.footer.dva': '数据流前端框架',
    'app.footer.resources': '相关资源',
    'app.footer.data-vis': '数据可视化',
    'app.footer.eggjs': '企业级 Node 开发框架',
    'app.footer.motion': '设计动效',
    'app.footer.antd-library': 'Axure 部件库',
    'app.footer.design-platform': '蚂蚁金服设计平台',
    'app.footer.antux': '页面逻辑素材',
    'app.footer.community': '社区',
    'app.footer.help': '帮助',
    'app.footer.change-log': '更新记录',
    'app.footer.faq': '常见问题',
    'app.footer.feedback': '反馈和建议',
    'app.footer.stackoverflow': 'StackOverflow',
    'app.footer.segmentfault': 'SegmentFault',
    'app.footer.discuss-en': '在线讨论 (English)',
    'app.footer.discuss-cn': '在线讨论 (中文)',
    'app.footer.bug-report': '报告 Bug',
    'app.footer.issues': '讨论列表',
    'app.footer.version': '文档版本：',
    'app.footer.author': '蚂蚁金服体验技术部出品 @ AFX',
    'app.footer.work_with_us': '加入我们',
    'app.footer.more-product': '更多产品',
    'app.footer.company': 'AFX',
    'app.footer.ant-design': '蚂蚁 UI 体系',
    'app.footer.yuque': '语雀',
    'app.footer.yuque.slogan': '知识创作·协作平台',
    'app.footer.fengdie': '云凤蝶',
    'app.footer.fengdie.slogan': '移动建站平台',
    'app.footer.zhihu': '知乎专栏',
    'app.footer.zhihu.xtech': '体验科技专栏',
    'app.footer.seeconf': '蚂蚁体验科技大会',
    'app.footer.xcloud': '蚂蚁体验云',
    'app.publish.title': 'antd@3.0.0 发布！🎉 🎉 🎉',
    'app.publish.greeting': '你好，',
    'app.publish.intro': ' 已正式发布，欢迎升级。',
    'app.publish.old-version-guide': '如果您还需要使用旧版，请查阅 ',
    'app.publish.old-version-tips': '，也可通过页面右上角的文档版本选择框进行切换。',
    'app.docs.color.pick-primary': '选择你的主色',
    'app.docs.components.icon.pick-theme': '选择图标主题风格',
    'app.docs.components.icon.category.direction': '方向性图标',
    'app.docs.components.icon.category.suggestion': '提示建议性图标',
    'app.docs.components.icon.category.edit': '编辑类图标',
    'app.docs.components.icon.category.data': '数据类图标',
    'app.docs.components.icon.category.other': '网站通用图标',
    'app.docs.components.icon.category.logo': '品牌和标识',
  },
};
<commit_msg>Update zh-CN.js<commit_after>const appLocaleData = require('react-intl/locale-data/zh');

module.exports = {
  locale: 'zh-CN',
  data: appLocaleData,
  messages: {
    'app.header.search': '全文本搜索...',
    'app.header.menu.home': '首页',
    'app.header.menu.practice': '实践',
    'app.header.menu.pattern': '模式',
    'app.header.menu.components': '组件',
    'app.header.menu.spec': '设计语言',
    'app.header.menu.resource': '资源',
    'app.header.menu.mobile': '移动版',
    'app.header.menu.pro': 'PRO',
    'app.header.lang': 'English',
    'app.content.edit-page': '在 Github 上编辑此页！',
    'app.content.edit-demo': '在 Github 上编辑此示例！',
    'app.component.examples': '代码演示',
    'app.component.examples.expand': '展开全部代码',
    'app.component.examples.collpse': '收起全部代码',
    'app.demo.copy': '复制代码',
    'app.demo.copied': '复制成功',
    'app.demo.codepen': '在 CodePen 中打开',
    'app.demo.codesandbox': '在 CodeSandbox 中打开',
    'app.demo.riddle': '在 Riddle 中打开',
    'app.home.slogan': '一个 UI 设计语言',
    'app.home.introduce': '服务于企业级产品的设计体系，基于确定和自然的设计价值观上的模块化解决方案，让设计者和开发者专注于更好的用户体验。',
    'app.home.design-language': '设计语言',
    'app.home.solution': '解决方案',
    'app.home.components-explain': '基于 Ant Design 设计语言，我们提供了一套开箱即用的高质量 React 组件，用于开发和服务于企业级中后台产品，除官方的 React 实现，还有 Angular、Vue 的实现',
    'app.home.product-pro-slogan': '开箱即用的中台前端/设计解决方案',
    'app.home.product-mobile-slogan': 'antd-mobile 是 Ant Design 移动规范的实现',
    'app.home.product-antv-slogan': '简单、专业、拥有无限可能的数据可视化解决方案',
    'app.home.tool-title': '工具和资源',
    'app.home.tool-package-title': 'Ant Design 资源包',
    'app.home.tool-package-content': 'Ant Design 相关设计资源下载',
    'app.home.tool-library-title': 'Axure Library',
    'app.home.tool-library-content': '一套精美得像视觉稿的 Axure 组件库',
    'app.home.tool-kitchen-title': 'Kitchen',
    'app.home.tool-kitchen-content': '一个为设计师提效的 Sketch 工具集',
    'app.home.getting-started': '开始使用',
    'app.home.more': '查看更多',
    'app.home.more-mobile-react': 'Ant Design Mobile of React',
    'app.home.more-mobile-angular': 'Ant Design Mobile of Angular',
    'app.footer.repo': 'GitHub 仓库',
    'app.footer.awesome': 'Awesome Ant Design',
    'app.footer.course': 'Ant Design 实战教程',
    'app.footer.chinamirror': '国内镜像站点 🇨🇳',
    'app.footer.primary-color-changed': '修改主题色成功！',
    'app.footer.kitchen': 'Sketch 工具集',
    'app.footer.scaffold': '脚手架',
    'app.footer.scaffolds': '脚手架市场',
    'app.footer.dev-tools': '开发工具',
    'app.footer.umi': 'React 应用开发框架',
    'app.footer.dva': '数据流前端框架',
    'app.footer.resources': '相关资源',
    'app.footer.data-vis': '数据可视化',
    'app.footer.eggjs': '企业级 Node 开发框架',
    'app.footer.motion': '设计动效',
    'app.footer.antd-library': 'Axure 部件库',
    'app.footer.design-platform': '蚂蚁金服设计平台',
    'app.footer.antux': '页面逻辑素材',
    'app.footer.community': '社区',
    'app.footer.help': '帮助',
    'app.footer.change-log': '更新记录',
    'app.footer.faq': '常见问题',
    'app.footer.feedback': '反馈和建议',
    'app.footer.stackoverflow': 'StackOverflow',
    'app.footer.segmentfault': 'SegmentFault',
    'app.footer.discuss-en': '在线讨论 (English)',
    'app.footer.discuss-cn': '在线讨论 (中文)',
    'app.footer.bug-report': '报告 Bug',
    'app.footer.issues': '讨论列表',
    'app.footer.version': '文档版本：',
    'app.footer.author': '蚂蚁金服体验技术部出品 @ AFX',
    'app.footer.work_with_us': '加入我们',
    'app.footer.more-product': '更多产品',
    'app.footer.company': 'AFX',
    'app.footer.ant-design': '蚂蚁 UI 体系',
    'app.footer.yuque': '语雀',
    'app.footer.yuque.slogan': '知识创作与分享工具',
    'app.footer.fengdie': '云凤蝶',
    'app.footer.fengdie.slogan': '移动建站平台',
    'app.footer.zhihu': '知乎专栏',
    'app.footer.zhihu.xtech': '体验科技专栏',
    'app.footer.seeconf': '蚂蚁体验科技大会',
    'app.footer.xcloud': '蚂蚁体验云',
    'app.publish.title': 'antd@3.0.0 发布！🎉 🎉 🎉',
    'app.publish.greeting': '你好，',
    'app.publish.intro': ' 已正式发布，欢迎升级。',
    'app.publish.old-version-guide': '如果您还需要使用旧版，请查阅 ',
    'app.publish.old-version-tips': '，也可通过页面右上角的文档版本选择框进行切换。',
    'app.docs.color.pick-primary': '选择你的主色',
    'app.docs.components.icon.pick-theme': '选择图标主题风格',
    'app.docs.components.icon.category.direction': '方向性图标',
    'app.docs.components.icon.category.suggestion': '提示建议性图标',
    'app.docs.components.icon.category.edit': '编辑类图标',
    'app.docs.components.icon.category.data': '数据类图标',
    'app.docs.components.icon.category.other': '网站通用图标',
    'app.docs.components.icon.category.logo': '品牌和标识',
  },
};
<|endoftext|>


<commit_before>// Prevent Dropzone from auto discoveringr all elements:
Dropzone.autoDiscover = false;

/*global
    piranha
*/

piranha.dropzone = new function () {
    var self = this;

    self.init = function (selector, options) {
        if (!options) options = {};

        var defaultOptions = {
            paramName: 'Uploads',
            url: piranha.baseUrl + "manager/api/media/upload",
            thumbnailWidth: 70,
            thumbnailHeight: 70,
            previewsContainer: selector + " .media-list",
            previewTemplate: document.querySelector( "#media-upload-template").innerHTML,
            uploadMultiple: true,
            init: function () {
                var self = this;

                // Default addedfile callback
                if (!options.addedfile) {
                    options.addedfile = function (file) { }
                }

                // Default removedfile callback
                if (!options.removedfile) {
                    options.removedfile = function (file) { }
                }

                // Default error callback
                if (!options.error) {
                    options.error = function (file) { }
                }

                // Default complete callback
                if (!options.complete) {
                    options.complete = function (file) {
                        console.log(file)
                        if (file.status !== "success" && file.xhr.responseText !== "" ) {
                            var response = JSON.parse(file.xhr.responseText);
                            file.previewElement.querySelector("[data-dz-errormessage]").innerText = response.body;
                        }
                    }
                }

                // Default queuecomplete callback
                if (!options.queuecomplete) {
                    options.queuecomplete = function () {}
                }

                self.on("addedfile", options.addedfile);
                self.on("removedfile", options.removedfile);
                self.on("complete", options.complete);
                self.on("queuecomplete", options.queuecomplete);
            }
        };

        var config = Object.assign(defaultOptions, options);
        console.log(selector, config);

        return new Dropzone(selector + " form", config);
    }
};<commit_msg>Removed old log from piranha.dropzone<commit_after>// Prevent Dropzone from auto discoveringr all elements:
Dropzone.autoDiscover = false;

/*global
    piranha
*/

piranha.dropzone = new function () {
    var self = this;

    self.init = function (selector, options) {
        if (!options) options = {};

        var defaultOptions = {
            paramName: 'Uploads',
            url: piranha.baseUrl + "manager/api/media/upload",
            thumbnailWidth: 70,
            thumbnailHeight: 70,
            previewsContainer: selector + " .media-list",
            previewTemplate: document.querySelector( "#media-upload-template").innerHTML,
            uploadMultiple: true,
            init: function () {
                var self = this;

                // Default addedfile callback
                if (!options.addedfile) {
                    options.addedfile = function (file) { }
                }

                // Default removedfile callback
                if (!options.removedfile) {
                    options.removedfile = function (file) { }
                }

                // Default error callback
                if (!options.error) {
                    options.error = function (file) { }
                }

                // Default complete callback
                if (!options.complete) {
                    options.complete = function (file) {
                        console.log(file)
                        if (file.status !== "success" && file.xhr.responseText !== "" ) {
                            var response = JSON.parse(file.xhr.responseText);
                            file.previewElement.querySelector("[data-dz-errormessage]").innerText = response.body;
                        }
                    }
                }

                // Default queuecomplete callback
                if (!options.queuecomplete) {
                    options.queuecomplete = function () {}
                }

                self.on("addedfile", options.addedfile);
                self.on("removedfile", options.removedfile);
                self.on("complete", options.complete);
                self.on("queuecomplete", options.queuecomplete);
            }
        };

        var config = Object.assign(defaultOptions, options);

        return new Dropzone(selector + " form", config);
    }
};<|endoftext|>


<commit_before>importScripts("/packages/code/screens.js?platform=service_worker");
importScripts("/platform/service_worker.js?platform=service_worker");
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.0.0/workbox-sw.js");

var components = [];
for (var package of screens.packages) {
    for (var component in screens[package]) {
        components.push({ package, component });
    }
}
screens.require(components).then(() => screens.core.startup.run());

workbox.routing.registerRoute(
    ({ url, event }) => {
        if (url.pathname === "/") {
            return true;
        }
        if (url.host === "apis.google.com") {
            return true;
        }
        return false;
    },
    new workbox.strategies.StaleWhileRevalidate({
        cacheName: "dynamic-cache",
    })
);

workbox.routing.registerRoute(
    /\.(?:html)$/,
    new workbox.strategies.StaleWhileRevalidate({
        cacheName: "html-cache",
    })
);

workbox.routing.registerRoute(
    ({ url, event }) => {
        if (url.pathname.endsWith(".js")) {
            return true;
        }
        return false;
    },
    new workbox.strategies.StaleWhileRevalidate({
        cacheName: "js-cache",
    })
);

workbox.routing.registerRoute(
    /\.(?:json)$/,
    new workbox.strategies.StaleWhileRevalidate({
        cacheName: "json-cache",
    })
);

workbox.routing.registerRoute(
    // Cache CSS files.
    /\.css$/,
    // Use cache but update in the background.
    new workbox.strategies.StaleWhileRevalidate({
        // Use a custom cache name.
        cacheName: "css-cache"
    })
);

workbox.routing.registerRoute(
    // Cache image files.
    /\.(?:woff2|ttf)$/,
    // Use the cache if it's available.
    new workbox.strategies.StaleWhileRevalidate({
        // Use a custom cache name.
        cacheName: "font-cache"
    })
);
workbox.routing.registerRoute(
    // Cache image files.
    /\.(?:png|jpg|jpeg|svg|gif|ico)$/,
    // Use the cache if it's available.
    new workbox.strategies.StaleWhileRevalidate({
        // Use a custom cache name.
        cacheName: "image-cache"
    })
);

workbox.routing.registerRoute(
    /.*\.m4a/,
    new workbox.strategies.CacheFirst({
        cacheName: 'audio-cache',
        plugins: [
            new workbox.cacheableResponse.Plugin({ statuses: [200] }),
            new workbox.rangeRequests.Plugin(),
            new workbox.expiration.Plugin({
                // Cache only 3 files.
                maxEntries: 3,
                // Cache for a maximum of a week.
                maxAgeSeconds: 7 * 24 * 60 * 60,
            })
        ],
    }),
);
<commit_msg>bug fixes<commit_after>importScripts("/packages/code/screens.js?platform=service_worker");
importScripts("/platform/service_worker.js?platform=service_worker");
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.0.0/workbox-sw.js");

var components = [];
for (var package of screens.packages) {
    for (var component in screens[package]) {
        components.push({ package, component });
    }
}
screens.require(components).then(() => screens.core.startup.run());

workbox.routing.registerRoute(
    ({ url, event }) => {
        if (url.pathname === "/") {
            return true;
        }
        if (url.host === "apis.google.com") {
            return true;
        }
        return false;
    },
    new workbox.strategies.NetworkFirst({
        cacheName: "dynamic-cache",
    })
);

workbox.routing.registerRoute(
    /\.(?:html)$/,
    new workbox.strategies.NetworkFirst({
        cacheName: "html-cache",
    })
);

workbox.routing.registerRoute(
    ({ url, event }) => {
        if (url.pathname.endsWith(".js")) {
            return true;
        }
        return false;
    },
    new workbox.strategies.NetworkFirst({
        cacheName: "js-cache",
    })
);

workbox.routing.registerRoute(
    /\.(?:json)$/,
    new workbox.strategies.NetworkFirst({
        cacheName: "json-cache",
    })
);

workbox.routing.registerRoute(
    /\.css$/,
    new workbox.strategies.StaleWhileRevalidate({
        cacheName: "css-cache"
    })
);

workbox.routing.registerRoute(
    /\.(?:woff2|ttf)$/,
    new workbox.strategies.CacheFirst({
        cacheName: "font-cache"
    })
);
workbox.routing.registerRoute(
    /\.(?:png|jpg|jpeg|svg|gif|ico)$/,
    new workbox.strategies.CacheFirst({
        cacheName: "image-cache"
    })
);

workbox.routing.registerRoute(
    /.*\.m4a/,
    new workbox.strategies.CacheFirst({
        cacheName: 'audio-cache',
        plugins: [
            new workbox.cacheableResponse.Plugin({ statuses: [200] }),
            new workbox.rangeRequests.Plugin(),
            new workbox.expiration.Plugin({
                // Cache only 3 files.
                maxEntries: 3,
                // Cache for a maximum of a week.
                maxAgeSeconds: 7 * 24 * 60 * 60,
            })
        ],
    }),
);
<|endoftext|>