<commit_before>'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var MultiSelectValueList = _react2['default'].createClass({

  displayName: 'MultiSelectValueList',

  propTypes: {
    children: _react2['default'].PropTypes.node,
    disabled: _react2['default'].PropTypes.bool, // disabled prop passed to ReactSelect
    id: _react2['default'].PropTypes.string, // Unique id for the value - used for aria
    onClick: _react2['default'].PropTypes.func, // method to handle click on value label
    onRemove: _react2['default'].PropTypes.func, // method to handle removal of the value
    value: _react2['default'].PropTypes.object.isRequired },

  // the option object for this value
  handleMouseDown: function handleMouseDown(event) {
    if (event.type === 'mousedown' && event.button !== 0) {
      return;
    }
    if (this.props.onClick) {
      event.stopPropagation();
      this.props.onClick(this.props.value, event);
      return;
    }
    if (this.props.value.href) {
      event.stopPropagation();
    }
  },

  onRemove: function onRemove(event) {
    event.preventDefault();
    event.stopPropagation();
    this.props.onRemove(this.props.value);
  },

  handleTouchEndRemove: function handleTouchEndRemove(event) {
    // Check if the view is being dragged, In this case
    // we don't want to fire the click event (because the user only wants to scroll)
    if (this.dragging) return;

    // Fire the mouse events
    this.onRemove(event);
  },

  handleTouchMove: function handleTouchMove(event) {
    // Set a flag that the view is being dragged
    this.dragging = true;
  },

  handleTouchStart: function handleTouchStart(event) {
    // Set a flag that the view is not being dragged
    this.dragging = false;
  },

  renderRemoveIcon: function renderRemoveIcon() {
    if (this.props.disabled || !this.props.onRemove) return;
    return _react2['default'].createElement(
      'span',
      { style: { float: "right" },
        className: 'Select-value-icon',
        'aria-hidden': 'true',
        onMouseDown: this.onRemove,
        onTouchEnd: this.handleTouchEndRemove,
        onTouchStart: this.handleTouchStart,
        onTouchMove: this.handleTouchMove },
      '×'
    );
  },

  renderLabel: function renderLabel() {
    return _react2['default'].createElement(
      'span',
      { style: { width: "95%" } },
      this.props.children
    );
  },

  render: function render() {
    return _react2['default'].createElement(
      'div',
      { className: 'col-md-12',
        style: { padding: '0.4em', border: 'thin solid #ccc' },
        title: this.props.value.title
      },
      this.renderLabel(),
      this.renderRemoveIcon()
    );
  }

});

module.exports = MultiSelectValueList;<commit_msg>+ FA icon instead x closing button<commit_after>'use strict';

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var MultiSelectValueList = _react2['default'].createClass({

  displayName: 'MultiSelectValueList',

  propTypes: {
    children: _react2['default'].PropTypes.node,
    disabled: _react2['default'].PropTypes.bool, // disabled prop passed to ReactSelect
    id: _react2['default'].PropTypes.string, // Unique id for the value - used for aria
    onClick: _react2['default'].PropTypes.func, // method to handle click on value label
    onRemove: _react2['default'].PropTypes.func, // method to handle removal of the value
    value: _react2['default'].PropTypes.object.isRequired },

  // the option object for this value
  handleMouseDown: function handleMouseDown(event) {
    if (event.type === 'mousedown' && event.button !== 0) {
      return;
    }
    if (this.props.onClick) {
      event.stopPropagation();
      this.props.onClick(this.props.value, event);
      return;
    }
    if (this.props.value.href) {
      event.stopPropagation();
    }
  },

  onRemove: function onRemove(event) {
    event.preventDefault();
    event.stopPropagation();
    this.props.onRemove(this.props.value);
  },

  handleTouchEndRemove: function handleTouchEndRemove(event) {
    // Check if the view is being dragged, In this case
    // we don't want to fire the click event (because the user only wants to scroll)
    if (this.dragging) return;

    // Fire the mouse events
    this.onRemove(event);
  },

  handleTouchMove: function handleTouchMove(event) {
    // Set a flag that the view is being dragged
    this.dragging = true;
  },

  handleTouchStart: function handleTouchStart(event) {
    // Set a flag that the view is not being dragged
    this.dragging = false;
  },

  renderRemoveIcon: function renderRemoveIcon() {
    if (this.props.disabled || !this.props.onRemove) return;
    return _react2['default'].createElement(
      'span',
      { style: { float: "right" , padding: '10px'},
        className: 'fa fa-minus-square-o',
        'aria-hidden': 'true',
        onMouseDown: this.onRemove,
        onTouchEnd: this.handleTouchEndRemove,
        onTouchStart: this.handleTouchStart,
        onTouchMove: this.handleTouchMove },
      ''
    );
  },

  renderLabel: function renderLabel() {
    return _react2['default'].createElement(
      'span',
      { style: { width: "95%" } },
      this.props.children
    );
  },

  render: function render() {
    return _react2['default'].createElement(
      'div',
      { className: 'col-md-12',
        style: { padding: '0.4em', border: 'thin solid #ccc' },
        title: this.props.value.title
      },
      this.renderLabel(),
      this.renderRemoveIcon()
    );
  }

});

module.exports = MultiSelectValueList;
<|endoftext|>


<commit_before>/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 * full text of the license. */

/**
 * @requires OpenLayers/BaseTypes/Class.js
 * @requires OpenLayers/BaseTypes/LonLat.js
 * @requires OpenLayers/BaseTypes/Size.js
 * @requires OpenLayers/BaseTypes/Pixel.js
 * @requires OpenLayers/BaseTypes/Bounds.js
 * @requires OpenLayers/BaseTypes/Element.js
 * @requires OpenLayers/Lang/en.js
 */

/**
 * Header: OpenLayers Base Types
 * OpenLayers custom string, number and function functions are described here.
 */

/*********************
 *                   *
 *      STRING       *
 *                   *
 *********************/

OpenLayers.String = {

    /**
     * APIFunction: OpenLayers.String.startsWith
     * Test whether a string starts with another string.
     *
     * Parameters:
     * str - {String} The string to test.
     * sub - {Sring} The substring to look for.
     *
     * Returns:
     * {Boolean} The first string starts with the second.
     */
    startsWith: function(str, sub) {
        return (str.indexOf(sub) == 0);
    },

    /**
     * APIFunction: OpenLayers.String.contains
     * Test whether a string contains another string.
     *
     * Parameters:
     * str - {String} The string to test.
     * sub - {String} The substring to look for.
     *
     * Returns:
     * {Boolean} The first string contains the second.
     */
    contains: function(str, sub) {
        return (str.indexOf(sub) != -1);
    },

    /**
     * APIFunction: OpenLayers.String.trim
     * Removes leading and trailing whitespace characters from a string.
     *
     * Parameters:
     * str - {String} The (potentially) space padded string.  This string is not
     *     modified.
     *
     * Returns:
     * {String} A trimmed version of the string with all leading and
     *     trailing spaces removed.
     */
    trim: function(str) {
        return str.replace(/^\s*(.*?)\s*$/, "$1");
    },

    /**
     * APIFunction: OpenLayers.String.camelize
     * Camel-case a hyphenated string.
     *     Ex. "chicken-head" becomes "chickenHead", and
     *     "-chicken-head" becomes "ChickenHead".
     *
     * Parameters:
     * str - {String} The string to be camelized.  The original is not modified.
     *
     * Returns:
     * {String} The string, camelized
     */
    camelize: function(str) {
        var oStringList = str.split('-');
        var camelizedString = oStringList[0];
        for (var i = 1; i < oStringList.length; i++) {
            var s = oStringList[i];
            camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
        }
        return camelizedString;
    },

    /**
     * APIFunction: OpenLayers.String.format
     * Given a string with tokens in the form ${token}, return a string
     *     with tokens replaced with properties from the given context
     *     object.  Represent a literal "${" by doubling it, e.g. "${${".
     *
     * Parameters:
     * template - {String} A string with tokens to be replaced.  A template
     *     has the form "literal ${token}" where the token will be replaced
     *     by the value of context["token"].
     * context - {Object} An optional object with properties corresponding
     *     to the tokens in the format string.  If no context is sent, the
     *     window object will be used.
     * args - {Array} Optional arguments to pass to any functions found in
     *     the context.  If a context property is a function, the token
     *     will be replaced by the return from the function called with
     *     these arguments.
     *
     * Returns:
     * {String} A string with tokens replaced from the context object.
     */
    format: function(template, context, args) {
        if(!context) {
            context = window;
        }
        var tokens = template.split("${");
        var item, last, replacement;
        for(var i=1; i<tokens.length; i++) {
            item = tokens[i];
            last = item.indexOf("}");
            if(last > 0) {
                replacement = context[item.substring(0, last)];
                if(typeof replacement == "function") {
                    replacement = args ?
                        replacement.apply(null, args) :
                        replacement();
                }
                tokens[i] = replacement + item.substring(++last);
            } else {
                tokens[i] = "${" + item;
            }
        }
        return tokens.join("");
    }

};

if (!String.prototype.startsWith) {
    /**
     * APIMethod: String.startsWith
     * *Deprecated*. Whether or not a string starts with another string.
     *
     * Parameters:
     * sStart - {Sring} The string we're testing for.
     *
     * Returns:
     * {Boolean} Whether or not this string starts with the string passed in.
     */
    String.prototype.startsWith = function(sStart) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                {'newMethod':'OpenLayers.String.startsWith'}));
        return OpenLayers.String.startsWith(this, sStart);
    };
}

if (!String.prototype.contains) {
    /**
     * APIMethod: String.contains
     * *Deprecated*. Whether or not a string contains another string.
     *
     * Parameters:
     * str - {String} The string that we're testing for.
     *
     * Returns:
     * {Boolean} Whether or not this string contains with the string passed in.
     */
    String.prototype.contains = function(str) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                  {'newMethod':'OpenLayers.String.contains'}));
        return OpenLayers.String.contains(this, str);
    };
}

if (!String.prototype.trim) {
    /**
     * APIMethod: String.trim
     * *Deprecated*. Removes leading and trailing whitespace characters from a string.
     *
     * Returns:
     * {String} A trimmed version of the string - all leading and
     *          trailing spaces removed
     */
    String.prototype.trim = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                      {'newMethod':'OpenLayers.String.trim'}));
        return OpenLayers.String.trim(this);
    };
}

if (!String.prototype.camelize) {
    /**
     * APIMethod: String.camelize
     * *Deprecated*. Camel-case a hyphenated string.
     *     Ex. "chicken-head" becomes "chickenHead", and
     *     "-chicken-head" becomes "ChickenHead".
     *
     * Returns:
     * {String} The string, camelized
     */
    String.prototype.camelize = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                  {'newMethod':'OpenLayers.String.camelize'}));
        return OpenLayers.String.camelize(this);
    };
}

/*********************
 *                   *
 *      NUMBER       *
 *                   *
 *********************/

OpenLayers.Number = {

    /**
     * Property: OpenLayers.Number.decimalSeparator
     * Decimal separator to use when formatting numbers.
     */
    decimalSeparator: ".",

    /**
     * Property: OpenLayers.Number.thousandsSeparator
     * Thousands separator to use when formatting numbers.
     */
    thousandsSeparator: ",",

    /**
     * APIFunction: OpenLayers.Number.limitSigDigs
     * Limit the number of significant digits on a float.
     *
     * Parameters:
     * num - {Float}
     * sig - {Integer}
     *
     * Returns:
     * {Float} The number, rounded to the specified number of significant
     *     digits.
     */
    limitSigDigs: function(num, sig) {
        var fig = 0;
        if (sig > 0) {
            fig = parseFloat(num.toPrecision(sig));
        }
        return fig;
    },

    /**
     * APIFunction: OpenLayers.Number.format
     * Formats a number for output.
     *
     * Parameters:
     * num  - {Float}
     * dec  - {Integer} Number of decimal places to round to.
     *        Defaults to 0. Set to null to leave decimal places unchanged.
     * tsep - {String} Thousands separator.
     *        Default is ",".
     * dsep - {String} Decimal separator.
     *        Default is ".".
     *
     * Returns:
     * {String} A string representing the formatted number.
     */
    format: function(num, dec, tsep, dsep) {
        dec = (typeof dec != "undefined") ? dec : 0;
        tsep = (typeof tsep != "undefined") ? tsep :
            OpenLayers.Number.thousandsSeparator;
        dsep = (typeof dsep != "undefined") ? dsep :
            OpenLayers.Number.decimalSeparator;

        if (dec != null) {
            num = parseFloat(num.toFixed(dec));
        }

        var parts = num.toString().split(".");
        if (parts.length == 1 && dec == null) {
            // integer where we do not want to touch the decimals
            dec = 0;
        }

        var integer = parts[0];
        if (tsep) {
            var thousands = /(-?[0-9]+)([0-9]{3})/;
            while(thousands.test(integer)) {
                integer = integer.replace(thousands, "$1" + tsep + "$2");
            }
        }

        var str;
        if (dec == 0) {
            str = integer;
        } else {
            var rem = parts.length > 1 ? parts[1] : "0";
            if (dec != null) {
                rem = rem + new Array(dec - rem.length + 1).join("0");
            }
            str = integer + dsep + rem;
        }
        return str;
    }
};

if (!Number.prototype.limitSigDigs) {
    /**
     * APIMethod: Number.limitSigDigs
     * *Deprecated*. Limit the number of significant digits on an integer. Does *not*
     *     work with floats!
     *
     * Parameters:
     * sig - {Integer}
     *
     * Returns:
     * {Integer} The number, rounded to the specified number of significant digits.
     *           If null, 0, or negative value passed in, returns 0
     */
    Number.prototype.limitSigDigs = function(sig) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                              {'newMethod':'OpenLayers.String.limitSigDigs'}));
        return OpenLayers.Number.limitSigDigs(this, sig);
    };
}

/*********************
 *                   *
 *      FUNCTION     *
 *                   *
 *********************/

OpenLayers.Function = {
    /**
     * APIFunction: OpenLayers.Function.bind
     * Bind a function to an object.  Method to easily create closures with
     *     'this' altered.
     *
     * Parameters:
     * func - {Function} Input function.
     * object - {Object} The object to bind to the input function (as this).
     *
     * Returns:
     * {Function} A closure with 'this' set to the passed in object.
     */
    bind: function(func, object) {
        // create a reference to all arguments past the second one
        var args = Array.prototype.slice.apply(arguments, [2]);
        return function() {
            // Push on any additional arguments from the actual function call.
            // These will come after those sent to the bind call.
            var newArgs = args.concat(
                Array.prototype.slice.apply(arguments, [0])
            );
            return func.apply(object, newArgs);
        };
    },

    /**
     * APIFunction: OpenLayers.Function.bindAsEventListener
     * Bind a function to an object, and configure it to receive the event
     *     object as first parameter when called.
     *
     * Parameters:
     * func - {Function} Input function to serve as an event listener.
     * object - {Object} A reference to this.
     *
     * Returns:
     * {Function}
     */
    bindAsEventListener: function(func, object) {
        return function(event) {
            return func.call(object, event || window.event);
        };
    }
};

if (!Function.prototype.bind) {
    /**
     * APIMethod: Function.bind
     * *Deprecated*. Bind a function to an object.
     * Method to easily create closures with 'this' altered.
     *
     * Parameters:
     * object - {Object} the this parameter
     *
     * Returns:
     * {Function} A closure with 'this' altered to the first
     *            argument.
     */
    Function.prototype.bind = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                {'newMethod':'OpenLayers.String.bind'}));
        // new function takes the same arguments with this function up front
        Array.prototype.unshift.apply(arguments, [this]);
        return OpenLayers.Function.bind.apply(null, arguments);
    };
}

if (!Function.prototype.bindAsEventListener) {
    /**
     * APIMethod: Function.bindAsEventListener
     * *Deprecated*. Bind a function to an object, and configure it to receive the
     *     event object as first parameter when called.
     *
     * Parameters:
     * object - {Object} A reference to this.
     *
     * Returns:
     * {Function}
     */
    Function.prototype.bindAsEventListener = function(object) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                        {'newMethod':'OpenLayers.String.bindAsEventListener'}));
        return OpenLayers.Function.bindAsEventListener(this, object);
    };
}

/*********************
 *                   *
 *      ARRAY        *
 *                   *
 *********************/

OpenLayers.Array = {

    /**
     * APIMethod: OpenLayers.Array.filter
     * Filter an array.  Provides the functionality of the
     *     Array.prototype.filter extension to the ECMA-262 standard.  Where
     *     available, Array.prototype.filter will be used.
     *
     * Based on well known example from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter
     *
     * Parameters:
     * array - {Array} The array to be filtered.  This array is not mutated.
     *     Elements added to this array by the callback will not be visited.
     * callback - {Function} A function that is called for each element in
     *     the array.  If this function returns true, the element will be
     *     included in the return.  The function will be called with three
     *     arguments: the element in the array, the index of that element, and
     *     the array itself.  If the optional caller parameter is specified
     *     the callback will be called with this set to caller.
     * caller - {Object} Optional object to be set as this when the callback
     *     is called.
     *
     * Returns:
     * {Array} An array of elements from the passed in array for which the
     *     callback returns true.
     */
    filter: function(array, callback, caller) {
        var selected = [];
        if (Array.prototype.filter) {
            selected = array.filter(callback, caller);
        } else {
            var len = array.length;
            if (typeof callback != "function") {
                throw new TypeError();
            }
            for(var i=0; i<len; i++) {
                if (i in array) {
                    var val = array[i];
                    if (callback.call(caller, val, i, array)) {
                        selected.push(val);
                    }
                }
            }
        }
        return selected;
    }

};
<commit_msg>Dividing base types into namespaces (docs only).  (see #1504)<commit_after>/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 * full text of the license. */

/**
 * @requires OpenLayers/BaseTypes/Class.js
 * @requires OpenLayers/BaseTypes/LonLat.js
 * @requires OpenLayers/BaseTypes/Size.js
 * @requires OpenLayers/BaseTypes/Pixel.js
 * @requires OpenLayers/BaseTypes/Bounds.js
 * @requires OpenLayers/BaseTypes/Element.js
 * @requires OpenLayers/Lang/en.js
 */

/**
 * Header: OpenLayers Base Types
 * OpenLayers custom string, number and function functions are described here.
 */

/**
 * Namespace: OpenLayers.String
 * Contains convenience functions for string manipulation.
 */
OpenLayers.String = {

    /**
     * APIFunction: startsWith
     * Test whether a string starts with another string.
     *
     * Parameters:
     * str - {String} The string to test.
     * sub - {Sring} The substring to look for.
     *
     * Returns:
     * {Boolean} The first string starts with the second.
     */
    startsWith: function(str, sub) {
        return (str.indexOf(sub) == 0);
    },

    /**
     * APIFunction: contains
     * Test whether a string contains another string.
     *
     * Parameters:
     * str - {String} The string to test.
     * sub - {String} The substring to look for.
     *
     * Returns:
     * {Boolean} The first string contains the second.
     */
    contains: function(str, sub) {
        return (str.indexOf(sub) != -1);
    },

    /**
     * APIFunction: trim
     * Removes leading and trailing whitespace characters from a string.
     *
     * Parameters:
     * str - {String} The (potentially) space padded string.  This string is not
     *     modified.
     *
     * Returns:
     * {String} A trimmed version of the string with all leading and
     *     trailing spaces removed.
     */
    trim: function(str) {
        return str.replace(/^\s*(.*?)\s*$/, "$1");
    },

    /**
     * APIFunction: camelize
     * Camel-case a hyphenated string.
     *     Ex. "chicken-head" becomes "chickenHead", and
     *     "-chicken-head" becomes "ChickenHead".
     *
     * Parameters:
     * str - {String} The string to be camelized.  The original is not modified.
     *
     * Returns:
     * {String} The string, camelized
     */
    camelize: function(str) {
        var oStringList = str.split('-');
        var camelizedString = oStringList[0];
        for (var i = 1; i < oStringList.length; i++) {
            var s = oStringList[i];
            camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
        }
        return camelizedString;
    },

    /**
     * APIFunction: format
     * Given a string with tokens in the form ${token}, return a string
     *     with tokens replaced with properties from the given context
     *     object.  Represent a literal "${" by doubling it, e.g. "${${".
     *
     * Parameters:
     * template - {String} A string with tokens to be replaced.  A template
     *     has the form "literal ${token}" where the token will be replaced
     *     by the value of context["token"].
     * context - {Object} An optional object with properties corresponding
     *     to the tokens in the format string.  If no context is sent, the
     *     window object will be used.
     * args - {Array} Optional arguments to pass to any functions found in
     *     the context.  If a context property is a function, the token
     *     will be replaced by the return from the function called with
     *     these arguments.
     *
     * Returns:
     * {String} A string with tokens replaced from the context object.
     */
    format: function(template, context, args) {
        if(!context) {
            context = window;
        }
        var tokens = template.split("${");
        var item, last, replacement;
        for(var i=1; i<tokens.length; i++) {
            item = tokens[i];
            last = item.indexOf("}");
            if(last > 0) {
                replacement = context[item.substring(0, last)];
                if(typeof replacement == "function") {
                    replacement = args ?
                        replacement.apply(null, args) :
                        replacement();
                }
                tokens[i] = replacement + item.substring(++last);
            } else {
                tokens[i] = "${" + item;
            }
        }
        return tokens.join("");
    }

};

if (!String.prototype.startsWith) {
    /**
     * APIMethod: String.startsWith
     * *Deprecated*. Whether or not a string starts with another string.
     *
     * Parameters:
     * sStart - {Sring} The string we're testing for.
     *
     * Returns:
     * {Boolean} Whether or not this string starts with the string passed in.
     */
    String.prototype.startsWith = function(sStart) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                {'newMethod':'OpenLayers.String.startsWith'}));
        return OpenLayers.String.startsWith(this, sStart);
    };
}

if (!String.prototype.contains) {
    /**
     * APIMethod: String.contains
     * *Deprecated*. Whether or not a string contains another string.
     *
     * Parameters:
     * str - {String} The string that we're testing for.
     *
     * Returns:
     * {Boolean} Whether or not this string contains with the string passed in.
     */
    String.prototype.contains = function(str) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                  {'newMethod':'OpenLayers.String.contains'}));
        return OpenLayers.String.contains(this, str);
    };
}

if (!String.prototype.trim) {
    /**
     * APIMethod: String.trim
     * *Deprecated*. Removes leading and trailing whitespace characters from a string.
     *
     * Returns:
     * {String} A trimmed version of the string - all leading and
     *          trailing spaces removed
     */
    String.prototype.trim = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                      {'newMethod':'OpenLayers.String.trim'}));
        return OpenLayers.String.trim(this);
    };
}

if (!String.prototype.camelize) {
    /**
     * APIMethod: String.camelize
     * *Deprecated*. Camel-case a hyphenated string.
     *     Ex. "chicken-head" becomes "chickenHead", and
     *     "-chicken-head" becomes "ChickenHead".
     *
     * Returns:
     * {String} The string, camelized
     */
    String.prototype.camelize = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                  {'newMethod':'OpenLayers.String.camelize'}));
        return OpenLayers.String.camelize(this);
    };
}

/**
 * Namespace: OpenLayers.Number
 * Contains convenience functions for manipulating numbers.
 */
OpenLayers.Number = {

    /**
     * Property: decimalSeparator
     * Decimal separator to use when formatting numbers.
     */
    decimalSeparator: ".",

    /**
     * Property: thousandsSeparator
     * Thousands separator to use when formatting numbers.
     */
    thousandsSeparator: ",",

    /**
     * APIFunction: limitSigDigs
     * Limit the number of significant digits on a float.
     *
     * Parameters:
     * num - {Float}
     * sig - {Integer}
     *
     * Returns:
     * {Float} The number, rounded to the specified number of significant
     *     digits.
     */
    limitSigDigs: function(num, sig) {
        var fig = 0;
        if (sig > 0) {
            fig = parseFloat(num.toPrecision(sig));
        }
        return fig;
    },

    /**
     * APIFunction: format
     * Formats a number for output.
     *
     * Parameters:
     * num  - {Float}
     * dec  - {Integer} Number of decimal places to round to.
     *        Defaults to 0. Set to null to leave decimal places unchanged.
     * tsep - {String} Thousands separator.
     *        Default is ",".
     * dsep - {String} Decimal separator.
     *        Default is ".".
     *
     * Returns:
     * {String} A string representing the formatted number.
     */
    format: function(num, dec, tsep, dsep) {
        dec = (typeof dec != "undefined") ? dec : 0;
        tsep = (typeof tsep != "undefined") ? tsep :
            OpenLayers.Number.thousandsSeparator;
        dsep = (typeof dsep != "undefined") ? dsep :
            OpenLayers.Number.decimalSeparator;

        if (dec != null) {
            num = parseFloat(num.toFixed(dec));
        }

        var parts = num.toString().split(".");
        if (parts.length == 1 && dec == null) {
            // integer where we do not want to touch the decimals
            dec = 0;
        }

        var integer = parts[0];
        if (tsep) {
            var thousands = /(-?[0-9]+)([0-9]{3})/;
            while(thousands.test(integer)) {
                integer = integer.replace(thousands, "$1" + tsep + "$2");
            }
        }

        var str;
        if (dec == 0) {
            str = integer;
        } else {
            var rem = parts.length > 1 ? parts[1] : "0";
            if (dec != null) {
                rem = rem + new Array(dec - rem.length + 1).join("0");
            }
            str = integer + dsep + rem;
        }
        return str;
    }
};

if (!Number.prototype.limitSigDigs) {
    /**
     * APIMethod: Number.limitSigDigs
     * *Deprecated*. Limit the number of significant digits on an integer. Does *not*
     *     work with floats!
     *
     * Parameters:
     * sig - {Integer}
     *
     * Returns:
     * {Integer} The number, rounded to the specified number of significant digits.
     *           If null, 0, or negative value passed in, returns 0
     */
    Number.prototype.limitSigDigs = function(sig) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                              {'newMethod':'OpenLayers.String.limitSigDigs'}));
        return OpenLayers.Number.limitSigDigs(this, sig);
    };
}

/**
 * Namespace: OpenLayers.Function
 * Contains convenience functions for function manipulation.
 */
OpenLayers.Function = {
    /**
     * APIFunction: bind
     * Bind a function to an object.  Method to easily create closures with
     *     'this' altered.
     *
     * Parameters:
     * func - {Function} Input function.
     * object - {Object} The object to bind to the input function (as this).
     *
     * Returns:
     * {Function} A closure with 'this' set to the passed in object.
     */
    bind: function(func, object) {
        // create a reference to all arguments past the second one
        var args = Array.prototype.slice.apply(arguments, [2]);
        return function() {
            // Push on any additional arguments from the actual function call.
            // These will come after those sent to the bind call.
            var newArgs = args.concat(
                Array.prototype.slice.apply(arguments, [0])
            );
            return func.apply(object, newArgs);
        };
    },

    /**
     * APIFunction: bindAsEventListener
     * Bind a function to an object, and configure it to receive the event
     *     object as first parameter when called.
     *
     * Parameters:
     * func - {Function} Input function to serve as an event listener.
     * object - {Object} A reference to this.
     *
     * Returns:
     * {Function}
     */
    bindAsEventListener: function(func, object) {
        return function(event) {
            return func.call(object, event || window.event);
        };
    }
};

if (!Function.prototype.bind) {
    /**
     * APIMethod: Function.bind
     * *Deprecated*. Bind a function to an object.
     * Method to easily create closures with 'this' altered.
     *
     * Parameters:
     * object - {Object} the this parameter
     *
     * Returns:
     * {Function} A closure with 'this' altered to the first
     *            argument.
     */
    Function.prototype.bind = function() {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                                {'newMethod':'OpenLayers.String.bind'}));
        // new function takes the same arguments with this function up front
        Array.prototype.unshift.apply(arguments, [this]);
        return OpenLayers.Function.bind.apply(null, arguments);
    };
}

if (!Function.prototype.bindAsEventListener) {
    /**
     * APIMethod: Function.bindAsEventListener
     * *Deprecated*. Bind a function to an object, and configure it to receive the
     *     event object as first parameter when called.
     *
     * Parameters:
     * object - {Object} A reference to this.
     *
     * Returns:
     * {Function}
     */
    Function.prototype.bindAsEventListener = function(object) {
        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
                        {'newMethod':'OpenLayers.String.bindAsEventListener'}));
        return OpenLayers.Function.bindAsEventListener(this, object);
    };
}

/**
 * Namespace: OpenLayers.Array
 * Contains convenience functions for array manipulation.
 */
OpenLayers.Array = {

    /**
     * APIMethod: filter
     * Filter an array.  Provides the functionality of the
     *     Array.prototype.filter extension to the ECMA-262 standard.  Where
     *     available, Array.prototype.filter will be used.
     *
     * Based on well known example from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter
     *
     * Parameters:
     * array - {Array} The array to be filtered.  This array is not mutated.
     *     Elements added to this array by the callback will not be visited.
     * callback - {Function} A function that is called for each element in
     *     the array.  If this function returns true, the element will be
     *     included in the return.  The function will be called with three
     *     arguments: the element in the array, the index of that element, and
     *     the array itself.  If the optional caller parameter is specified
     *     the callback will be called with this set to caller.
     * caller - {Object} Optional object to be set as this when the callback
     *     is called.
     *
     * Returns:
     * {Array} An array of elements from the passed in array for which the
     *     callback returns true.
     */
    filter: function(array, callback, caller) {
        var selected = [];
        if (Array.prototype.filter) {
            selected = array.filter(callback, caller);
        } else {
            var len = array.length;
            if (typeof callback != "function") {
                throw new TypeError();
            }
            for(var i=0; i<len; i++) {
                if (i in array) {
                    var val = array[i];
                    if (callback.call(caller, val, i, array)) {
                        selected.push(val);
                    }
                }
            }
        }
        return selected;
    }

};
<|endoftext|>


<commit_before>define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var BxlHighlightRules = function() {

	var keywords = "this|super|root|forkey|forval"
	var controlKeywords = "if|else|while|for|break|continue|switch|case|default|return"
	var trees = "loc|in|out|cfg|data|env|tmp|throw|try|catch|finally"
	var types = "bool|int|float|double|string|date|time|dateTime|path"
    var support_functions = "log|warning|error|info|java|compile|exec|stack|trace"

	var docRegex = "\\b(?:TODO|FIXME|XXX|HACK|BUG|BARLA)\\b"
	var urlRegex = /https?:\/\/[^\s]+/

	var keywordMapper = this.createKeywordMapper({
        "keyword": keywords,
        "keyword.control": controlKeywords,
        "variable.language": trees,
        "support.function": support_functions,
        "storage.type": types
    }, "identifier.XXX");

	this.$rules = {
	    "start": [ {
			token : "comment.line",
			regex : "\\/\\/",
			next  : "singlelineComment"
        }, {
			token : "comment.block",
			regex : "\\/\\*",
			next : "multilineComment"
		}, {
			token : "string.triple",
			regex : "'''",
			next  : "tripleQuotedString"
		}, {
			token : "string.single",
			regex : '[\']',
			next  : "singleQuotedString"
		}, {
		    token : "string.double",
		    regex : '"',
		    next  : "doubleQuotedString"
		}, {
			token : "constant.numeric", // number
			regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|F|f|D|d)?\\b"
		}, {
			token : "constant.language.boolean", // boolean
			regex : "(?:true|false)\\b"
		}, {
			token : "constant.language", // null and empty tree
			regex : "(?:null|empty)\\b"
		},{
			token : "identifier.tree", // tree paths // language.variable
			regex : "(/[\\w]+)"
		}, /*{
			token : "support.function.module", // module operation call
			regex : "(\\$\\w+\\.\\w+)"
		}, */{
			token : "support.function.agent", // module operation call
			regex : "(\\w+\\.)(\\w+)"
		}, {
			token : keywordMapper,
			regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
		}, {
			token : "keyword.operator", // TODO precistit
			regex : "!|\\$|%|&|\/|\\*|\\-\\-|\\-|\\+\\+|\\+|\\.|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^="
		}, {
			token : "lparen",
			regex : "[[({]"
		}, {
			token : "rparen",
			regex : "[\\])}]"
		}],
		"multilineComment" : [ {
			token : "comment",
			regex : ".*?\\*\\/",
			next : "start"
		}, {
		    token : "invalid.illegal",
            regex : docRegex
		}, {
		    token: "comment.markup.underline.link",
		    regex : urlRegex
		}, {
			defaultToken : "comment"
		}],
		"singlelineComment": [{
		    token : "",
		    regex : "^",
		    next  : "start"
		}, {
		    token : "invalid.illegal",
            regex : docRegex
		}, {
		    token: "comment.markup.underline.link",
		    regex : urlRegex
		}, {
		    defaultToken: "comment.line"
		}],
		"singleQuotedString" : [{
			token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
			token : "string.escaped",
			regex : "[\\\\]."
		}, {
			token : "string.single",
			regex : '[\']',
			next  : "start"
		}, {
			defaultToken : "string.single"
		}],
		"doubleQuotedString": [{
		    token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
			token : "string.escaped",
			regex : "[\\\\]."
		}, {
			token : "string.double",
			regex : '["]',
			next  : "start"
		}, {
			defaultToken : "string.double"
		}],
		"tripleQuotedString"  : [{
			token : "string.triple",
			regex : "'''",
			next  : "start"
		}, {
			token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
            defaultToken : "string.triple"
        }]
	};

}

oop.inherits(BxlHighlightRules, TextHighlightRules);

exports.BxlHighlightRules = BxlHighlightRules;

});<commit_msg>Added highlighting of do-while statement.<commit_after>define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var BxlHighlightRules = function() {

	var keywords = "this|super|root|forkey|forval"
	var controlKeywords = "if|else|do|while|for|break|continue|switch|case|default|return"
	var trees = "loc|in|out|cfg|data|env|tmp|throw|try|catch|finally"
	var types = "bool|int|float|double|string|date|time|dateTime|path"
    var support_functions = "log|warning|error|info|java|compile|exec|stack|trace"

	var docRegex = "\\b(?:TODO|FIXME|XXX|HACK|BUG|BARLA)\\b"
	var urlRegex = /https?:\/\/[^\s]+/

	var keywordMapper = this.createKeywordMapper({
        "keyword": keywords,
        "keyword.control": controlKeywords,
        "variable.language": trees,
        "support.function": support_functions,
        "storage.type": types
    }, "identifier.XXX");

	this.$rules = {
	    "start": [ {
			token : "comment.line",
			regex : "\\/\\/",
			next  : "singlelineComment"
        }, {
			token : "comment.block",
			regex : "\\/\\*",
			next : "multilineComment"
		}, {
			token : "string.triple",
			regex : "'''",
			next  : "tripleQuotedString"
		}, {
			token : "string.single",
			regex : '[\']',
			next  : "singleQuotedString"
		}, {
		    token : "string.double",
		    regex : '"',
		    next  : "doubleQuotedString"
		}, {
			token : "constant.numeric", // number
			regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|F|f|D|d)?\\b"
		}, {
			token : "constant.language.boolean", // boolean
			regex : "(?:true|false)\\b"
		}, {
			token : "constant.language", // null and empty tree
			regex : "(?:null|empty)\\b"
		},{
			token : "identifier.tree", // tree paths // language.variable
			regex : "(/[\\w]+)"
		}, /*{
			token : "support.function.module", // module operation call
			regex : "(\\$\\w+\\.\\w+)"
		}, */{
			token : "support.function.agent", // module operation call
			regex : "(\\w+\\.)(\\w+)"
		}, {
			token : keywordMapper,
			regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
		}, {
			token : "keyword.operator", // TODO precistit
			regex : "!|\\$|%|&|\/|\\*|\\-\\-|\\-|\\+\\+|\\+|\\.|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^="
		}, {
			token : "lparen",
			regex : "[[({]"
		}, {
			token : "rparen",
			regex : "[\\])}]"
		}],
		"multilineComment" : [ {
			token : "comment",
			regex : ".*?\\*\\/",
			next : "start"
		}, {
		    token : "invalid.illegal",
            regex : docRegex
		}, {
		    token: "comment.markup.underline.link",
		    regex : urlRegex
		}, {
			defaultToken : "comment"
		}],
		"singlelineComment": [{
		    token : "",
		    regex : "^",
		    next  : "start"
		}, {
		    token : "invalid.illegal",
            regex : docRegex
		}, {
		    token: "comment.markup.underline.link",
		    regex : urlRegex
		}, {
		    defaultToken: "comment.line"
		}],
		"singleQuotedString" : [{
			token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
			token : "string.escaped",
			regex : "[\\\\]."
		}, {
			token : "string.single",
			regex : '[\']',
			next  : "start"
		}, {
			defaultToken : "string.single"
		}],
		"doubleQuotedString": [{
		    token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
			token : "string.escaped",
			regex : "[\\\\]."
		}, {
			token : "string.double",
			regex : '["]',
			next  : "start"
		}, {
			defaultToken : "string.double"
		}],
		"tripleQuotedString"  : [{
			token : "string.triple",
			regex : "'''",
			next  : "start"
		}, {
			token : "variable.parameter",
			regex : "%%.*?%%"
		}, {
            defaultToken : "string.triple"
        }]
	};

}

oop.inherits(BxlHighlightRules, TextHighlightRules);

exports.BxlHighlightRules = BxlHighlightRules;

});<|endoftext|>


<commit_before>var selftest = require('../selftest.js');
var Sandbox = selftest.Sandbox;
var archinfo = require('../archinfo.js');
var release = require('../release.js');

selftest.define("argument parsing", function () {
  var s = new Sandbox;
  var run;

  // bad command
  run = s.run("aoeuasdf");
  run.matchErr("not a Meteor command");
  run.expectExit(1);

  // bad subcommand
  run = s.run("admin", "aoeuasdf");
  run.matchErr("not a Meteor command");
  run.expectExit(1);

  // missing subcommand
  run = s.run("admin");
  run.matchErr("for available commands");
  run.expectExit(1);

  // conflicting command-like options
  run = s.run("aoeuasdf", "--version");
  run.matchErr("pass anything else along with --version");
  run.expectExit(1);

  run = s.run("--arch", "--version");
  run.matchErr("pass anything else");
  run.expectExit(1);

  run = s.run("run", "--version");
  run.matchErr("pass anything else");
  run.expectExit(1);

  run = s.run("--arch", "--arch");
  run.matchErr("more than once");
  run.expectExit(1);

  // --release takes exactly one value
  run = s.run("--release");
  run.matchErr("needs a value");
  run.expectExit(1);

  run = s.run("--release", "abc", "--release", "def");
  run.matchErr("should only be passed once");
  run.expectExit(1);

  // required option missing
  run = s.run("dummy");
  run.matchErr("option is required");
  run.matchErr("Usage: meteor dummy");
  run.expectExit(1);

  // successful command invocation, correct parsing of arguments
  run = s.run("dummy", "--ething", "x");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "", "");
  run.read('"x" "3000" none ["",""]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething=");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-e=");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-");
  run.read('"x" "3000" none ["-"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-e", "x");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-e", "");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-exxx");
  run.read('"xxx" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "-");
  run.read('"-" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "1234", "--changed");
  run.read('"x" 1234 true []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "0", "true");
  run.read('"x" 0 none ["true"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "01234", "12", "0013");
  run.read('"x" 1234 none ["12","0013"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "--port", "1234", "--changed");
  run.read('"--port" "3000" true ["1234"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething=x=y=z", "-Up=3000");
  run.read('"x=y=z" 3000 none []\nurl\n');
  run.expectEnd();
  run.expectExit(0);

  // bad option
  run = s.run("dummy", "--ething", "x", "--foo");
  run.matchErr("--foo: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-z");
  run.matchErr("-z: unknown option");
  run.expectExit(1);

  // passing short and long options
  run = s.run("dummy", "--ething", "x", "-p", "2000", "--port", "2000");
  run.matchErr("can't pass both -p and --port");
  run.expectExit(1);

  // multiple values for an option
  run = s.run("dummy", "--ething", "x", "--port", "2000", "--port", "3000");
  run.matchErr("can only take one --port option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-p", "2000", "-p", "2000");
  run.matchErr("can only take one --port (-p) option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "--changed", "--changed");
  run.matchErr("can only take one --changed option");
  run.expectExit(1);

  // missing option value
  run = s.run("dummy", "--ething", "x", "--port");
  run.matchErr("the --port option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "--ething");
  run.matchErr("--ething option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "-e");
  run.matchErr("--ething (-e) option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "--changed", "-p");
  run.matchErr("the --port (-p) option needs a value");
  run.expectExit(1);

  // non-numeric value for numeric option
  run = s.run("dummy", "--ething", "x", "--port", "kitten");
  run.matchErr("--port must be a number");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-p", "1234k");
  run.matchErr("--port (-p) must be a number");
  run.expectExit(1);

  // bad use of =
  run = s.run("dummy", "--=");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "--=asdf");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "-=");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "--changed=foo");
  run.matchErr("the --changed option does not need a value.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "-D=foo");
  run.matchErr("the --delete (-D) option does not need a value.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "-UD=foo");
  run.matchErr("the --delete (-D) option does not need a value.\n");
  run.expectExit(1);

  // incorrect number of arguments
  run = s.run("dummy", "--ething", "x", "1", "2", "3");
  run.matchErr("too many arguments");
  run.matchErr("Usage: meteor dummy");
  run.expectExit(1);

  run = s.run("bundle");
  run.matchErr("not enough arguments");
  run.matchErr("This command has been deprecated");
  run.expectExit(1);

  run = s.run("bundle", "a", "b");
  run.matchErr("too many arguments");
  run.matchErr("This command has been deprecated");
  run.expectExit(1);

  run = s.run("build");
  run.matchErr("not enough arguments");
  run.matchErr("Usage: meteor build");
  run.expectExit(1);

  run = s.run("build", "a", "b");
  run.matchErr("too many arguments");
  run.matchErr("Usage: meteor build");
  run.expectExit(1);

  // '--' to end parsing
  run = s.run("dummy", "--ething", "x", "--", "-p", "4000");
  run.read('"x" "3000" none ["-p","4000"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--", "--changed", "--changed");
  run.read('"x" "3000" none ["--changed","--changed"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  // compact short options
  run = s.run("dummy", "--ething", "x", "-p4000", "--changed");
  run.read('"x" 4000 true []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UD", "--changed");
  run.read('"x" "3000" true []\nurl\n\delete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000", "--changed");
  run.read('"x" 4000 true []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000", "--changed");
  run.read('"x" 4000 true []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000");
  run.read('"x" 4000 none []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDkp4000", "--changed");
  run.matchErr("-k: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UDp4000k", "--changed");
  run.matchErr("--port (-p) must be a number");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UD4000k", "--changed");
  run.matchErr("-4: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UDDp4000", "--changed");
  run.matchErr("one --delete (-D) option");
  run.expectExit(1);

  // requiring an app dir
  run = s.run("list");
  run.matchErr("not in a Meteor project");
  run.matchErr("meteor create"); // new user help
  run.expectExit(1);

  s.createApp('myapp', 'standard-app');
  s.cd('myapp', function () {
    run = s.run("list");
    run.expectExit(0);
  });
});

selftest.define("command-like options", function () {
  var s = new Sandbox;
  var run;

  run = s.run("--version");
  if (release.current.isCheckout()) {
    run.matchErr("Unreleased");
    run.expectExit(1);
  } else {
    run.read(release.current.getDisplayName() + "\n");
    run.expectEnd();
    run.expectExit(0);
  }

  run = s.run("--arch");
  run.read(archinfo.host() + "\n");
  run.expectEnd();
  run.expectExit(0);
});
<commit_msg>Comment out empty string arg tests<commit_after>var selftest = require('../selftest.js');
var Sandbox = selftest.Sandbox;
var archinfo = require('../archinfo.js');
var release = require('../release.js');

selftest.define("argument parsing", function () {
  var s = new Sandbox;
  var run;

  // bad command
  run = s.run("aoeuasdf");
  run.matchErr("not a Meteor command");
  run.expectExit(1);

  // bad subcommand
  run = s.run("admin", "aoeuasdf");
  run.matchErr("not a Meteor command");
  run.expectExit(1);

  // missing subcommand
  run = s.run("admin");
  run.matchErr("for available commands");
  run.expectExit(1);

  // conflicting command-like options
  run = s.run("aoeuasdf", "--version");
  run.matchErr("pass anything else along with --version");
  run.expectExit(1);

  run = s.run("--arch", "--version");
  run.matchErr("pass anything else");
  run.expectExit(1);

  run = s.run("run", "--version");
  run.matchErr("pass anything else");
  run.expectExit(1);

  run = s.run("--arch", "--arch");
  run.matchErr("more than once");
  run.expectExit(1);

  // --release takes exactly one value
  run = s.run("--release");
  run.matchErr("needs a value");
  run.expectExit(1);

  run = s.run("--release", "abc", "--release", "def");
  run.matchErr("should only be passed once");
  run.expectExit(1);

  // required option missing
  run = s.run("dummy");
  run.matchErr("option is required");
  run.matchErr("Usage: meteor dummy");
  run.expectExit(1);

  // successful command invocation, correct parsing of arguments
  run = s.run("dummy", "--ething", "x");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  // The tests below fail on Windows. There is a bug in Node about empty
  // arguments that was fixed recently:
  // https://github.com/joyent/node/issues/7138
  // run = s.run("dummy", "--ething", "");
  // run.read('"" "3000" none []\n');
  // run.expectEnd();
  // run.expectExit(0);

  // run = s.run("dummy", "--ething", "x", "", "");
  // run.read('"x" "3000" none ["",""]\n');
  // run.expectEnd();
  // run.expectExit(0);

  run = s.run("dummy", "--ething=");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-e=");
  run.read('"" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-");
  run.read('"x" "3000" none ["-"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "-e", "x");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  // See comment above about empty arguments
  // run = s.run("dummy", "-e", "");
  // run.read('"" "3000" none []\n');
  // run.expectEnd();
  // run.expectExit(0);

  run = s.run("dummy", "-exxx");
  run.read('"xxx" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "-");
  run.read('"-" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "1234", "--changed");
  run.read('"x" 1234 true []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "0", "true");
  run.read('"x" 0 none ["true"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--port", "01234", "12", "0013");
  run.read('"x" 1234 none ["12","0013"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "--port", "1234", "--changed");
  run.read('"--port" "3000" true ["1234"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething=x=y=z", "-Up=3000");
  run.read('"x=y=z" 3000 none []\nurl\n');
  run.expectEnd();
  run.expectExit(0);

  // bad option
  run = s.run("dummy", "--ething", "x", "--foo");
  run.matchErr("--foo: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-z");
  run.matchErr("-z: unknown option");
  run.expectExit(1);

  // passing short and long options
  run = s.run("dummy", "--ething", "x", "-p", "2000", "--port", "2000");
  run.matchErr("can't pass both -p and --port");
  run.expectExit(1);

  // multiple values for an option
  run = s.run("dummy", "--ething", "x", "--port", "2000", "--port", "3000");
  run.matchErr("can only take one --port option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-p", "2000", "-p", "2000");
  run.matchErr("can only take one --port (-p) option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "--changed", "--changed");
  run.matchErr("can only take one --changed option");
  run.expectExit(1);

  // missing option value
  run = s.run("dummy", "--ething", "x", "--port");
  run.matchErr("the --port option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "--ething");
  run.matchErr("--ething option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "-e");
  run.matchErr("--ething (-e) option needs a value");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "--changed", "-p");
  run.matchErr("the --port (-p) option needs a value");
  run.expectExit(1);

  // non-numeric value for numeric option
  run = s.run("dummy", "--ething", "x", "--port", "kitten");
  run.matchErr("--port must be a number");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-p", "1234k");
  run.matchErr("--port (-p) must be a number");
  run.expectExit(1);

  // bad use of =
  run = s.run("dummy", "--=");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "--=asdf");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "-=");
  run.readErr("Option names cannot begin with '='.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "--changed=foo");
  run.matchErr("the --changed option does not need a value.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "-D=foo");
  run.matchErr("the --delete (-D) option does not need a value.\n");
  run.expectExit(1);

  run = s.run("dummy", "-ex", "-UD=foo");
  run.matchErr("the --delete (-D) option does not need a value.\n");
  run.expectExit(1);

  // incorrect number of arguments
  run = s.run("dummy", "--ething", "x", "1", "2", "3");
  run.matchErr("too many arguments");
  run.matchErr("Usage: meteor dummy");
  run.expectExit(1);

  run = s.run("bundle");
  run.matchErr("not enough arguments");
  run.matchErr("This command has been deprecated");
  run.expectExit(1);

  run = s.run("bundle", "a", "b");
  run.matchErr("too many arguments");
  run.matchErr("This command has been deprecated");
  run.expectExit(1);

  run = s.run("build");
  run.matchErr("not enough arguments");
  run.matchErr("Usage: meteor build");
  run.expectExit(1);

  run = s.run("build", "a", "b");
  run.matchErr("too many arguments");
  run.matchErr("Usage: meteor build");
  run.expectExit(1);

  // '--' to end parsing
  run = s.run("dummy", "--ething", "x", "--", "-p", "4000");
  run.read('"x" "3000" none ["-p","4000"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--", "--changed", "--changed");
  run.read('"x" "3000" none ["--changed","--changed"]\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "--");
  run.read('"x" "3000" none []\n');
  run.expectEnd();
  run.expectExit(0);

  // compact short options
  run = s.run("dummy", "--ething", "x", "-p4000", "--changed");
  run.read('"x" 4000 true []\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UD", "--changed");
  run.read('"x" "3000" true []\nurl\n\delete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000", "--changed");
  run.read('"x" 4000 true []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000", "--changed");
  run.read('"x" 4000 true []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDp4000");
  run.read('"x" 4000 none []\nurl\ndelete\n');
  run.expectEnd();
  run.expectExit(0);

  run = s.run("dummy", "--ething", "x", "-UDkp4000", "--changed");
  run.matchErr("-k: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UDp4000k", "--changed");
  run.matchErr("--port (-p) must be a number");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UD4000k", "--changed");
  run.matchErr("-4: unknown option");
  run.expectExit(1);

  run = s.run("dummy", "--ething", "x", "-UDDp4000", "--changed");
  run.matchErr("one --delete (-D) option");
  run.expectExit(1);

  // requiring an app dir
  run = s.run("list");
  run.matchErr("not in a Meteor project");
  run.matchErr("meteor create"); // new user help
  run.expectExit(1);

  s.createApp('myapp', 'standard-app');
  s.cd('myapp', function () {
    run = s.run("list");
    run.expectExit(0);
  });
});

selftest.define("command-like options", function () {
  var s = new Sandbox;
  var run;

  run = s.run("--version");
  if (release.current.isCheckout()) {
    run.matchErr("Unreleased");
    run.expectExit(1);
  } else {
    run.read(release.current.getDisplayName() + "\n");
    run.expectEnd();
    run.expectExit(0);
  }

  run = s.run("--arch");
  run.read(archinfo.host() + "\n");
  run.expectEnd();
  run.expectExit(0);
});
<|endoftext|>


<commit_before>var path = require('path');
var Database = require('../../database').Database;
var Domain = require('../../domain').Domain;
var Deferred = require('jsdeferred').Deferred;

exports.version = path.basename(__dirname);

var XMLNS = 'http://cloudsearch.amazonaws.com/doc/2011-02-01';
var FAKE_DOMAIN_ID = 'example';

function createCommonErrorResponse(errorCode, message) {
  return '<?xml version="1.0"?>\n' +
         '<Response>' +
           '<Errors>' +
             '<Error>' + errorCode +'' +
                     '<Message>' + message + '</Message></Error>' +
             '</Errors>' +
           '<RequestID></RequestID>' +
         '</Response>';
}

var handlers = Object.create(null);

function getBaseDomain(domain) {
  return domain.replace(/^cloudsearch\./, '');
}

function createDomainStatus(options) {
return '<DomainStatus>' +
         '<SearchPartitionCount>' + (options.searchPartitionCount || 0) +
           '</SearchPartitionCount>' +
         '<SearchService>' +
           '<Endpoint>' + (options.searchEndpoint || '') +'</Endpoint>' +
         '</SearchService>' +
         '<NumSearchableDocs>' + (options.searchableDocumentsCount || 0) +
           '</NumSearchableDocs>' +
         '<Created>' + (options.created || 'false') + '</Created>' +
         '<DomainId>' + options.domainName + '/' + options.domainName +
           '</DomainId>' +
         '<SearchInstanceCount>' + (options.searchInstanceCount || 0) +
           '</SearchInstanceCount>' +
         '<DomainName>' + options.domainName + '</DomainName>' +
         '<RequiresIndexDocuments>' +
           (options.requiresIndexDocuments || 'false') +
           '</RequiresIndexDocuments>' +
         '<Deleted>' + (options.deleted || 'false') + '</Deleted>' +
         '<DocService>' +
           '<Endpoint>' + (options.documentsEndpoint || '') +'</Endpoint>' +
         '</DocService>' +
       '</DomainStatus>';
}

function createCreateDomainResponse(options) {
  return '<?xml version="1.0"?>\n' +
         '<CreateDomainResponse xmlns="' + XMLNS + '">' +
           '<CreateDomainResult>' +
             createDomainStatus() +
           '</CreateDomainResult>' +
           '<ResponseMetadata>' +
             '<RequestId>' + (options.requestId || '') + '</RequestId>' +
           '</ResponseMetadata>' +
         '</CreateDomainResponse>';
}

handlers.CreateDomain = function(database, request, response) {
  var domain = new Domain(request);
  var options = {
        name: domain.tableName,
        flags: Database.TABLE_HASH_KEY,
        key_type: Database.ShortText
      };
  database.commandDeferred('table_create', options)
    .next(function(data) {
      var termsOptions = {
            name: domain.termsTableName,
            flags: Database.TABLE_PAT_KEY + '|' + Database.KEY_NORMALIZE,
            key_type: Database.ShortText,
            default_tokenizer: Database.TokenBigram
          };
      return database.commandDeferred('table_create', termsOptions);
    })
    .next(function(data) {
      var host = getBaseDomain(request.headers.host);
      response.contentType('application/xml');
      response.send(createCreateDomainResponse({
        domainName: domain.name,
        domainId: FAKE_DOMAIN_ID,
        searchEndpoint: 'http://search-' + domain.name + '-' + FAKE_DOMAIN_ID +
                        '/' + exports.version + '/search',
        documentsEndpoint: 'http://doc-' + domain.name + '-' + FAKE_DOMAIN_ID +
                           '/' + exports.version + '/documents/batch',
        created: true,
        searchableDocumentsCount: 0,
        searchInstanceCount: 0,
        searchPartitionCount: 0,
        requiresIndexDocuments: false
      }));
    })
    .error(function(error) {
      return response.send(error.message, 400);
    });
};

handlers.DefineIndexField = function(database, request, response) {
  var domain = new Domain(request);

  var fieldName = request.query['IndexField.IndexFieldName'] || '';
  var field = domain.getIndexField(fieldName);

  var options = {
        table: domain.tableName,
        name: field.columnName,
        flags: Database.COLUMN_SCALAR,
        type: Database.ShortText
      };
  database.commandDeferred('column_create', options)
    .next(function(data) {
      var termsOptions = {
            table: domain.termsTableName,
            name: field.indexColumnName,
            flags: Database.COLUMN_INDEX + '|' + Database.WITH_POSITION,
            type: domain.tableName,
            source: field.columnName
          };
      return database.commandDeferred('column_create', termsOptions);
    })
    .next(function() {
      response.send('created index field "' + field + '" ' +
                    'for the domain "' + domain.name + '"');
    })
    .error(function(error) {
      return response.send(error.message, 400);
    });
};

exports.createHandler = function(database) {
  return function(request, response) {
    var message, body;

    var version = request.query.Version;
    if (!version) {
      message = 'An input parameter "Version" that is mandatory for ' +
                'processing the request is not supplied.';
      body = createCommonErrorResponse('MissingParameter', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    if (version != exports.version) {
      message = 'A bad or out-of-range value "' + version + '" was supplied ' +
                'for the "Version" input parameter.';
      body = createCommonErrorResponse('InvalidParameterValue', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    var action = request.query.Action || '';
    if (!action) {
      message = 'The request is missing an action or operation parameter.';
      body = createCommonErrorResponse('MissingAction', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    if (!(action in handlers)) {
      message = 'The action ' + action + ' is not valid for this web service.';
      body = createCommonErrorResponse('InvalidAction', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    var handler = handlers[action];
    handler(database, request, response);
  };
};
<commit_msg>Return error responses as XML<commit_after>var path = require('path');
var Database = require('../../database').Database;
var Domain = require('../../domain').Domain;
var Deferred = require('jsdeferred').Deferred;

exports.version = path.basename(__dirname);

var XMLNS = 'http://cloudsearch.amazonaws.com/doc/2011-02-01';
var FAKE_DOMAIN_ID = 'example';

function createCommonErrorResponse(errorCode, message) {
  return '<?xml version="1.0"?>\n' +
         '<Response>' +
           '<Errors>' +
             '<Error>' + errorCode +'' +
                     '<Message>' + message + '</Message></Error>' +
             '</Errors>' +
           '<RequestID></RequestID>' +
         '</Response>';
}

var handlers = Object.create(null);

function getBaseDomain(domain) {
  return domain.replace(/^cloudsearch\./, '');
}

function createDomainStatus(options) {
return '<DomainStatus>' +
         '<SearchPartitionCount>' + (options.searchPartitionCount || 0) +
           '</SearchPartitionCount>' +
         '<SearchService>' +
           '<Endpoint>' + (options.searchEndpoint || '') +'</Endpoint>' +
         '</SearchService>' +
         '<NumSearchableDocs>' + (options.searchableDocumentsCount || 0) +
           '</NumSearchableDocs>' +
         '<Created>' + (options.created || 'false') + '</Created>' +
         '<DomainId>' + options.domainName + '/' + options.domainName +
           '</DomainId>' +
         '<SearchInstanceCount>' + (options.searchInstanceCount || 0) +
           '</SearchInstanceCount>' +
         '<DomainName>' + options.domainName + '</DomainName>' +
         '<RequiresIndexDocuments>' +
           (options.requiresIndexDocuments || 'false') +
           '</RequiresIndexDocuments>' +
         '<Deleted>' + (options.deleted || 'false') + '</Deleted>' +
         '<DocService>' +
           '<Endpoint>' + (options.documentsEndpoint || '') +'</Endpoint>' +
         '</DocService>' +
       '</DomainStatus>';
}

function createCreateDomainResponse(options) {
  return '<?xml version="1.0"?>\n' +
         '<CreateDomainResponse xmlns="' + XMLNS + '">' +
           '<CreateDomainResult>' +
             createDomainStatus() +
           '</CreateDomainResult>' +
           '<ResponseMetadata>' +
             '<RequestId>' + (options.requestId || '') + '</RequestId>' +
           '</ResponseMetadata>' +
         '</CreateDomainResponse>';
}

handlers.CreateDomain = function(database, request, response) {
  var domain = new Domain(request);
  var options = {
        name: domain.tableName,
        flags: Database.TABLE_HASH_KEY,
        key_type: Database.ShortText
      };
  database.commandDeferred('table_create', options)
    .next(function(data) {
      var termsOptions = {
            name: domain.termsTableName,
            flags: Database.TABLE_PAT_KEY + '|' + Database.KEY_NORMALIZE,
            key_type: Database.ShortText,
            default_tokenizer: Database.TokenBigram
          };
      return database.commandDeferred('table_create', termsOptions);
    })
    .next(function(data) {
      var host = getBaseDomain(request.headers.host);
      response.contentType('application/xml');
      response.send(createCreateDomainResponse({
        domainName: domain.name,
        domainId: FAKE_DOMAIN_ID,
        searchEndpoint: 'http://search-' + domain.name + '-' + FAKE_DOMAIN_ID +
                        '/' + exports.version + '/search',
        documentsEndpoint: 'http://doc-' + domain.name + '-' + FAKE_DOMAIN_ID +
                           '/' + exports.version + '/documents/batch',
        created: true,
        searchableDocumentsCount: 0,
        searchInstanceCount: 0,
        searchPartitionCount: 0,
        requiresIndexDocuments: false
      }));
    })
    .error(function(error) {
      var body = createCommonErrorResponse('InternalFailure', error.message);
      response.contentType('application/xml');
      return response.send(body, 400);
    });
};

handlers.DefineIndexField = function(database, request, response) {
  var domain = new Domain(request);

  var fieldName = request.query['IndexField.IndexFieldName'] || '';
  var field = domain.getIndexField(fieldName);

  var options = {
        table: domain.tableName,
        name: field.columnName,
        flags: Database.COLUMN_SCALAR,
        type: Database.ShortText
      };
  database.commandDeferred('column_create', options)
    .next(function(data) {
      var termsOptions = {
            table: domain.termsTableName,
            name: field.indexColumnName,
            flags: Database.COLUMN_INDEX + '|' + Database.WITH_POSITION,
            type: domain.tableName,
            source: field.columnName
          };
      return database.commandDeferred('column_create', termsOptions);
    })
    .next(function() {
      response.send('created index field "' + field + '" ' +
                    'for the domain "' + domain.name + '"');
    })
    .error(function(error) {
      var body = createCommonErrorResponse('InternalFailure', error.message);
      response.contentType('application/xml');
      return response.send(body, 400);
    });
};

exports.createHandler = function(database) {
  return function(request, response) {
    var message, body;

    var version = request.query.Version;
    if (!version) {
      message = 'An input parameter "Version" that is mandatory for ' +
                'processing the request is not supplied.';
      body = createCommonErrorResponse('MissingParameter', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    if (version != exports.version) {
      message = 'A bad or out-of-range value "' + version + '" was supplied ' +
                'for the "Version" input parameter.';
      body = createCommonErrorResponse('InvalidParameterValue', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    var action = request.query.Action || '';
    if (!action) {
      message = 'The request is missing an action or operation parameter.';
      body = createCommonErrorResponse('MissingAction', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    if (!(action in handlers)) {
      message = 'The action ' + action + ' is not valid for this web service.';
      body = createCommonErrorResponse('InvalidAction', message);
      response.contentType('application/xml');
      return response.send(body, 400);
    }

    var handler = handlers[action];
    handler(database, request, response);
  };
};
<|endoftext|>


<commit_before>'use strict';

module.exports = {
  visa: {
    APPROVAL: ['00', '08', '11', '16', '17', '18', '20', '22', '24', '26', '27',
               '29', '31', '32', '34', '35', '36', '37', '38', '39', '40', '42',
               '44', '45', '46', '47', '48', '49', '50', '56', '59', '60', '64',
               '66', '67', '69', '70', '71', '79', '85', '87', '95'],
    CALL_AUTH_CENTER: ['01', '02', '03', '06', '09', '12', '25', '28', '30',
                       '52', '53', '68', '73', '82', '84', '90', '93', '96', '97'],
    PICK_UP_CARD: ['04', '07', '41', '43'],
    DECLINED: ['05', '21', '51', '57', '62', '63', '65 /*', '72*/', '74', '75',
               '77', '88', '89', '94'],
    AMOUNT_ERROR: ['13'],
    INVALID_CARD: ['14', '15', '78'],
    EXPIRED_CARD: ['33', '54'],
    INCORRECT_PIN: ['55', '81', '83'],
    SERV_NOT_ALLOWED: ['58'],
    EXCEEDS_AMT_LMT: ['61'],
    CALL_REF: ['86'],
    PLEASE_RETRY5270: ['19', '91', '92'],
    PLEASE_RETRY5305: ['80'],
    PA_APPROVAL_05: ['10'],
    DECLINED_CVV2: ['72']
  }
};
<commit_msg>Fix commented VISA x.72 response in 'DECLINED'.<commit_after>'use strict';

module.exports = {
  visa: {
    APPROVAL: ['00', '08', '11', '16', '17', '18', '20', '22', '24', '26', '27',
               '29', '31', '32', '34', '35', '36', '37', '38', '39', '40', '42',
               '44', '45', '46', '47', '48', '49', '50', '56', '59', '60', '64',
               '66', '67', '69', '70', '71', '79', '85', '87', '95'],
    CALL_AUTH_CENTER: ['01', '02', '03', '06', '09', '12', '25', '28', '30',
                       '52', '53', '68', '73', '82', '84', '90', '93', '96', '97'],
    PICK_UP_CARD: ['04', '07', '41', '43'],
    DECLINED: ['05', '21', '51', '57', '62', '63', '65', '74', '75',
               '77', '88', '89', '94'],
    AMOUNT_ERROR: ['13'],
    INVALID_CARD: ['14', '15', '78'],
    EXPIRED_CARD: ['33', '54'],
    INCORRECT_PIN: ['55', '81', '83'],
    SERV_NOT_ALLOWED: ['58'],
    EXCEEDS_AMT_LMT: ['61'],
    CALL_REF: ['86'],
    PLEASE_RETRY5270: ['19', '91', '92'],
    PLEASE_RETRY5305: ['80'],
    PA_APPROVAL_05: ['10'],
    DECLINED_CVV2: ['72']
  }
};
<|endoftext|>


<commit_before>/* Google custom search code */
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
  var customSearchControl = new google.search.CustomSearchControl('018021367961685880654:mdt584m83r4');
  customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  var options = new google.search.DrawOptions();
  options.setSearchFormRoot('PWGSearchForm');
  options.setAutoComplete(true);
  customSearchControl.draw('PWGSearchResults', options);
}, true);

/* Collapsible panels from http://www.richnetapps.com/javascript-animated-collapsible-panels-without-frameworks/ */
var PANEL_NORMAL_CLASS    = "panel";
var PANEL_COLLAPSED_CLASS = "panelcollapsed";
var PANEL_HEADING_TAG     = "h2";
var PANEL_CONTENT_CLASS   = "panelcontent";
var PANEL_COOKIE_NAME     = "";
var PANEL_ANIMATION_DELAY = 20; /*ms*/
var PANEL_ANIMATION_STEPS = 10;

function setUpPanels()
{
  loadSettings();

  // get all headings
  var headingTags = document.getElementsByTagName(PANEL_HEADING_TAG);

  // go through all tags
  for (var i=0; i<headingTags.length; i++)
  {
    var el = headingTags[i];

    // make sure it's the heading inside a panel
    if (el.parentNode.className != PANEL_NORMAL_CLASS && el.parentNode.className != PANEL_COLLAPSED_CLASS)
      continue;

    // get the text value of the tag
    var name = el.firstChild.nodeValue;

    // look for the name in loaded settings, apply the normal/collapsed class
    if (panelsStatus[name] == "false")
      el.parentNode.className = PANEL_COLLAPSED_CLASS;
    else if (panelsStatus[name] == "true")
      el.parentNode.className = PANEL_NORMAL_CLASS;
    else
    {
      // if no saved setting, see the initial setting
      panelsStatus[name] = (el.parentNode.className == PANEL_NORMAL_CLASS) ? "true" : "false";
    }

    // add the click behavor to headings
    el.onclick = function()
    {
      var target    = this.parentNode;
      var name      = this.firstChild.nodeValue;
      var collapsed = (target.className == PANEL_COLLAPSED_CLASS);
      saveSettings(name, collapsed?"true":"false");
      animateTogglePanel(target, collapsed);
    };
  }
}

/**
 * Start the expand/collapse animation of the panel
 * @param panel reference to the panel div
 */
function animateTogglePanel(panel, expanding)
{
  // find the .panelcontent div
  var elements = panel.getElementsByTagName("div");
  var panelContent = null;
  for (var i=0; i<elements.length; i++)
  {
    if (elements[i].className == PANEL_CONTENT_CLASS)
    {
	    panelContent = elements[i];
	    break;
    }
  }

  // make sure the content is visible before getting its height
  panelContent.style.display = "block";

  // get the height of the content
  var contentHeight = panelContent.offsetHeight;

  // if panel is collapsed and expanding, we must start with 0 height
  if (expanding)
    panelContent.style.height = "0px";

  var stepHeight = contentHeight / PANEL_ANIMATION_STEPS;
  var direction = (!expanding ? -1 : 1);

  setTimeout(function(){animateStep(panelContent,1,stepHeight,direction)}, PANEL_ANIMATION_DELAY);
}

/**
 * Change the height of the target
 * @param panelContent	reference to the panel content to change height
 * @param iteration		current iteration; animation will be stopped when iteration reaches PANEL_ANIMATION_STEPS
 * @param stepHeight	height increment to be added/substracted in one step
 * @param direction		1 for expanding, -1 for collapsing
 */
function animateStep(panelContent, iteration, stepHeight, direction)
{
  if (iteration<PANEL_ANIMATION_STEPS)
  {
    panelContent.style.height = Math.round(((direction>0) ? iteration : 10 - iteration) * stepHeight) +"px";
    iteration++;
    setTimeout(function(){animateStep(panelContent,iteration,stepHeight,direction)}, PANEL_ANIMATION_DELAY);
  }
  else
  {
    // set class for the panel
    panelContent.parentNode.className = (direction<0) ? PANEL_COLLAPSED_CLASS : PANEL_NORMAL_CLASS;
    // clear inline styles
    panelContent.style.display = panelContent.style.height = "";
  }
}

// -----------------------------------------------------------------------------------------------
// Load-Save
// -----------------------------------------------------------------------------------------------
/**
 * Reads the "panels" cookie if exists, expects data formatted as key:value|key:value... puts in panelsStatus object
 */
function loadSettings()
{
  // prepare the object that will keep the panel statuses
  panelsStatus = {};

  if (PANEL_COOKIE_NAME == "")
    return;

  // find the cookie name
  var start = document.cookie.indexOf(PANEL_COOKIE_NAME + "=");
  if (start == -1) return;

  // starting point of the value
  start += PANEL_COOKIE_NAME.length+1;

  // find end point of the value
  var end = document.cookie.indexOf(";", start);
  if (end == -1) end = document.cookie.length;

  // get the value, split into key:value pairs
  var cookieValue = unescape(document.cookie.substring(start, end));
  var panelsData = cookieValue.split("|");

  // split each key:value pair and put in object
  for (var i=0; i< panelsData.length; i++)
  {
    var pair = panelsData[i].split(":");
    panelsStatus[pair[0]] = pair[1];
  }
}

function expandAll()
{
  for (var key in panelsStatus)
    saveSettings(key, "true");

  setUpPanels();
}

function collapseAll()
{
  for (var key in panelsStatus)
    saveSettings(key, "false");

  setUpPanels();
}

/**
 * Takes data from the panelsStatus object, formats as key:value|key:value... and puts in cookie valid for 365 days
 * @param key	key name to save
 * @paeam value	key value
 */
function saveSettings(key, value)
{
  if (PANEL_COOKIE_NAME == "")
    return

  // put the new value in the object
  panelsStatus[key] = value;

  // create an array that will keep the key:value pairs
  var panelsData = [];
  for (var key in panelsStatus)
    panelsData.push(key+":"+panelsStatus[key]);

  // set the cookie expiration date 1 year from now
  var today = new Date();
  var expirationDate = new Date(today.getTime() + 365 * 1000 * 60 * 60 * 24);
  // write the cookie
  document.cookie = PANEL_COOKIE_NAME + "=" + escape(panelsData.join("|")) + ";expires=" + expirationDate.toGMTString();
}

/* Sidebar loading code - we do it here to avoid changing it on every page */
function load_sidebar(path) {
  setUpPanels();
  contents =
'
Printer Working Group:
\

\

Home
\

About Us
\

Calendar
\

Officers
\

Members/Joining
\

Meetings
\

Participating
\

\

Publications:
\

\

Informational
\

Namespaces
\

Standards
\

\

Technologies:
\

\

IPP Everywhere
\

\

Workgroups:
\

\

Cloud Imaging ModelCloud
\

Imaging Device SecurityIDS
\

Internet Printing ProtocolIPP
\

Semantic ModelSM
\

';

  if (document.anchors.length > 0)
  {
    contents = contents + '\n
This Page:
\n
\n';
    for (i = 0; i < document.anchors.length; i ++)
      contents = contents + '
' + document.anchors[i].innerHTML + '
\n';
    contents = contents + '
';
  }

  document.getElementById('PWGSideBody').innerHTML = contents;
}
<commit_msg>SM workgroup is now /sm instead of /mfd.<commit_after>/* Google custom search code */
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
  var customSearchControl = new google.search.CustomSearchControl('018021367961685880654:mdt584m83r4');
  customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  var options = new google.search.DrawOptions();
  options.setSearchFormRoot('PWGSearchForm');
  options.setAutoComplete(true);
  customSearchControl.draw('PWGSearchResults', options);
}, true);

/* Collapsible panels from http://www.richnetapps.com/javascript-animated-collapsible-panels-without-frameworks/ */
var PANEL_NORMAL_CLASS    = "panel";
var PANEL_COLLAPSED_CLASS = "panelcollapsed";
var PANEL_HEADING_TAG     = "h2";
var PANEL_CONTENT_CLASS   = "panelcontent";
var PANEL_COOKIE_NAME     = "";
var PANEL_ANIMATION_DELAY = 20; /*ms*/
var PANEL_ANIMATION_STEPS = 10;

function setUpPanels()
{
  loadSettings();

  // get all headings
  var headingTags = document.getElementsByTagName(PANEL_HEADING_TAG);

  // go through all tags
  for (var i=0; i<headingTags.length; i++)
  {
    var el = headingTags[i];

    // make sure it's the heading inside a panel
    if (el.parentNode.className != PANEL_NORMAL_CLASS && el.parentNode.className != PANEL_COLLAPSED_CLASS)
      continue;

    // get the text value of the tag
    var name = el.firstChild.nodeValue;

    // look for the name in loaded settings, apply the normal/collapsed class
    if (panelsStatus[name] == "false")
      el.parentNode.className = PANEL_COLLAPSED_CLASS;
    else if (panelsStatus[name] == "true")
      el.parentNode.className = PANEL_NORMAL_CLASS;
    else
    {
      // if no saved setting, see the initial setting
      panelsStatus[name] = (el.parentNode.className == PANEL_NORMAL_CLASS) ? "true" : "false";
    }

    // add the click behavor to headings
    el.onclick = function()
    {
      var target    = this.parentNode;
      var name      = this.firstChild.nodeValue;
      var collapsed = (target.className == PANEL_COLLAPSED_CLASS);
      saveSettings(name, collapsed?"true":"false");
      animateTogglePanel(target, collapsed);
    };
  }
}

/**
 * Start the expand/collapse animation of the panel
 * @param panel reference to the panel div
 */
function animateTogglePanel(panel, expanding)
{
  // find the .panelcontent div
  var elements = panel.getElementsByTagName("div");
  var panelContent = null;
  for (var i=0; i<elements.length; i++)
  {
    if (elements[i].className == PANEL_CONTENT_CLASS)
    {
	    panelContent = elements[i];
	    break;
    }
  }

  // make sure the content is visible before getting its height
  panelContent.style.display = "block";

  // get the height of the content
  var contentHeight = panelContent.offsetHeight;

  // if panel is collapsed and expanding, we must start with 0 height
  if (expanding)
    panelContent.style.height = "0px";

  var stepHeight = contentHeight / PANEL_ANIMATION_STEPS;
  var direction = (!expanding ? -1 : 1);

  setTimeout(function(){animateStep(panelContent,1,stepHeight,direction)}, PANEL_ANIMATION_DELAY);
}

/**
 * Change the height of the target
 * @param panelContent	reference to the panel content to change height
 * @param iteration		current iteration; animation will be stopped when iteration reaches PANEL_ANIMATION_STEPS
 * @param stepHeight	height increment to be added/substracted in one step
 * @param direction		1 for expanding, -1 for collapsing
 */
function animateStep(panelContent, iteration, stepHeight, direction)
{
  if (iteration<PANEL_ANIMATION_STEPS)
  {
    panelContent.style.height = Math.round(((direction>0) ? iteration : 10 - iteration) * stepHeight) +"px";
    iteration++;
    setTimeout(function(){animateStep(panelContent,iteration,stepHeight,direction)}, PANEL_ANIMATION_DELAY);
  }
  else
  {
    // set class for the panel
    panelContent.parentNode.className = (direction<0) ? PANEL_COLLAPSED_CLASS : PANEL_NORMAL_CLASS;
    // clear inline styles
    panelContent.style.display = panelContent.style.height = "";
  }
}

// -----------------------------------------------------------------------------------------------
// Load-Save
// -----------------------------------------------------------------------------------------------
/**
 * Reads the "panels" cookie if exists, expects data formatted as key:value|key:value... puts in panelsStatus object
 */
function loadSettings()
{
  // prepare the object that will keep the panel statuses
  panelsStatus = {};

  if (PANEL_COOKIE_NAME == "")
    return;

  // find the cookie name
  var start = document.cookie.indexOf(PANEL_COOKIE_NAME + "=");
  if (start == -1) return;

  // starting point of the value
  start += PANEL_COOKIE_NAME.length+1;

  // find end point of the value
  var end = document.cookie.indexOf(";", start);
  if (end == -1) end = document.cookie.length;

  // get the value, split into key:value pairs
  var cookieValue = unescape(document.cookie.substring(start, end));
  var panelsData = cookieValue.split("|");

  // split each key:value pair and put in object
  for (var i=0; i< panelsData.length; i++)
  {
    var pair = panelsData[i].split(":");
    panelsStatus[pair[0]] = pair[1];
  }
}

function expandAll()
{
  for (var key in panelsStatus)
    saveSettings(key, "true");

  setUpPanels();
}

function collapseAll()
{
  for (var key in panelsStatus)
    saveSettings(key, "false");

  setUpPanels();
}

/**
 * Takes data from the panelsStatus object, formats as key:value|key:value... and puts in cookie valid for 365 days
 * @param key	key name to save
 * @paeam value	key value
 */
function saveSettings(key, value)
{
  if (PANEL_COOKIE_NAME == "")
    return

  // put the new value in the object
  panelsStatus[key] = value;

  // create an array that will keep the key:value pairs
  var panelsData = [];
  for (var key in panelsStatus)
    panelsData.push(key+":"+panelsStatus[key]);

  // set the cookie expiration date 1 year from now
  var today = new Date();
  var expirationDate = new Date(today.getTime() + 365 * 1000 * 60 * 60 * 24);
  // write the cookie
  document.cookie = PANEL_COOKIE_NAME + "=" + escape(panelsData.join("|")) + ";expires=" + expirationDate.toGMTString();
}

/* Sidebar loading code - we do it here to avoid changing it on every page */
function load_sidebar(path) {
  setUpPanels();
  contents =
'
Printer Working Group:
\

\

Home
\

About Us
\

Calendar
\

Officers
\

Members/Joining
\

Meetings
\

Participating
\

\

Publications:
\

\

Informational
\

Namespaces
\

Standards
\

\

Technologies:
\

\

IPP Everywhere
\

\

Workgroups:
\

\

Cloud Imaging ModelCloud
\

Imaging Device SecurityIDS
\

Internet Printing ProtocolIPP
\

Semantic ModelSM
\

';

  if (document.anchors.length > 0)
  {
    contents = contents + '\n
This Page:
\n
\n';
    for (i = 0; i < document.anchors.length; i ++)
      contents = contents + '
' + document.anchors[i].innerHTML + '
\n';
    contents = contents + '
';
  }

  document.getElementById('PWGSideBody').innerHTML = contents;
}
<|endoftext|>