diff --git a/build/ace-uncompressed.js b/build/ace-uncompressed.js index e1e6c3d9..b5130031 100644 --- a/build/ace-uncompressed.js +++ b/build/ace-uncompressed.js @@ -5528,2461 +5528,6 @@ exports.getOS = function() { }; }); -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Skywriter. - * - * The Initial Developer of the Original Code is - * Mozilla. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Joe Walker (jwalker@mozilla.com) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -define('cockpit/cli', function(require, exports, module) { - - -var console = require('pilot/console'); -var lang = require('pilot/lang'); -var oop = require('pilot/oop'); -var EventEmitter = require('pilot/event_emitter').EventEmitter; - -//var keyboard = require('keyboard/keyboard'); -var types = require('pilot/types'); -var Status = require('pilot/types').Status; -var Conversion = require('pilot/types').Conversion; -var canon = require('pilot/canon'); - -/** - * Normally type upgrade is done when the owning command is registered, but - * out commandParam isn't part of a command, so it misses out. - */ -exports.startup = function(data, reason) { - canon.upgradeType('command', commandParam); -}; - -/** - * The information required to tell the user there is a problem with their - * input. - * TODO: There a several places where {start,end} crop up. Perhaps we should - * have a Cursor object. - */ -function Hint(status, message, start, end, predictions) { - this.status = status; - this.message = message; - - if (typeof start === 'number') { - this.start = start; - this.end = end; - this.predictions = predictions; - } - else { - var arg = start; - this.start = arg.start; - this.end = arg.end; - this.predictions = arg.predictions; - } -} -Hint.prototype = { -}; -/** - * Loop over the array of hints finding the one we should display. - * @param hints array of hints - */ -Hint.sort = function(hints, cursor) { - // Calculate 'distance from cursor' - if (cursor !== undefined) { - hints.forEach(function(hint) { - if (hint.start === Argument.AT_CURSOR) { - hint.distance = 0; - } - else if (cursor < hint.start) { - hint.distance = hint.start - cursor; - } - else if (cursor > hint.end) { - hint.distance = cursor - hint.end; - } - else { - hint.distance = 0; - } - }, this); - } - // Sort - hints.sort(function(hint1, hint2) { - // Compare first based on distance from cursor - if (cursor !== undefined) { - var diff = hint1.distance - hint2.distance; - if (diff != 0) { - return diff; - } - } - // otherwise go with hint severity - return hint2.status - hint1.status; - }); - // tidy-up - if (cursor !== undefined) { - hints.forEach(function(hint) { - delete hint.distance; - }, this); - } - return hints; -}; -exports.Hint = Hint; - -/** - * A Hint that arose as a result of a Conversion - */ -function ConversionHint(conversion, arg) { - this.status = conversion.status; - this.message = conversion.message; - if (arg) { - this.start = arg.start; - this.end = arg.end; - } - else { - this.start = 0; - this.end = 0; - } - this.predictions = conversion.predictions; -}; -oop.inherits(ConversionHint, Hint); - - -/** - * We record where in the input string an argument comes so we can report errors - * against those string positions. - * We publish a 'change' event when-ever the text changes - * @param emitter Arguments use something else to pass on change events. - * Currently this will be the creating Requisition. This prevents dependency - * loops and prevents us from needing to merge listener lists. - * @param text The string (trimmed) that contains the argument - * @param start The position of the text in the original input string - * @param end See start - * @param prefix Knowledge of quotation marks and whitespace used prior to the - * text in the input string allows us to re-generate the original input from - * the arguments. - * @param suffix Any quotation marks and whitespace used after the text. - * Whitespace is normally placed in the prefix to the succeeding argument, but - * can be used here when this is the last argument. - * @constructor - */ -function Argument(emitter, text, start, end, prefix, suffix) { - this.emitter = emitter; - this.setText(text); - this.start = start; - this.end = end; - this.prefix = prefix; - this.suffix = suffix; -} -Argument.prototype = { - /** - * Return the result of merging these arguments. - * TODO: What happens when we're merging arguments for the single string - * case and some of the arguments are in quotation marks? - */ - merge: function(following) { - if (following.emitter != this.emitter) { - throw new Error('Can\'t merge Arguments from different EventEmitters'); - } - return new Argument( - this.emitter, - this.text + this.suffix + following.prefix + following.text, - this.start, following.end, - this.prefix, - following.suffix); - }, - - /** - * See notes on events in Assignment. We might need to hook changes here - * into a CliRequisition so they appear of the command line. - */ - setText: function(text) { - if (text == null) { - throw new Error('Illegal text for Argument: ' + text); - } - var ev = { argument: this, oldText: this.text, text: text }; - this.text = text; - this.emitter._dispatchEvent('argumentChange', ev); - }, - - /** - * Helper when we're putting arguments back together - */ - toString: function() { - // TODO: There is a bug here - we should re-escape escaped characters - // But can we do that reliably? - return this.prefix + this.text + this.suffix; - } -}; - -/** - * Merge an array of arguments into a single argument. - * All Arguments in the array are expected to have the same emitter - */ -Argument.merge = function(argArray, start, end) { - start = (start === undefined) ? 0 : start; - end = (end === undefined) ? argArray.length : end; - - var joined; - for (var i = start; i < end; i++) { - var arg = argArray[i]; - if (!joined) { - joined = arg; - } - else { - joined = joined.merge(arg); - } - } - return joined; -}; - -/** - * We sometimes need a way to say 'this error occurs where ever the cursor is' - */ -Argument.AT_CURSOR = -1; - - -/** - * A link between a parameter and the data for that parameter. - * The data for the parameter is available as in the preferred type and as - * an Argument for the CLI. - *
We also record validity information where applicable. - *
For values, null and undefined have distinct definitions. null means
- * that a value has been provided, undefined means that it has not.
- * Thus, null is a valid default value, and common because it identifies an
- * parameter that is optional. undefined means there is no value from
- * the command line.
- * @constructor
- */
-function Assignment(param, requisition) {
- this.param = param;
- this.requisition = requisition;
- this.setValue(param.defaultValue);
-};
-Assignment.prototype = {
- /**
- * The parameter that we are assigning to
- * @readonly
- */
- param: undefined,
-
- /**
- * Report on the status of the last parse() conversion.
- * @see types.Conversion
- */
- conversion: undefined,
-
- /**
- * The current value in a type as specified by param.type
- */
- value: undefined,
-
- /**
- * The string version of the current value
- */
- arg: undefined,
-
- /**
- * The current value (i.e. not the string representation)
- * Use setValue() to mutate
- */
- value: undefined,
- setValue: function(value) {
- if (this.value === value) {
- return;
- }
-
- if (value === undefined) {
- this.value = this.param.defaultValue;
- this.conversion = this.param.getDefault ?
- this.param.getDefault() :
- this.param.type.getDefault();
- this.arg = undefined;
- } else {
- this.value = value;
- this.conversion = undefined;
- var text = (value == null) ? '' : this.param.type.stringify(value);
- if (this.arg) {
- this.arg.setText(text);
- }
- }
-
- this.requisition._assignmentChanged(this);
- },
-
- /**
- * The textual representation of the current value
- * Use setValue() to mutate
- */
- arg: undefined,
- setArgument: function(arg) {
- if (this.arg === arg) {
- return;
- }
- this.arg = arg;
- this.conversion = this.param.type.parse(arg.text);
- this.conversion.arg = arg; // TODO: make this automatic?
- this.value = this.conversion.value;
- this.requisition._assignmentChanged(this);
- },
-
- /**
- * Create a list of the hints associated with this parameter assignment.
- * Generally there will be only one hint generated because we're currently
- * only displaying one hint at a time, ordering by distance from cursor
- * and severity. Since distance from cursor will be the same for all hints
- * from this assignment all but the most severe will ever be used. It might
- * make sense with more experience to alter this to function to be getHint()
- */
- getHint: function() {
- // Allow the parameter to provide documentation
- if (this.param.getCustomHint && this.value && this.arg) {
- var hint = this.param.getCustomHint(this.value, this.arg);
- if (hint) {
- return hint;
- }
- }
-
- // If there is no argument, use the cursor position
- var message = '' + this.param.name + ': ';
- if (this.param.description) {
- // TODO: This should be a short description - do we need to trim?
- message += this.param.description.trim();
-
- // Ensure the help text ends with '. '
- if (message.charAt(message.length - 1) !== '.') {
- message += '.';
- }
- if (message.charAt(message.length - 1) !== ' ') {
- message += ' ';
- }
- }
- var status = Status.VALID;
- var start = this.arg ? this.arg.start : Argument.AT_CURSOR;
- var end = this.arg ? this.arg.end : Argument.AT_CURSOR;
- var predictions;
-
- // Non-valid conversions will have useful information to pass on
- if (this.conversion) {
- status = this.conversion.status;
- if (this.conversion.message) {
- message += this.conversion.message;
- }
- predictions = this.conversion.predictions;
- }
-
- // Hint if the param is required, but not provided
- var argProvided = this.arg && this.arg.text !== '';
- var dataProvided = this.value !== undefined || argProvided;
- if (this.param.defaultValue === undefined && !dataProvided) {
- status = Status.INVALID;
- message += 'Required<\strong>';
- }
-
- return new Hint(status, message, start, end, predictions);
- },
-
- /**
- * Basically setValue(conversion.predictions[0]) done in a safe
- * way.
- */
- complete: function() {
- if (this.conversion && this.conversion.predictions &&
- this.conversion.predictions.length > 0) {
- this.setValue(this.conversion.predictions[0]);
- }
- },
-
- /**
- * If the cursor is at 'position', do we have sufficient data to start
- * displaying the next hint. This is both complex and important.
- * For example, if the user has just typed: Note that the input for 2 and 4 is identical, only the configuration
- * has changed, so hint display is environmental.
- *
- * This function works out if the cursor is before the end of this
- * assignment (assuming that we've asked the same thing of the previous
- * assignment) and then attempts to work out if we should use the hint from
- * the next assignment even though technically the cursor is still inside
- * this one due to the rules above.
- */
- isPositionCaptured: function(position) {
- if (!this.arg) {
- return false;
- }
-
- // Note we don't check if position >= this.arg.start because that's
- // implied by the fact that we're asking the assignments in turn, and
- // we want to avoid thing falling between the cracks, but we do need
- // to check that the argument does have a position
- if (this.arg.start === -1) {
- return false;
- }
-
- // We're clearly done if the position is past the end of the text
- if (position > this.arg.end) {
- return false;
- }
-
- // If we're AT the end, the position is captured if either the status
- // is not valid or if there are other valid options including current
- if (position === this.arg.end) {
- return this.conversion.status !== Status.VALID ||
- this.conversion.predictions.length !== 0;
- }
-
- // Otherwise we're clearly inside
- return true;
- },
-
- /**
- * Replace the current value with the lower value if such a concept
- * exists.
- */
- decrement: function() {
- var replacement = this.param.type.decrement(this.value);
- if (replacement != null) {
- this.setValue(replacement);
- }
- },
-
- /**
- * Replace the current value with the higher value if such a concept
- * exists.
- */
- increment: function() {
- var replacement = this.param.type.increment(this.value);
- if (replacement != null) {
- this.setValue(replacement);
- }
- },
-
- /**
- * Helper when we're rebuilding command lines.
- */
- toString: function() {
- return this.arg ? this.arg.toString() : '';
- }
-};
-exports.Assignment = Assignment;
-
-
-/**
- * This is a special parameter to reflect the command itself.
- */
-var commandParam = {
- name: '__command',
- type: 'command',
- description: 'The command to execute',
-
- /**
- * Provide some documentation for a command.
- */
- getCustomHint: function(command, arg) {
- var docs = [];
- docs.push(' > ');
- docs.push(command.name);
- if (command.params && command.params.length > 0) {
- command.params.forEach(function(param) {
- if (param.defaultValue === undefined) {
- docs.push(' [' + param.name + ']');
- }
- else {
- docs.push(' [' + param.name + ']');
- }
- }, this);
- }
- docs.push(' The 'output' of the update is held in 2 objects: input.hints which is an
- * array of hints to display to the user. In the future this will become a
- * single value.
- * The other output value is input.requisition which gives access to an
- * args object for use in executing the final command.
- *
- * The majority of the functions in this class are called in sequence by the
- * constructor. Their task is to add to hints fill out the requisition.
- * The general sequence is: This takes #_command.params and #_unparsedArgs and creates a map of
- * param names to 'assignment' objects, which have the following properties:
- * "+e.description+" "+e.description+"
- *
- *
');
-
- docs.push(command.description ? command.description : '(No description)');
- docs.push('
');
-
- if (command.params && command.params.length > 0) {
- docs.push('');
- command.params.forEach(function(param) {
- docs.push('
');
- }
-
- return new Hint(Status.VALID, docs.join(''), arg);
- }
-};
-
-/**
- * A Requisition collects the information needed to execute a command.
- * There is no point in a requisition for parameter-less commands because there
- * is no information to collect. A Requisition is a collection of assignments
- * of values to parameters, each handled by an instance of Assignment.
- * CliRequisition adds functions for parsing input from a command line to this
- * class.
- * Events
- * We publish the following events:
- *
- *
- *
- * @param typed {string} The instruction as typed by the user so far
- * @param options {object} A list of optional named parameters. Can be any of:
- * flags: Flags for us to check against the predicates specified with the
- * commands. Defaulted to keyboard.buildFlags({ });
- * if not specified.
- * @constructor
- */
-function CliRequisition(env, options) {
- Requisition.call(this, env);
-
- if (options && options.flags) {
- /**
- * TODO: We were using a default of keyboard.buildFlags({ });
- * This allowed us to have commands that only existed in certain contexts
- * - i.e. Javascript specific commands.
- */
- this.flags = options.flags;
- }
-}
-oop.inherits(CliRequisition, Requisition);
-(function() {
- /**
- * Called by the UI when ever the user interacts with a command line input
- * @param input A structure that details the state of the input field.
- * It should look something like: { typed:a, cursor: { start:b, end:c } }
- * Where a is the contents of the input field, and b and c are the start
- * and end of the cursor/selection respectively.
- */
- CliRequisition.prototype.update = function(input) {
- this.input = input;
- this._hints = [];
-
- var args = this._tokenize(input.typed);
- this._split(args);
-
- if (this.commandAssignment.value) {
- this._assign(args);
- }
-
- this._updateHints();
- };
-
- /**
- * Return an array of Status scores so we can create a marked up
- * version of the command line input.
- */
- CliRequisition.prototype.getInputStatusMarkup = function() {
- // 'scores' is an array which tells us what chars are errors
- // Initialize with everything VALID
- var scores = this.toString().split('').map(function(ch) {
- return Status.VALID;
- });
- // For all chars in all hints, check and upgrade the score
- this._hints.forEach(function(hint) {
- for (var i = hint.start; i <= hint.end; i++) {
- if (hint.status > scores[i]) {
- scores[i] = hint.status;
- }
- }
- }, this);
- return scores;
- };
-
- /**
- * Reconstitute the input from the args
- */
- CliRequisition.prototype.toString = function() {
- return this.getAssignments(true).map(function(assignment) {
- return assignment.toString();
- }, this).join('');
- };
-
- var superUpdateHints = CliRequisition.prototype._updateHints;
- /**
- * Marks up hints in a number of ways:
- * - Makes INCOMPLETE hints that are not near the cursor INVALID since
- * they can't be completed by typing
- * - Finds the most severe hint, and annotates the array with it
- * - Finds the hint to display, and also annotates the array with it
- * TODO: I'm wondering if array annotation is evil and we should replace
- * this with an object. Need to find out more.
- */
- CliRequisition.prototype._updateHints = function() {
- superUpdateHints.call(this);
-
- // Not knowing about cursor positioning, the requisition and assignments
- // can't know this, but anything they mark as INCOMPLETE is actually
- // INVALID unless the cursor is actually inside that argument.
- var c = this.input.cursor;
- this._hints.forEach(function(hint) {
- var startInHint = c.start >= hint.start && c.start <= hint.end;
- var endInHint = c.end >= hint.start && c.end <= hint.end;
- var inHint = startInHint || endInHint;
- if (!inHint && hint.status === Status.INCOMPLETE) {
- hint.status = Status.INVALID;
- }
- }, this);
-
- Hint.sort(this._hints);
- };
-
- /**
- * Accessor for the hints array.
- * While we could just use the hints property, using getHints() is
- * preferred for symmetry with Requisition where it needs a function due to
- * lack of an atomic update system.
- */
- CliRequisition.prototype.getHints = function() {
- return this._hints;
- };
-
- /**
- * Look through the arguments attached to our assignments for the assignment
- * at the given position.
- */
- CliRequisition.prototype.getAssignmentAt = function(position) {
- var assignments = this.getAssignments(true);
- for (var i = 0; i < assignments.length; i++) {
- var assignment = assignments[i];
- if (!assignment.arg) {
- // There is no argument in this assignment, we've fallen off
- // the end of the obvious answers - it must be this one.
- return assignment;
- }
- if (assignment.isPositionCaptured(position)) {
- return assignment;
- }
- }
-
- return assignment;
- };
-
- /**
- * Split up the input taking into account ' and "
- */
- CliRequisition.prototype._tokenize = function(typed) {
- // For blank input, place a dummy empty argument into the list
- if (typed == null || typed.length === 0) {
- return [ new Argument(this, '', 0, 0, '', '') ];
- }
-
- var OUTSIDE = 1; // The last character was whitespace
- var IN_SIMPLE = 2; // The last character was part of a parameter
- var IN_SINGLE_Q = 3; // We're inside a single quote: '
- var IN_DOUBLE_Q = 4; // We're inside double quotes: "
-
- var mode = OUTSIDE;
-
- // First we un-escape. This list was taken from:
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Unicode
- // We are generally converting to their real values except for \', \"
- // and '\ ' which we are converting to unicode private characters so we
- // can distinguish them from ', " and ' ', which have special meaning.
- // They need swapping back post-split - see unescape2()
- typed = typed
- .replace(/\\\\/g, '\\')
- .replace(/\\b/g, '\b')
- .replace(/\\f/g, '\f')
- .replace(/\\n/g, '\n')
- .replace(/\\r/g, '\r')
- .replace(/\\t/g, '\t')
- .replace(/\\v/g, '\v')
- .replace(/\\n/g, '\n')
- .replace(/\\r/g, '\r')
- .replace(/\\ /g, '\uF000')
- .replace(/\\'/g, '\uF001')
- .replace(/\\"/g, '\uF002');
-
- function unescape2(str) {
- return str
- .replace(/\uF000/g, ' ')
- .replace(/\uF001/g, '\'')
- .replace(/\uF002/g, '"');
- }
-
- var i = 0;
- var start = 0; // Where did this section start?
- var prefix = '';
- var args = [];
-
- while (true) {
- if (i >= typed.length) {
- // There is nothing else to read - tidy up
- if (mode !== OUTSIDE) {
- var str = unescape2(typed.substring(start, i));
- args.push(new Argument(this, str, start, i, prefix, ''));
- }
- else {
- if (i !== start) {
- // There's a bunch of whitespace at the end of the
- // command add it to the last argument's suffix,
- // creating an empty argument if needed.
- var extra = typed.substring(start, i);
- var lastArg = args[args.length - 1];
- if (!lastArg) {
- lastArg = new Argument(this, '', i, i, extra, '');
- args.push(lastArg);
- }
- else {
- lastArg.suffix += extra;
- }
- }
- }
- break;
- }
-
- var c = typed[i];
- switch (mode) {
- case OUTSIDE:
- if (c === '\'') {
- prefix = typed.substring(start, i + 1);
- mode = IN_SINGLE_Q;
- start = i + 1;
- }
- else if (c === '"') {
- prefix = typed.substring(start, i + 1);
- mode = IN_DOUBLE_Q;
- start = i + 1;
- }
- else if (/ /.test(c)) {
- // Still whitespace, do nothing
- }
- else {
- prefix = typed.substring(start, i);
- mode = IN_SIMPLE;
- start = i;
- }
- break;
-
- case IN_SIMPLE:
- // There is an edge case of xx'xx which we are assuming to
- // be a single parameter (and same with ")
- if (c === ' ') {
- var str = unescape2(typed.substring(start, i));
- args.push(new Argument(this, str,
- start, i, prefix, ''));
- mode = OUTSIDE;
- start = i;
- prefix = '';
- }
- break;
-
- case IN_SINGLE_Q:
- if (c === '\'') {
- var str = unescape2(typed.substring(start, i));
- args.push(new Argument(this, str,
- start - 1, i + 1, prefix, c));
- mode = OUTSIDE;
- start = i + 1;
- prefix = '';
- }
- break;
-
- case IN_DOUBLE_Q:
- if (c === '"') {
- var str = unescape2(typed.substring(start, i));
- args.push(new Argument(this, str,
- start - 1, i + 1, prefix, c));
- mode = OUTSIDE;
- start = i + 1;
- prefix = '';
- }
- break;
- }
-
- i++;
- }
-
- return args;
- };
-
- /**
- * Looks in the canon for a command extension that matches what has been
- * typed at the command line.
- */
- CliRequisition.prototype._split = function(args) {
- var argsUsed = 1;
- var arg;
-
- while (argsUsed <= args.length) {
- var arg = Argument.merge(args, 0, argsUsed);
- this.commandAssignment.setArgument(arg);
-
- if (!this.commandAssignment.value) {
- // Not found. break with value == null
- break;
- }
-
- /*
- // Previously we needed a way to hide commands depending context.
- // We have not resurrected that feature yet.
- if (!keyboard.flagsMatch(command.predicates, this.flags)) {
- // If the predicates say 'no match' then go LA LA LA
- command = null;
- break;
- }
- */
-
- if (this.commandAssignment.value.exec) {
- // Valid command, break with command valid
- for (var i = 0; i < argsUsed; i++) {
- args.shift();
- }
- break;
- }
-
- argsUsed++;
- }
- };
-
- /**
- * Work out which arguments are applicable to which parameters.
- *
- *
- */
- CliRequisition.prototype._assign = function(args) {
- if (args.length === 0) {
- this.setDefaultValues();
- return;
- }
-
- // Create an error if the command does not take parameters, but we have
- // been given them ...
- if (this.assignmentCount === 0) {
- // TODO: previously we were doing some extra work to avoid this if
- // we determined that we had args that were all whitespace, but
- // probably given our tighter tokenize() this won't be an issue?
- this._hints.push(new Hint(Status.INVALID,
- this.commandAssignment.value.name +
- ' does not take any parameters',
- Argument.merge(args)));
- return;
- }
-
- // Special case: if there is only 1 parameter, and that's of type
- // text we put all the params into the first param
- if (this.assignmentCount === 1) {
- var assignment = this.getAssignment(0);
- if (assignment.param.type.name === 'text') {
- assignment.setArgument(Argument.merge(args));
- return;
- }
- }
-
- var assignments = this.cloneAssignments();
- var names = this.getParameterNames();
-
- // Extract all the named parameters
- var used = [];
- assignments.forEach(function(assignment) {
- var namedArgText = '--' + assignment.name;
-
- var i = 0;
- while (true) {
- var arg = args[i];
- if (namedArgText !== arg.text) {
- i++;
- if (i >= args.length) {
- break;
- }
- continue;
- }
-
- // boolean parameters don't have values, default to false
- if (assignment.param.type.name === 'boolean') {
- assignment.setValue(true);
- }
- else {
- if (i + 1 < args.length) {
- // Missing value portion of this named param
- this._hints.push(new Hint(Status.INCOMPLETE,
- 'Missing value for: ' + namedArgText,
- args[i]));
- }
- else {
- args.splice(i + 1, 1);
- assignment.setArgument(args[i + 1]);
- }
- }
-
- lang.arrayRemove(names, assignment.name);
- args.splice(i, 1);
- // We don't need to i++ if we splice
- }
- }, this);
-
- // What's left are positional parameters assign in order
- names.forEach(function(name) {
- var assignment = this.getAssignment(name);
- if (args.length === 0) {
- // No more values
- assignment.setValue(undefined); // i.e. default
- }
- else {
- var arg = args[0];
- args.splice(0, 1);
- assignment.setArgument(arg);
- }
- }, this);
-
- if (args.length > 0) {
- var remaining = Argument.merge(args);
- this._hints.push(new Hint(Status.INVALID,
- 'Input \'' + remaining.text + '\' makes no sense.',
- remaining));
- }
- };
-
-})();
-exports.CliRequisition = CliRequisition;
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Skywriter Team (skywriter@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/commands/basic', function(require, exports, module) {
-
-
-var canon = require('pilot/canon');
-
-/**
- * '!' command
- */
-var bangCommandSpec = {
- name: 'sh',
- description: 'Execute a system command (requires server support)',
- params: [
- {
- name: 'command',
- type: 'text',
- description: 'The string to send to the os shell.'
- }
- ],
- exec: function(env, args, request) {
- var req = new XMLHttpRequest();
- req.open('GET', '/exec?args=' + args.command, true);
- req.onreadystatechange = function(ev) {
- if (req.readyState == 4) {
- if (req.status == 200) {
- request.done('' + req.responseText + '
');
- }
- }
- };
- req.send(null);
- }
-};
-
-var canon = require('pilot/canon');
-
-exports.startup = function(data, reason) {
- canon.addCommand(bangCommandSpec);
-};
-
-exports.shutdown = function(data, reason) {
- canon.removeCommand(bangCommandSpec);
-};
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Skywriter Team (skywriter@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/commands/git', function(require, exports, module) {
-
-
-var checks = require("pilot/typecheck");
-var canon = require('pilot/canon');
-var Type = require('pilot/types').Type;
-var types = require('pilot/types');
-
-
-/**
- * '!' command
- */
-var gitCommandSpec = {
- name: 'git',
- description: 'Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.'
-};
-
-var gitAddCommandSpec = {
- name: 'git add',
- description: 'Add file contents to the index',
- manual: 'This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.' +
- '
The "index" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working directory, and before running the commit command, you must use the add command to add any new or modified files to the index.' +
- '
This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index.' +
- '
The git status command can be used to obtain a summary of which files have changes that are staged for the next commit.' +
- '
The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option.' +
- '
Please see git-commit(1) for alternative ways to add content to a commit.',
- params: [
- {
- name: 'dry-run',
- short: 'n',
- type: 'bool',
- description: 'Don\'t actually add the file(s), just show if they exist and/or will be ignored.'
- },
- {
- name: 'verbose',
- short: 'v',
- type: 'bool',
- description: 'Be verbose.'
- },
- {
- name: 'force',
- short: 'f',
- type: 'bool',
- description: 'Allow adding otherwise ignored files.'
- },
- {
- name: 'update',
- short: 'u',
- type: 'bool',
- description: 'Only match filepattern against already tracked files in the index rather than the working tree.',
- manual: 'That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.
If no ' + req.responseText + '
');
- }
- }
- };
- req.send(null);
- }
-};
-
-/**
- * commitObject really needs some smarts, but for now it is a clone of string
- */
-var commitObject = new Type();
-
-commitObject.stringify = function(value) {
- return value;
-};
-
-commitObject.parse = function(value) {
- if (typeof value != 'string') {
- throw new Error('non-string passed to commitObject.parse()');
- }
- return new Conversion(value);
-};
-
-commitObject.name = 'commitObject';
-
-/**
- * existingFile really needs some smarts, but for now it is a clone of string
- */
-var existingFile = new Type();
-
-existingFile.stringify = function(value) {
- return value;
-};
-
-existingFile.parse = function(value) {
- if (typeof value != 'string') {
- throw new Error('non-string passed to existingFile.parse()');
- }
- return new Conversion(value);
-};
-
-existingFile.name = 'existingFile';
-
-var gitCommitCommandSpec = {
- name: 'git commit',
- description: 'Record changes to the repository',
- manual: 'Stores the current contents of the index in a new commit along with a log message from the user describing the changes.' +
- '
The content to be added can be specified in several ways:' +
- '
1. by using git add to incrementally "add" changes to the index before using the commit command (Note: even modified files must be "added");' +
- '
2. by using git rm to remove files from the working tree and the index, again before using the commit command;' +
- '
3. by listing files as arguments to the commit command, in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to git);' +
- '
4. by using the -a switch with the commit command to automatically "add" changes from all known files (i.e. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit;' +
- '
5. by using the --interactive switch with the commit command to decide one by one which files should be part of the commit, before finalizing the operation. Currently, this is done by invoking git add --interactive.' +
- '
The --dry-run option can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters (options and paths).' +
- '
If you make a commit and then find a mistake immediately after that, you can recover from it with git reset.',
- params: [
- {
- name: 'all',
- short: 'a',
- type: 'bool',
- description: 'Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.'
- },
- {
- name: 'reuse-message',
- short: 'C',
- type: 'commitObject',
- description: 'Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.'
- },
- {
- name: 'reset-author',
- type: 'bool',
- description: 'When used with --reuse-message/--amend options, declare that the authorship of the resulting commit now belongs of the committer. This also renews the author timestamp.'
- },
- {
- name: 'short',
- type: 'bool',
- description: 'When doing a dry-run, give the output in the short-format.',
- manual: 'See git-status(1) for details. Implies --dry-run.'
- },
- {
- name: 'porcelain',
- type: 'bool',
- description: 'When doing a dry-run, give the output in a porcelain-ready format.',
- manual: 'See git-status(1) for details. Implies --dry-run.'
- },
- {
- name: 'terminate-nul',
- short: 'z',
- type: 'bool',
- description: 'When showing short or porcelain status output, terminate entries in the status output with NUL, instead of LF.',
- manual: 'If no format is given, implies the --porcelain output format.'
- },
- {
- name: 'file',
- short: 'F',
- type: 'existingFile',
- description: 'Take the commit message from the given file.',
- manual: ''
- },
- {
- name: 'author',
- type: 'text',
- description: 'Override the commit author.',
- manual: 'Specify an explicit author using the standard A U Thor
normal Shows untracked files and directories
all Also shows individual files in untracked directories.'
- },
- {
- name: 'verbose',
- short: 'v',
- type: 'bool',
- description: 'Show unified diff between the HEAD commit and what would be committed at the bottom of the commit message template.',
- manual: 'Note that this diff output doesn\'t have its lines prefixed with #.'
- },
- {
- name: 'quiet',
- short: 'q',
- type: 'bool',
- description: 'Suppress commit summary message.'
- },
- {
- name: 'dry-run',
- type: 'bool',
- description: 'Do not create a commit, but show a list of paths that are to be committed, paths with local changes that will be left uncommitted and paths that are untracked.'
- },
- {
- name: 'status',
- type: 'bool',
- description: 'Include the output of git-status(1) in the commit message template when using an editor to prepare the commit message.',
- manual: 'Defaults to on, but can be used to override configuration variable commit.status.'
- },
- {
- name: 'no-status',
- type: 'bool',
- description: 'Do not include the output of git-status(1) in the commit message template when using an editor to prepare the default commit message.'
- },
- {
- name: 'file',
- type: 'existingFile[]',
- description: 'When files are given on the command line, the command commits the contents of the named files, without recording the changes already staged.',
- manual: 'The contents of these files are also staged for the next commit on top of what have been staged before.'
- }
- ],
- exec: function(env, args, request) {
- }
-};
-
-
-var commands = [
- gitCommandSpec,
- gitAddCommandSpec,
- gitCommitCommandSpec
-];
-
-var canon = require('pilot/canon');
-
-exports.startup = function(data, reason) {
- types.registerType(commitObject);
- types.registerType(existingFile);
- commands.forEach(function(command) {
- canon.addCommand(command);
- }, this);
-};
-
-exports.shutdown = function(data, reason) {
- commands.forEach(function(command) {
- canon.removeCommand(command);
- }, this);
- types.unregisterType(commitObject);
- types.unregisterType(existingFile);
-};
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Kevin Dangoor (kdangoor@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/index', function(require, exports, module) {
-
-
-exports.startup = function(data, reason) {
- require('pilot/index');
- require('cockpit/cli').startup(data, reason);
- // window.testCli = require('cockpit/test/testCli');
-
- require('cockpit/ui/settings').startup(data, reason);
- require('cockpit/ui/cliView').startup(data, reason);
- require('cockpit/commands/basic').startup(data, reason);
-};
-
-/*
-exports.shutdown(data, reason) {
-};
-*/
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Joe Walker (jwalker@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/ui/cliView', function(require, exports, module) {
-
-
-var editorCss = require("text!cockpit/ui/cliView.css");
-var dom = require("pilot/dom");
-dom.importCssString(editorCss);
-
-var canon = require("pilot/canon");
-var Status = require('pilot/types').Status;
-var keyutil = require('pilot/keyboard/keyutil');
-
-var CliRequisition = require('cockpit/cli').CliRequisition;
-var Hint = require('cockpit/cli').Hint;
-var RequestView = require('cockpit/ui/requestView').RequestView;
-
-var NO_HINT = new Hint(Status.VALID, '', 0, 0);
-
-/**
- * On startup we need to:
- * 1. Add 3 sets of elements to the DOM for:
- * - command line output
- * - input hints
- * - completion
- * 2. Attach a set of events so the command line works
- */
-exports.startup = function(data, reason) {
- var cli = new CliRequisition(data.env);
- var cliView = new CliView(cli, data.env);
-};
-
-/**
- * A class to handle the simplest UI implementation
- */
-function CliView(cli, env) {
- this.cli = cli;
- this.doc = document;
- this.win = this.doc.defaultView;
-
- // TODO: we should have a better way to specify command lines???
- this.element = this.doc.getElementById('cockpitInput');
- if (!this.element) {
- console.log('No element with an id of cockpit. Bailing on cli');
- return;
- }
-
- this.settings = env.settings;
- this.hintDirection = this.settings.getSetting('hintDirection');
- this.outputDirection = this.settings.getSetting('outputDirection');
- this.outputHeight = this.settings.getSetting('outputHeight');
-
- // If the requisition tells us something has changed, we use this to know
- // if we should ignore it
- this.isUpdating = false;
-
- this.createElements();
- this.update();
-}
-CliView.prototype = {
- /**
- * Create divs for completion, hints and output
- */
- createElements: function() {
- var input = this.element;
-
- this.element.spellcheck = false;
-
- this.output = this.doc.getElementById('cockpitOutput');
- this.popupOutput = (this.output == null);
- if (!this.output) {
- this.output = this.doc.createElement('div');
- this.output.id = 'cockpitOutput';
- this.output.className = 'cptFocusPopup';
- input.parentNode.insertBefore(this.output, input.nextSibling);
-
- var setMaxOutputHeight = function() {
- this.output.style.maxHeight = this.outputHeight.get() + 'px';
- }.bind(this);
- this.outputHeight.addEventListener('change', setMaxOutputHeight);
- setMaxOutputHeight();
- }
-
- this.completer = this.doc.createElement('div');
- this.completer.className = 'cptCompletion VALID';
- var style = window.getComputedStyle(input, null);
- this.completer.style.color = style.color;
- this.completer.style.fontSize = style.fontSize;
- this.completer.style.fontFamily = style.fontFamily;
- this.completer.style.fontWeight = style.fontWeight;
- this.completer.style.fontStyle = style.fontStyle;
- input.parentNode.insertBefore(this.completer, input.nextSibling);
-
- // Transfer background styling to the completer.
- this.completer.style.backgroundColor = input.style.backgroundColor;
- input.style.backgroundColor = 'transparent';
-
- this.hinter = this.doc.createElement('div');
- this.hinter.className = 'cptHints cptFocusPopup';
- input.parentNode.insertBefore(this.hinter, input.nextSibling);
-
- var resizer = this.resizer.bind(this);
- this.win.addEventListener('resize', resizer, false);
- this.hintDirection.addEventListener('change', resizer);
- this.outputDirection.addEventListener('change', resizer);
- resizer();
-
- canon.addEventListener('output', function(ev) {
- new RequestView(ev.request, this);
- }.bind(this));
-
- keyutil.addKeyDownListener(input, this.onKeyDown.bind(this));
- input.addEventListener('keyup', this.onKeyUp.bind(this), true);
- // cursor position affects hint severity. TODO: shortcuts for speed
- input.addEventListener('mouseup', function(ev) {
- this.isUpdating = true;
- this.update();
- this.isUpdating = false;
- }.bind(this), false);
-
- this.cli.addEventListener('argumentChange', this.onArgChange.bind(this));
- },
-
- /**
- * We need to see the output of the latest command entered
- */
- scrollOutputToBottom: function() {
- // Certain browsers have a bug such that scrollHeight is too small
- // when content does not fill the client area of the element
- var scrollHeight = Math.max(this.output.scrollHeight, this.output.clientHeight);
- this.output.scrollTop = scrollHeight - this.output.clientHeight;
- },
-
- /**
- * To be called on window resize or any time we want to align the elements
- * with the input box.
- */
- resizer: function() {
- var rect = this.element.getClientRects()[0];
-
- this.completer.style.top = rect.top + 'px';
- this.completer.style.height = rect.height + 'px';
- this.completer.style.lineHeight = rect.height + 'px';
- this.completer.style.left = rect.left + 'px';
- this.completer.style.width = rect.width + 'px';
-
- if (this.hintDirection.get() === 'below') {
- this.hinter.style.top = rect.bottom + 'px';
- this.hinter.style.bottom = 'auto';
- }
- else {
- this.hinter.style.top = 'auto';
- this.hinter.style.bottom = (this.win.innerHeight - rect.top) + 'px';
- }
- this.hinter.style.left = (rect.left + 30) + 'px';
- this.hinter.style.maxWidth = (rect.width - 110) + 'px';
-
- if (this.popupOutput) {
- if (this.outputDirection.get() === 'below') {
- this.output.style.top = rect.bottom + 'px';
- this.output.style.bottom = 'auto';
- }
- else {
- this.output.style.top = 'auto';
- this.output.style.bottom = (this.win.innerHeight - rect.top) + 'px';
- }
- this.output.style.left = rect.left + 'px';
- this.output.style.width = (rect.width - 80) + 'px';
- }
- },
-
- /**
- * Ensure that TAB isn't handled by the browser
- */
- onKeyDown: function(ev) {
- var handled;
- // var handled = keyboardManager.processKeyEvent(ev, this, {
- // isCommandLine: true, isKeyUp: false
- // });
- if (ev.keyCode === keyutil.KeyHelper.KEY.TAB ||
- ev.keyCode === keyutil.KeyHelper.KEY.UP ||
- ev.keyCode === keyutil.KeyHelper.KEY.DOWN) {
- return true;
- }
- return handled;
- },
-
- /**
- * The main keyboard processing loop
- */
- onKeyUp: function(ev) {
- var handled;
- /*
- var handled = keyboardManager.processKeyEvent(ev, this, {
- isCommandLine: true, isKeyUp: true
- });
- */
-
- // RETURN does a special exec/highlight thing
- if (ev.keyCode === keyutil.KeyHelper.KEY.RETURN) {
- var worst = this.cli.getWorstHint();
- // Deny RETURN unless the command might work
- if (worst.status === Status.VALID) {
- this.cli.exec();
- this.element.value = '';
- }
- else {
- // If we've denied RETURN because the command was not VALID,
- // select the part of the command line that is causing problems
- // TODO: if there are 2 errors are we picking the right one?
- this.element.selectionStart = worst.start;
- this.element.selectionEnd = worst.end;
- }
- }
-
- this.update();
-
- // Special actions which delegate to the assignment
- var current = this.cli.getAssignmentAt(this.element.selectionStart);
- if (current) {
- // TAB does a special complete thing
- if (ev.keyCode === keyutil.KeyHelper.KEY.TAB) {
- current.complete();
- this.update();
- }
-
- // UP/DOWN look for some history
- if (ev.keyCode === keyutil.KeyHelper.KEY.UP) {
- current.increment();
- this.update();
- }
- if (ev.keyCode === keyutil.KeyHelper.KEY.DOWN) {
- current.decrement();
- this.update();
- }
- }
-
- return handled;
- },
-
- /**
- * Actually parse the input and make sure we're all up to date
- */
- update: function() {
- this.isUpdating = true;
- var input = {
- typed: this.element.value,
- cursor: {
- start: this.element.selectionStart,
- end: this.element.selectionEnd
- }
- };
- this.cli.update(input);
-
- var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
-
- // 1. Update the completer with prompt/error marker/TAB info
- dom.removeCssClass(this.completer, Status.VALID.toString());
- dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
- dom.removeCssClass(this.completer, Status.INVALID.toString());
-
- var completion = '> ';
- if (this.element.value.length > 0) {
- var scores = this.cli.getInputStatusMarkup();
- completion += this.markupStatusScore(scores);
- }
-
- // Display the "-> prediction" at the end of the completer
- if (this.element.value.length > 0 &&
- display.predictions && display.predictions.length > 0) {
- var tab = display.predictions[0];
- completion += ' ⇥ ' + (tab.name ? tab.name : tab);
- }
- this.completer.innerHTML = completion;
- dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
-
- // 2. Update the hint element
- var hint = '';
- if (this.element.value.length !== 0) {
- hint += display.message;
- if (display.predictions && display.predictions.length > 0) {
- hint += ': [ ';
- display.predictions.forEach(function(prediction) {
- hint += (prediction.name ? prediction.name : prediction);
- hint += ' | ';
- }, this);
- hint = hint.replace(/\| $/, ']');
- }
- }
-
- this.hinter.innerHTML = hint;
- if (hint.length === 0) {
- dom.addCssClass(this.hinter, 'cptNoPopup');
- }
- else {
- dom.removeCssClass(this.hinter, 'cptNoPopup');
- }
-
- this.isUpdating = false;
- },
-
- /**
- * Markup an array of Status values with spans
- */
- markupStatusScore: function(scores) {
- var completion = '';
- // Create mark-up
- var i = 0;
- var lastStatus = -1;
- while (true) {
- if (lastStatus !== scores[i]) {
- completion += '';
- lastStatus = scores[i];
- }
- completion += this.element.value[i];
- i++;
- if (i === this.element.value.length) {
- completion += '';
- break;
- }
- if (lastStatus !== scores[i]) {
- completion += '';
- }
- }
-
- return completion;
- },
-
- /**
- * Update the input element to reflect the changed argument
- */
- onArgChange: function(ev) {
- if (this.isUpdating) {
- return;
- }
-
- var prefix = this.element.value.substring(0, ev.argument.start);
- var suffix = this.element.value.substring(ev.argument.end);
- var insert = typeof ev.text === 'string' ? ev.text : ev.text.name;
- this.element.value = prefix + insert + suffix;
- // Fix the cursor.
- var insertEnd = (prefix + insert).length;
- this.element.selectionStart = insertEnd;
- this.element.selectionEnd = insertEnd;
- }
-};
-exports.CliView = CliView;
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Joe Walker (jwalker@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/ui/requestView', function(require, exports, module) {
-
-var dom = require("pilot/dom");
-var event = require("pilot/event");
-var requestViewHtml = require("text!cockpit/ui/requestView.html");
-var Templater = require("pilot/domtemplate").Templater;
-
-var requestViewCss = require("text!cockpit/ui/requestView.css");
-dom.importCssString(requestViewCss);
-
-/**
- * Pull the HTML into the DOM, but don't add it to the document
- */
-var templates = document.createElement('div');
-templates.innerHTML = requestViewHtml;
-var row = templates.querySelector('.cptRow');
-
-/**
- * Work out the path for images.
- * TODO: This should probably live in some utility area somewhere
- */
-function imageUrl(path) {
- var dataUrl = require('text!cockpit/ui/' + path);
- if (dataUrl) {
- return dataUrl;
- }
-
- var filename = module.id.split('/').pop() + '.js';
- var imagePath;
-
- if (module.uri.substr(-filename.length) !== filename) {
- console.error('Can\'t work out path from module.uri/module.id');
- return path;
- }
-
- if (module.uri) {
- var end = module.uri.length - filename.length - 1;
- return module.uri.substr(0, end) + path;
- }
-
- return filename + path;
-}
-
-
-/**
- * Adds a row to the CLI output display
- */
-function RequestView(request, cliView) {
- this.request = request;
- this.cliView = cliView;
- this.imageUrl = imageUrl;
-
- // Elements attached to this by the templater. For info only
- this.rowin = null;
- this.rowout = null;
- this.output = null;
- this.hide = null;
- this.show = null;
- this.duration = null;
- this.throb = null;
-
- new Templater().processNode(row.cloneNode(true), this);
-
- this.cliView.output.appendChild(this.rowin);
- this.cliView.output.appendChild(this.rowout);
-
- this.request.addEventListener('output', this.onRequestChange.bind(this));
-};
-
-RequestView.prototype = {
- /**
- * A single click on an invocation line in the console copies the command to
- * the command line
- */
- copyToInput: function() {
- this.cliView.element.value = this.request.typed;
- },
-
- /**
- * A double click on an invocation line in the console executes the command
- */
- executeRequest: function(ev) {
- this.cliView.cli.update({
- typed: this.request.typed,
- cursor: { start:0, end:0 }
- });
- this.cliView.cli.exec();
- },
-
- hideOutput: function(ev) {
- this.output.style.display = 'none';
- dom.addCssClass(this.hide, 'cmd_hidden');
- dom.removeCssClass(this.show, 'cmd_hidden');
-
- event.stopPropagation(ev);
- },
-
- showOutput: function(ev) {
- this.output.style.display = 'block';
- dom.removeCssClass(this.hide, 'cmd_hidden');
- dom.addCssClass(this.show, 'cmd_hidden');
-
- event.stopPropagation(ev);
- },
-
- remove: function(ev) {
- this.cliView.output.removeChild(this.rowin);
- this.cliView.output.removeChild(this.rowout);
- event.stopPropagation(ev);
- },
-
- onRequestChange: function(ev) {
- this.duration.innerHTML = this.request.duration ?
- 'completed in ' + (this.request.duration / 1000) + ' sec ' :
- '';
-
- this.output.innerHTML = '';
- this.request.outputs.forEach(function(output) {
- var node;
- if (typeof output == 'string') {
- node = document.createElement('p');
- node.innerHTML = output;
- } else {
- node = output;
- }
- this.output.appendChild(node);
- }, this);
- this.cliView.scrollOutputToBottom();
-
- dom.setCssClass(this.output, 'cmd_error', this.request.error);
-
- this.throb.style.display = this.request.completed ? 'none' : 'block';
- }
-};
-exports.RequestView = RequestView;
-
-
-});
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Skywriter.
- *
- * The Initial Developer of the Original Code is
- * Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Joe Walker (jwalker@mozilla.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('cockpit/ui/settings', function(require, exports, module) {
-
-
-var types = require("pilot/types");
-var SelectionType = require('pilot/types/basic').SelectionType;
-
-var direction = new SelectionType({
- name: 'direction',
- data: [ 'above', 'below' ]
-});
-
-var hintDirectionSetting = {
- name: "hintDirection",
- description: "Are hints shown above or below the command line?",
- type: "direction",
- defaultValue: "above"
-};
-
-var outputDirectionSetting = {
- name: "outputDirection",
- description: "Is the output window shown above or below the command line?",
- type: "direction",
- defaultValue: "above"
-};
-
-var outputHeightSetting = {
- name: "outputHeight",
- description: "What height should the output panel be?",
- type: "number",
- defaultValue: 300
-};
-
-exports.startup = function(data, reason) {
- types.registerType(direction);
- data.env.settings.addSetting(hintDirectionSetting);
- data.env.settings.addSetting(outputDirectionSetting);
- data.env.settings.addSetting(outputHeightSetting);
-};
-
-exports.shutdown = function(data, reason) {
- types.unregisterType(direction);
- data.env.settings.removeSetting(hintDirectionSetting);
- data.env.settings.removeSetting(outputDirectionSetting);
- data.env.settings.removeSetting(outputHeightSetting);
-};
-
-
-});
-define("text!cockpit/ui/cliView.css", "" +
- "#cockpitInput { padding-left: 16px; }" +
- "" +
- "#cockpitOutput { overflow: auto; }" +
- "#cockpitOutput.cptFocusPopup { position: absolute; z-index: 999; }" +
- "" +
- ".cptFocusPopup { display: none; }" +
- "#cockpitInput:focus ~ .cptFocusPopup { display: block; }" +
- "#cockpitInput:focus ~ .cptFocusPopup.cptNoPopup { display: none; }" +
- "" +
- ".cptCompletion { padding: 0; position: absolute; z-index: -1000; }" +
- ".cptCompletion.VALID { background: #FFF; }" +
- ".cptCompletion.INCOMPLETE { background: #DDD; }" +
- ".cptCompletion.INVALID { background: #DDD; }" +
- ".cptCompletion span { color: #FFF; }" +
- ".cptCompletion span.INCOMPLETE { color: #DDD; border-bottom: 2px dotted #F80; }" +
- ".cptCompletion span.INVALID { color: #DDD; border-bottom: 2px dotted #F00; }" +
- "span.cptPrompt { color: #66F; font-weight: bold; }" +
- "" +
- "" +
- ".cptHints {" +
- " color: #000;" +
- " position: absolute;" +
- " border: 1px solid rgba(230, 230, 230, 0.8);" +
- " background: rgba(250, 250, 250, 0.8);" +
- " -moz-border-radius-topleft: 10px;" +
- " -moz-border-radius-topright: 10px;" +
- " border-top-left-radius: 10px; border-top-right-radius: 10px;" +
- " z-index: 1000;" +
- " padding: 8px;" +
- " display: none;" +
- "}" +
- ".cptHints ul { margin: 0; padding: 0 15px; }" +
- "" +
- ".cptGt { font-weight: bold; font-size: 120%; }" +
- "");
-
-define("text!cockpit/ui/requestView.css", "" +
- ".cptRowIn {" +
- " display: box; display: -moz-box; display: -webkit-box;" +
- " box-orient: horizontal; -moz-box-orient: horizontal; -webkit-box-orient: horizontal;" +
- " box-align: center; -moz-box-align: center; -webkit-box-align: center;" +
- " color: #333;" +
- " background-color: #EEE;" +
- " width: 100%;" +
- " font-family: consolas, courier, monospace;" +
- "}" +
- ".cptRowIn > * { padding-left: 2px; padding-right: 2px; }" +
- ".cptRowIn > img { cursor: pointer; }" +
- ".cptHover { display: none; }" +
- ".cptRowIn:hover > .cptHover { display: block; }" +
- ".cptRowIn:hover > .cptHover.cptHidden { display: none; }" +
- ".cptOutTyped {" +
- " box-flex: 1; -moz-box-flex: 1; -webkit-box-flex: 1;" +
- " font-weight: bold; color: #000; font-size: 120%;" +
- "}" +
- ".cptRowOutput { padding-left: 10px; line-height: 1.2em; }" +
- ".cptRowOutput strong," +
- ".cptRowOutput b," +
- ".cptRowOutput th," +
- ".cptRowOutput h1," +
- ".cptRowOutput h2," +
- ".cptRowOutput h3 { color: #000; }" +
- ".cptRowOutput a { font-weight: bold; color: #666; text-decoration: none; }" +
- ".cptRowOutput a: hover { text-decoration: underline; cursor: pointer; }" +
- ".cptRowOutput input[type=password]," +
- ".cptRowOutput input[type=text]," +
- ".cptRowOutput textarea {" +
- " color: #000; font-size: 120%;" +
- " background: transparent; padding: 3px;" +
- " border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;" +
- "}" +
- ".cptRowOutput table," +
- ".cptRowOutput td," +
- ".cptRowOutput th { border: 0; padding: 0 2px; }" +
- ".cptRowOutput .right { text-align: right; }" +
- "");
-
-define("text!cockpit/ui/requestView.html", "" +
- "" +
- "
" +
- "
" +
- "" +
- "
" +
- "
Welcome to Skywriter - Code in the Cloud
",plainSuffix:"For more information, see the Skywriter Wiki."};var helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[];var e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=false;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("Sub-Commands of "+e.name+"
"),d.push("Commands starting with '"+b.search+"':
")):d.push("Available Commands:
");var g=canon.getCommandNames();g.sort(),d.push("");for(var h=0;h
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}};var evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:true,exec:function(env,args,request){var result;var javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="";var type="";var x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g,""+e.name+" "),d.push(""+e.description+" "),d.push("")}d.push("
").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[];var value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()
"}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):
"+msg)}};var versionCommandSpec={name:"version",description:"show the Skywriter version",hidden:true,exec:function(a,b,c){var d="Skywriter "+skywriter.versionNumber+" ("+skywriter.versionCodename+")";c.done(d)}};var skywriterCommandSpec={name:"skywriter",hidden:true,exec:function(a,b,c){var d=Math.floor(Math.random()*messages.length);c.done("Skywriter "+messages[d])}};var messages=["really wants you to trick it out in some way.","is your Web editor.","would love to be like Emacs on the Web.","is written on the Web platform, so you can tweak it."];var canon=require("pilot/canon");exports.startup=function(a,b){canon.addCommand(helpCommandSpec),canon.addCommand(evalCommandSpec),canon.addCommand(skywriterCommandSpec)},exports.shutdown=function(a,b){canon.removeCommand(helpCommandSpec),canon.removeCommand(evalCommandSpec),canon.removeCommand(skywriterCommandSpec)}}),define("pilot/commands/history",function(a,b,c){var d={name:"historyPrevious",predicates:{isCommandLine:true,isKeyUp:true},key:"up",exec:function(a,b){g>0&&g--;var c=history.requests[g].typed;env.commandLine.setInput(c)}};var e={name:"historyNext",predicates:{isCommandLine:true,isKeyUp:true},key:"down",exec:function(a,b){g"),c.push(" "),d++}),c.push(""),b.done(c.join(""))}};var g=0;b.addedRequestOutput=function(){g=history.requests.length}}),define("pilot/commands/settings",function(a,b,c){var d={name:"set",params:[{name:"setting",type:"setting",description:"The name of the setting to display or alter",defaultValue:null},{name:"value",type:"settingValue",description:"The new value for the chosen setting",defaultValue:null}],description:"define and show settings",exec:function(a,b,c){var d;if(b.setting)b.value===undefined?d=""+setting.name+" = "+setting.get():(b.setting.set(b.value),d="Setting: "+b.setting.name+" = "+b.setting.get());else{var e=a.settings.getSettingNames();d="",e.sort(function(a,b){return a.localeCompare(b)}),e.forEach(function(b){var c=a.settings.getSetting(b);var e="https://wiki.mozilla.org/Labs/Skywriter/Settings#"+c.name;d+=""+c.name+" = "+c.value+""+d+" "),c.push(""+a.typed+" "),c.push("
"})}c.done(d)}};var e={name:"unset",params:[{name:"setting",type:"setting",description:"The name of the setting to return to defaults"}],description:"unset a setting entirely",exec:function(a,b,c){var d=a.settings.get(b.setting);d?(d.reset(),c.done("Reset "+d.name+" to default: "+a.settings.get(b.setting))):c.doneWithError("No setting with the name "+b.setting+".")}};var f=a("pilot/canon");b.startup=function(a,b){f.addCommand(d),f.addCommand(e)},b.shutdown=function(a,b){f.removeCommand(d),f.removeCommand(e)}}),define("pilot/console",function(a,b,c){var d=function(){};var e=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","log","profile","profileEnd","time","timeEnd","trace","warn"];typeof window==="undefined"?e.forEach(function(a){b[a]=function(){var b=Array.prototype.slice.call(arguments);var c={op:"log",method:a,args:b};postMessage(JSON.stringify(c))}}):e.forEach(function(a){window.console&&window.console[a]?b[a]=Function.prototype.bind.call(window.console[a],window.console):b[a]=d})}),define("pilot/dom",function(a,b,c){b.setText=function(a,b){a.innerText!==undefined&&(a.innerText=b),a.textContent!==undefined&&(a.textContent=b)},b.hasCssClass=function(a,b){var c=a.className.split(/\s+/g);return c.indexOf(b)!==-1},b.addCssClass=function(a,c){b.hasCssClass(a,c)||(a.className+=" "+c)},b.setCssClass=function(a,c,d){d?b.addCssClass(a,c):b.removeCssClass(a,c)},b.removeCssClass=function(a,b){var c=a.className.split(/\s+/g);while(true){var d=c.indexOf(b);if(d==-1)break;c.splice(d,1)}a.className=c.join(" ")},b.importCssString=function(a,b){b=b||document;if(b.createStyleSheet){var c=b.createStyleSheet();c.cssText=a}else{var d=b.createElement("style");d.appendChild(b.createTextNode(a)),b.getElementsByTagName("head")[0].appendChild(d)}},b.getInnerWidth=function(a){return parseInt(b.computedStyle(a,"paddingLeft"))+parseInt(b.computedStyle(a,"paddingRight"))+a.clientWidth},b.getInnerHeight=function(a){return parseInt(b.computedStyle(a,"paddingTop"))+parseInt(b.computedStyle(a,"paddingBottom"))+a.clientHeight},b.computedStyle=function(a,b){return window.getComputedStyle?(window.getComputedStyle(a,"")||{})[b]||"":a.currentStyle[b]},b.scrollbarWidth=function(){var a=document.createElement("p");a.style.width="100%",a.style.height="200px";var b=document.createElement("div");var c=b.style;c.position="absolute",c.left="-10000px",c.overflow="hidden",c.width="200px",c.height="150px",b.appendChild(a),document.body.appendChild(b);var d=a.offsetWidth;c.overflow="scroll";var e=a.offsetWidth;d==e&&(e=b.clientWidth),document.body.removeChild(b);return d-e}}),define("pilot/domtemplate",function(require,exports,module){function Templater(){this.scope=[]}Templater.prototype.processNode=function(a,b){typeof a==="string"&&(a=document.getElementById(a));if(b===null||b===undefined)b={};this.scope.push(a.nodeName+(a.id?"#"+a.id:""));try{if(a.attributes&&a.attributes.length){if(a.hasAttribute("foreach")){this.processForEach(a,b);return}if(a.hasAttribute("if"))if(!this.processIf(a,b))return;b.__element=a;var c=Array.prototype.slice.call(a.attributes);for(var d=0;d
"),c.push(a.description?a.description:"(No description)"),c.push("
"),a.params&&a.params.length>0&&(c.push(""),a.params.forEach(function(a){c.push("
"));return new l(i.VALID,c.join(""),b)}};function q(a){this.env=a,this.commandAssignment=new o(p,this)}q.prototype={commandAssignment:undefined,assignmentCount:undefined,_assignments:undefined,_hints:undefined,_assignmentChanged:function(a){a.param.name!=="__command"||(this._assignments={},a.value&&a.value.params.forEach(function(a){this._assignments[a.name]=new o(a,this)},this),this.assignmentCount=Object.keys(this._assignments).length,this._dispatchEvent("commandChange",{command:a.value}))},getAssignment:function(a){var b=typeof a==="string"?a:Object.keys(this._assignments)[a];return this._assignments[b]},getParameterNames:function(){return Object.keys(this._assignments)},cloneAssignments:function(){return Object.keys(this._assignments).map(function(a){return this._assignments[a]},this)},_updateHints:function(){this.getAssignments(true).forEach(function(a){this._hints.push(a.getHint())},this),l.sort(this._hints)},getWorstHint:function(){return this._hints[0]},getArgsObject:function(){var a={};this.getAssignments().forEach(function(b){a[b.param.name]=b.value},this);return a},getAssignments:function(a){var b=[];a===true&&b.push(this.commandAssignment),Object.keys(this._assignments).forEach(function(a){b.push(this.getAssignment(a))},this);return b},setDefaultValues:function(){this.getAssignments().forEach(function(a){a.setValue(undefined)},this)},exec:function(){k.exec(this.commandAssignment.value,this.env,this.getArgsObject(),this.toCanonicalString())},toCanonicalString:function(){var a=[];a.push(this.commandAssignment.value.name),Object.keys(this._assignments).forEach(function(b){var c=this._assignments[b];var d=c.param.type;c.value!==c.param.defaultValue&&(a.push(" "),a.push(d.stringify(c.value)))},this);return a.join("")}},f.implement(q.prototype,g),b.Requisition=q;function r(a,b){q.call(this,a),b&&b.flags&&(this.flags=b.flags)}f.inherits(r,q),function(){r.prototype.update=function(a){this.input=a,this._hints=[];var b=this._tokenize(a.typed);this._split(b),this.commandAssignment.value&&this._assign(b),this._updateHints()},r.prototype.getInputStatusMarkup=function(){var a=this.toString().split("").map(function(a){return i.VALID});this._hints.forEach(function(b){for(var c=b.start;c<=b.end;c++)b.status>a[c]&&(a[c]=b.status)},this);return a},r.prototype.toString=function(){return this.getAssignments(true).map(function(a){return a.toString()},this).join("")};var a=r.prototype._updateHints;r.prototype._updateHints=function(){a.call(this);var b=this.input.cursor;this._hints.forEach(function(a){var c=b.start>=a.start&&b.start<=a.end;var d=b.end>=a.start&&b.end<=a.end;var e=c||d;!e&&a.status===i.INCOMPLETE&&(a.status=i.INVALID)},this),l.sort(this._hints)},r.prototype.getHints=function(){return this._hints},r.prototype.getAssignmentAt=function(a){var b=this.getAssignments(true);for(var c=0;c"+d.responseText+"
"))},d.send(null)}};var d=a("pilot/canon");b.startup=function(a,b){d.addCommand(e)},b.shutdown=function(a,b){d.removeCommand(e)}}),define("cockpit/commands/git",function(a,b,c){var d=a("pilot/typecheck");var e=a("pilot/canon");var f=a("pilot/types").Type;var g=a("pilot/types");var h={name:"git",description:"Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals."};var i={name:"git add",description:"Add file contents to the index",manual:"This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.
The \"index\" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working directory, and before running the commit command, you must use the add command to add any new or modified files to the index.
This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index.
The git status command can be used to obtain a summary of which files have changes that are staged for the next commit.
The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option.
Please see git-commit(1) for alternative ways to add content to a commit.",params:[{name:"dry-run","short":"n",type:"bool",description:"Don't actually add the file(s), just show if they exist and/or will be ignored."},{name:"verbose","short":"v",type:"bool",description:"Be verbose."},{name:"force","short":"f",type:"bool",description:"Allow adding otherwise ignored files."},{name:"update","short":"u",type:"bool",description:"Only match filepattern against already tracked files in the index rather than the working tree.",manual:"That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.
If no "+d.responseText+"
"))},d.send(null)}};var j=new f;j.stringify=function(a){return a},j.parse=function(a){if(typeof a!="string")throw new Error("non-string passed to commitObject.parse()");return new Conversion(a)},j.name="commitObject";var k=new f;k.stringify=function(a){return a},k.parse=function(a){if(typeof a!="string")throw new Error("non-string passed to existingFile.parse()");return new Conversion(a)},k.name="existingFile";var l={name:"git commit",description:"Record changes to the repository",manual:"Stores the current contents of the index in a new commit along with a log message from the user describing the changes.
The content to be added can be specified in several ways:
1. by using git add to incrementally \"add\" changes to the index before using the commit command (Note: even modified files must be \"added\");
2. by using git rm to remove files from the working tree and the index, again before using the commit command;
3. by listing files as arguments to the commit command, in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to git);
4. by using the -a switch with the commit command to automatically \"add\" changes from all known files (i.e. all files that are already listed in the index) and to automatically \"rm\" files in the index that have been removed from the working tree, and then perform the actual commit;
5. by using the --interactive switch with the commit command to decide one by one which files should be part of the commit, before finalizing the operation. Currently, this is done by invoking git add --interactive.
The --dry-run option can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters (options and paths).
If you make a commit and then find a mistake immediately after that, you can recover from it with git reset.",params:[{name:"all","short":"a",type:"bool",description:"Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected."},{name:"reuse-message","short":"C",type:"commitObject",description:"Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit."},{name:"reset-author",type:"bool",description:"When used with --reuse-message/--amend options, declare that the authorship of the resulting commit now belongs of the committer. This also renews the author timestamp."},{name:"short",type:"bool",description:"When doing a dry-run, give the output in the short-format.",manual:"See git-status(1) for details. Implies --dry-run."},{name:"porcelain",type:"bool",description:"When doing a dry-run, give the output in a porcelain-ready format.",manual:"See git-status(1) for details. Implies --dry-run."},{name:"terminate-nul","short":"z",type:"bool",description:"When showing short or porcelain status output, terminate entries in the status output with NUL, instead of LF.",manual:"If no format is given, implies the --porcelain output format."},{name:"file","short":"F",type:"existingFile",description:"Take the commit message from the given file.",manual:""},{name:"author",type:"text",description:"Override the commit author.",manual:"Specify an explicit author using the standard A U Thor
normal Shows untracked files and directories
all Also shows individual files in untracked directories."},{name:"verbose","short":"v",type:"bool",description:"Show unified diff between the HEAD commit and what would be committed at the bottom of the commit message template.",manual:"Note that this diff output doesn't have its lines prefixed with #."},{name:"quiet","short":"q",type:"bool",description:"Suppress commit summary message."},{name:"dry-run",type:"bool",description:"Do not create a commit, but show a list of paths that are to be committed, paths with local changes that will be left uncommitted and paths that are untracked."},{name:"status",type:"bool",description:"Include the output of git-status(1) in the commit message template when using an editor to prepare the commit message.",manual:"Defaults to on, but can be used to override configuration variable commit.status."},{name:"no-status",type:"bool",description:"Do not include the output of git-status(1) in the commit message template when using an editor to prepare the default commit message."},{name:"file",type:"existingFile[]",description:"When files are given on the command line, the command commits the contents of the named files, without recording the changes already staged.",manual:"The contents of these files are also staged for the next commit on top of what have been staged before."}],exec:function(a,b,c){}};var m=[h,i,l];var e=a("pilot/canon");b.startup=function(a,b){g.registerType(j),g.registerType(k),m.forEach(function(a){e.addCommand(a)},this)},b.shutdown=function(a,b){m.forEach(function(a){e.removeCommand(a)},this),g.unregisterType(j),g.unregisterType(k)}}),define("cockpit/index",function(a,b,c){b.startup=function(b,c){a("pilot/index"),a("cockpit/cli").startup(b,c),a("cockpit/ui/settings").startup(b,c),a("cockpit/ui/cliView").startup(b,c),a("cockpit/commands/basic").startup(b,c)}}),define("cockpit/ui/cliView",function(a,b,c){var d=a("text!cockpit/ui/cliView.css");var e=a("pilot/dom");e.importCssString(d);var f=a("pilot/canon");var g=a("pilot/types").Status;var h=a("pilot/keyboard/keyutil");var i=a("cockpit/cli").CliRequisition;var j=a("cockpit/cli").Hint;var k=a("cockpit/ui/requestView").RequestView;var l=new j(g.VALID,"",0,0);b.startup=function(a,b){var c=new i(a.env);var d=new m(c,a.env)};function m(a,b){this.cli=a,this.doc=document,this.win=this.doc.defaultView,this.element=this.doc.getElementById("cockpitInput");this.element?(this.settings=b.settings,this.hintDirection=this.settings.getSetting("hintDirection"),this.outputDirection=this.settings.getSetting("outputDirection"),this.outputHeight=this.settings.getSetting("outputHeight"),this.isUpdating=false,this.createElements(),this.update()):console.log("No element with an id of cockpit. Bailing on cli")}m.prototype={createElements:function(){var a=this.element;this.element.spellcheck=false,this.output=this.doc.getElementById("cockpitOutput"),this.popupOutput=this.output==null;if(!this.output){this.output=this.doc.createElement("div"),this.output.id="cockpitOutput",this.output.className="cptFocusPopup",a.parentNode.insertBefore(this.output,a.nextSibling);var b=function(){this.output.style.maxHeight=this.outputHeight.get()+"px"}.bind(this);this.outputHeight.addEventListener("change",b),b()}this.completer=this.doc.createElement("div"),this.completer.className="cptCompletion VALID";var c=window.getComputedStyle(a,null);this.completer.style.color=c.color,this.completer.style.fontSize=c.fontSize,this.completer.style.fontFamily=c.fontFamily,this.completer.style.fontWeight=c.fontWeight,this.completer.style.fontStyle=c.fontStyle,a.parentNode.insertBefore(this.completer,a.nextSibling),this.completer.style.backgroundColor=a.style.backgroundColor,a.style.backgroundColor="transparent",this.hinter=this.doc.createElement("div"),this.hinter.className="cptHints cptFocusPopup",a.parentNode.insertBefore(this.hinter,a.nextSibling);var d=this.resizer.bind(this);this.win.addEventListener("resize",d,false),this.hintDirection.addEventListener("change",d),this.outputDirection.addEventListener("change",d),d(),f.addEventListener("output",function(a){new k(a.request,this)}.bind(this)),h.addKeyDownListener(a,this.onKeyDown.bind(this)),a.addEventListener("keyup",this.onKeyUp.bind(this),true),a.addEventListener("mouseup",function(a){this.isUpdating=true,this.update(),this.isUpdating=false}.bind(this),false),this.cli.addEventListener("argumentChange",this.onArgChange.bind(this))},scrollOutputToBottom:function(){var a=Math.max(this.output.scrollHeight,this.output.clientHeight);this.output.scrollTop=a-this.output.clientHeight},resizer:function(){var a=this.element.getClientRects()[0];this.completer.style.top=a.top+"px",this.completer.style.height=a.height+"px",this.completer.style.lineHeight=a.height+"px",this.completer.style.left=a.left+"px",this.completer.style.width=a.width+"px",this.hintDirection.get()==="below"?(this.hinter.style.top=a.bottom+"px",this.hinter.style.bottom="auto"):(this.hinter.style.top="auto",this.hinter.style.bottom=this.win.innerHeight-a.top+"px"),this.hinter.style.left=a.left+30+"px",this.hinter.style.maxWidth=a.width-110+"px",this.popupOutput&&(this.outputDirection.get()==="below"?(this.output.style.top=a.bottom+"px",this.output.style.bottom="auto"):(this.output.style.top="auto",this.output.style.bottom=this.win.innerHeight-a.top+"px"),this.output.style.left=a.left+"px",this.output.style.width=a.width-80+"px")},onKeyDown:function(a){var b;if(a.keyCode===h.KeyHelper.KEY.TAB||a.keyCode===h.KeyHelper.KEY.UP||a.keyCode===h.KeyHelper.KEY.DOWN)return true;return b},onKeyUp:function(a){var b;if(a.keyCode===h.KeyHelper.KEY.RETURN){var c=this.cli.getWorstHint();c.status===g.VALID?(this.cli.exec(),this.element.value=""):(this.element.selectionStart=c.start,this.element.selectionEnd=c.end)}this.update();var d=this.cli.getAssignmentAt(this.element.selectionStart);d&&(a.keyCode===h.KeyHelper.KEY.TAB&&(d.complete(),this.update()),a.keyCode===h.KeyHelper.KEY.UP&&(d.increment(),this.update()),a.keyCode===h.KeyHelper.KEY.DOWN&&(d.decrement(),this.update()));return b},update:function(){this.isUpdating=true;var a={typed:this.element.value,cursor:{start:this.element.selectionStart,end:this.element.selectionEnd}};this.cli.update(a);var b=this.cli.getAssignmentAt(a.cursor.start).getHint();e.removeCssClass(this.completer,g.VALID.toString()),e.removeCssClass(this.completer,g.INCOMPLETE.toString()),e.removeCssClass(this.completer,g.INVALID.toString());var c="> ";if(this.element.value.length>0){var d=this.cli.getInputStatusMarkup();c+=this.markupStatusScore(d)}if(this.element.value.length>0&&b.predictions&&b.predictions.length>0){var f=b.predictions[0];c+=" ⇥ "+(f.name?f.name:f)}this.completer.innerHTML=c,e.addCssClass(this.completer,this.cli.getWorstHint().status.toString());var h="";this.element.value.length!==0&&(h+=b.message,b.predictions&&b.predictions.length>0&&(h+=": [ ",b.predictions.forEach(function(a){h+=a.name?a.name:a,h+=" | "},this),h=h.replace(/\| $/,"]"))),this.hinter.innerHTML=h,h.length===0?e.addCssClass(this.hinter,"cptNoPopup"):e.removeCssClass(this.hinter,"cptNoPopup"),this.isUpdating=false},markupStatusScore:function(a){var b="";var c=0;var d=-1;while(true){d!==a[c]&&(b+="",d=a[c]),b+=this.element.value[c],c++;if(c===this.element.value.length){b+="";break}d!==a[c]&&(b+="")}return b},onArgChange:function(a){if(!this.isUpdating){var b=this.element.value.substring(0,a.argument.start);var c=this.element.value.substring(a.argument.end);var d=typeof a.text==="string"?a.text:a.text.name;this.element.value=b+d+c;var e=(b+d).length;this.element.selectionStart=e,this.element.selectionEnd=e}}},b.CliView=m}),define("cockpit/ui/requestView",function(a,b,c){var d=a("pilot/dom");var e=a("pilot/event");var f=a("text!cockpit/ui/requestView.html");var g=a("pilot/domtemplate").Templater;var h=a("text!cockpit/ui/requestView.css");d.importCssString(h);var i=document.createElement("div");i.innerHTML=f;var j=i.querySelector(".cptRow");function k(b){var d=a("text!cockpit/ui/"+b);if(d)return d;var e=c.id.split("/").pop()+".js";var f;if(c.uri.substr(-e.length)!==e){console.error("Can't work out path from module.uri/module.id");return b}if(c.uri){var g=c.uri.length-e.length-1;return c.uri.substr(0,g)+b}return e+b}function l(a,b){this.request=a,this.cliView=b,this.imageUrl=k,this.rowin=null,this.rowout=null,this.output=null,this.hide=null,this.show=null,this.duration=null,this.throb=null,(new g).processNode(j.cloneNode(true),this),this.cliView.output.appendChild(this.rowin),this.cliView.output.appendChild(this.rowout),this.request.addEventListener("output",this.onRequestChange.bind(this))}l.prototype={copyToInput:function(){this.cliView.element.value=this.request.typed},executeRequest:function(a){this.cliView.cli.update({typed:this.request.typed,cursor:{start:0,end:0}}),this.cliView.cli.exec()},hideOutput:function(a){this.output.style.display="none",d.addCssClass(this.hide,"cmd_hidden"),d.removeCssClass(this.show,"cmd_hidden"),e.stopPropagation(a)},showOutput:function(a){this.output.style.display="block",d.removeCssClass(this.hide,"cmd_hidden"),d.addCssClass(this.show,"cmd_hidden"),e.stopPropagation(a)},remove:function(a){this.cliView.output.removeChild(this.rowin),this.cliView.output.removeChild(this.rowout),e.stopPropagation(a)},onRequestChange:function(a){this.duration.innerHTML=this.request.duration?"completed in "+this.request.duration/1e3+" sec ":"",this.output.innerHTML="",this.request.outputs.forEach(function(a){var b;typeof a=="string"?(b=document.createElement("p"),b.innerHTML=a):b=a,this.output.appendChild(b)},this),this.cliView.scrollOutputToBottom(),d.setCssClass(this.output,"cmd_error",this.request.error),this.throb.style.display=this.request.completed?"none":"block"}},b.RequestView=l}),define("cockpit/ui/settings",function(a,b,c){var d=a("pilot/types");var e=a("pilot/types/basic").SelectionType;var f=new e({name:"direction",data:["above","below"]});var g={name:"hintDirection",description:"Are hints shown above or below the command line?",type:"direction",defaultValue:"above"};var h={name:"outputDirection",description:"Is the output window shown above or below the command line?",type:"direction",defaultValue:"above"};var i={name:"outputHeight",description:"What height should the output panel be?",type:"number",defaultValue:300};b.startup=function(a,b){d.registerType(f),a.env.settings.addSetting(g),a.env.settings.addSetting(h),a.env.settings.addSetting(i)},b.shutdown=function(a,b){d.unregisterType(f),a.env.settings.removeSetting(g),a.env.settings.removeSetting(h),a.env.settings.removeSetting(i)}}),define("text!cockpit/ui/cliView.css","#cockpitInput { padding-left: 16px; }#cockpitOutput { overflow: auto; }#cockpitOutput.cptFocusPopup { position: absolute; z-index: 999; }.cptFocusPopup { display: none; }#cockpitInput:focus ~ .cptFocusPopup { display: block; }#cockpitInput:focus ~ .cptFocusPopup.cptNoPopup { display: none; }.cptCompletion { padding: 0; position: absolute; z-index: -1000; }.cptCompletion.VALID { background: #FFF; }.cptCompletion.INCOMPLETE { background: #DDD; }.cptCompletion.INVALID { background: #DDD; }.cptCompletion span { color: #FFF; }.cptCompletion span.INCOMPLETE { color: #DDD; border-bottom: 2px dotted #F80; }.cptCompletion span.INVALID { color: #DDD; border-bottom: 2px dotted #F00; }span.cptPrompt { color: #66F; font-weight: bold; }.cptHints { color: #000; position: absolute; border: 1px solid rgba(230, 230, 230, 0.8); background: rgba(250, 250, 250, 0.8); -moz-border-radius-topleft: 10px; -moz-border-radius-topright: 10px; border-top-left-radius: 10px; border-top-right-radius: 10px; z-index: 1000; padding: 8px; display: none;}.cptHints ul { margin: 0; padding: 0 15px; }.cptGt { font-weight: bold; font-size: 120%; }"),define("text!cockpit/ui/requestView.css",".cptRowIn { display: box; display: -moz-box; display: -webkit-box; box-orient: horizontal; -moz-box-orient: horizontal; -webkit-box-orient: horizontal; box-align: center; -moz-box-align: center; -webkit-box-align: center; color: #333; background-color: #EEE; width: 100%; font-family: consolas, courier, monospace;}.cptRowIn > * { padding-left: 2px; padding-right: 2px; }.cptRowIn > img { cursor: pointer; }.cptHover { display: none; }.cptRowIn:hover > .cptHover { display: block; }.cptRowIn:hover > .cptHover.cptHidden { display: none; }.cptOutTyped { box-flex: 1; -moz-box-flex: 1; -webkit-box-flex: 1; font-weight: bold; color: #000; font-size: 120%;}.cptRowOutput { padding-left: 10px; line-height: 1.2em; }.cptRowOutput strong,.cptRowOutput b,.cptRowOutput th,.cptRowOutput h1,.cptRowOutput h2,.cptRowOutput h3 { color: #000; }.cptRowOutput a { font-weight: bold; color: #666; text-decoration: none; }.cptRowOutput a: hover { text-decoration: underline; cursor: pointer; }.cptRowOutput input[type=password],.cptRowOutput input[type=text],.cptRowOutput textarea { color: #000; font-size: 120%; background: transparent; padding: 3px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;}.cptRowOutput table,.cptRowOutput td,.cptRowOutput th { border: 0; padding: 0 2px; }.cptRowOutput .right { text-align: right; }"),define("text!cockpit/ui/requestView.html","
Welcome to Skywriter - Code in the Cloud
",plainSuffix:"For more information, see the Skywriter Wiki."};var helpCommandSpec={name:"help",params:[{name:"search",type:"text",description:"Search string to narrow the output.",defaultValue:null}],description:"Get help on the available commands.",exec:function(a,b,c){var d=[];var e=canon.getCommand(b.search);if(e&&e.exec)d.push(e.description?e.description:"No description for "+b.search);else{var f=false;!b.search&&helpMessages.plainPrefix&&d.push(helpMessages.plainPrefix),e?(d.push("Sub-Commands of "+e.name+"
"),d.push("Commands starting with '"+b.search+"':
")):d.push("Available Commands:
");var g=canon.getCommandNames();g.sort(),d.push("");for(var h=0;h
"),!b.search&&helpMessages.plainSuffix&&d.push(helpMessages.plainSuffix)}c.done(d.join(""))}};var evalCommandSpec={name:"eval",params:[{name:"javascript",type:"text",description:"The JavaScript to evaluate"}],description:"evals given js code and show the result",hidden:true,exec:function(env,args,request){var result;var javascript=args.javascript;try{result=eval(javascript)}catch(e){result="Error: "+e.message+""}var msg="";var type="";var x;if(checks.isFunction(result))msg=(result+"").replace(/\n/g,""+e.name+" "),d.push(""+e.description+" "),d.push("")}d.push("
").replace(/ /g," "),type="function";else if(checks.isObject(result)){Array.isArray(result)?type="array":type="object";var items=[];var value;for(x in result)result.hasOwnProperty(x)&&(checks.isFunction(result[x])?value="[function]":checks.isObject(result[x])?value="[object]":value=result[x],items.push({name:x,value:value}));items.sort(function(a,b){return a.name.toLowerCase()
"}else msg=result,type=typeof result;request.done("Result for eval '"+javascript+"' (type: "+type+"):
"+msg)}};var versionCommandSpec={name:"version",description:"show the Skywriter version",hidden:true,exec:function(a,b,c){var d="Skywriter "+skywriter.versionNumber+" ("+skywriter.versionCodename+")";c.done(d)}};var skywriterCommandSpec={name:"skywriter",hidden:true,exec:function(a,b,c){var d=Math.floor(Math.random()*messages.length);c.done("Skywriter "+messages[d])}};var messages=["really wants you to trick it out in some way.","is your Web editor.","would love to be like Emacs on the Web.","is written on the Web platform, so you can tweak it."];var canon=require("pilot/canon");exports.startup=function(a,b){canon.addCommand(helpCommandSpec),canon.addCommand(evalCommandSpec),canon.addCommand(skywriterCommandSpec)},exports.shutdown=function(a,b){canon.removeCommand(helpCommandSpec),canon.removeCommand(evalCommandSpec),canon.removeCommand(skywriterCommandSpec)}}),define("pilot/commands/history",function(a,b,c){var d={name:"historyPrevious",predicates:{isCommandLine:true,isKeyUp:true},key:"up",exec:function(a,b){g>0&&g--;var c=history.requests[g].typed;env.commandLine.setInput(c)}};var e={name:"historyNext",predicates:{isCommandLine:true,isKeyUp:true},key:"down",exec:function(a,b){g"),c.push(" "),d++}),c.push(""),b.done(c.join(""))}};var g=0;b.addedRequestOutput=function(){g=history.requests.length}}),define("pilot/commands/settings",function(a,b,c){var d={name:"set",params:[{name:"setting",type:"setting",description:"The name of the setting to display or alter",defaultValue:null},{name:"value",type:"settingValue",description:"The new value for the chosen setting",defaultValue:null}],description:"define and show settings",exec:function(a,b,c){var d;if(b.setting)b.value===undefined?d=""+setting.name+" = "+setting.get():(b.setting.set(b.value),d="Setting: "+b.setting.name+" = "+b.setting.get());else{var e=a.settings.getSettingNames();d="",e.sort(function(a,b){return a.localeCompare(b)}),e.forEach(function(b){var c=a.settings.getSetting(b);var e="https://wiki.mozilla.org/Labs/Skywriter/Settings#"+c.name;d+=""+c.name+" = "+c.value+""+d+" "),c.push(""+a.typed+" "),c.push("
"})}c.done(d)}};var e={name:"unset",params:[{name:"setting",type:"setting",description:"The name of the setting to return to defaults"}],description:"unset a setting entirely",exec:function(a,b,c){var d=a.settings.get(b.setting);d?(d.reset(),c.done("Reset "+d.name+" to default: "+a.settings.get(b.setting))):c.doneWithError("No setting with the name "+b.setting+".")}};var f=a("pilot/canon");b.startup=function(a,b){f.addCommand(d),f.addCommand(e)},b.shutdown=function(a,b){f.removeCommand(d),f.removeCommand(e)}}),define("pilot/console",function(a,b,c){var d=function(){};var e=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","log","profile","profileEnd","time","timeEnd","trace","warn"];typeof window==="undefined"?e.forEach(function(a){b[a]=function(){var b=Array.prototype.slice.call(arguments);var c={op:"log",method:a,args:b};postMessage(JSON.stringify(c))}}):e.forEach(function(a){window.console&&window.console[a]?b[a]=Function.prototype.bind.call(window.console[a],window.console):b[a]=d})}),define("pilot/dom",function(a,b,c){b.setText=function(a,b){a.innerText!==undefined&&(a.innerText=b),a.textContent!==undefined&&(a.textContent=b)},b.hasCssClass=function(a,b){var c=a.className.split(/\s+/g);return c.indexOf(b)!==-1},b.addCssClass=function(a,c){b.hasCssClass(a,c)||(a.className+=" "+c)},b.setCssClass=function(a,c,d){d?b.addCssClass(a,c):b.removeCssClass(a,c)},b.removeCssClass=function(a,b){var c=a.className.split(/\s+/g);while(true){var d=c.indexOf(b);if(d==-1)break;c.splice(d,1)}a.className=c.join(" ")},b.importCssString=function(a,b){b=b||document;if(b.createStyleSheet){var c=b.createStyleSheet();c.cssText=a}else{var d=b.createElement("style");d.appendChild(b.createTextNode(a)),b.getElementsByTagName("head")[0].appendChild(d)}},b.getInnerWidth=function(a){return parseInt(b.computedStyle(a,"paddingLeft"))+parseInt(b.computedStyle(a,"paddingRight"))+a.clientWidth},b.getInnerHeight=function(a){return parseInt(b.computedStyle(a,"paddingTop"))+parseInt(b.computedStyle(a,"paddingBottom"))+a.clientHeight},b.computedStyle=function(a,b){return window.getComputedStyle?(window.getComputedStyle(a,"")||{})[b]||"":a.currentStyle[b]},b.scrollbarWidth=function(){var a=document.createElement("p");a.style.width="100%",a.style.height="200px";var b=document.createElement("div");var c=b.style;c.position="absolute",c.left="-10000px",c.overflow="hidden",c.width="200px",c.height="150px",b.appendChild(a),document.body.appendChild(b);var d=a.offsetWidth;c.overflow="scroll";var e=a.offsetWidth;d==e&&(e=b.clientWidth),document.body.removeChild(b);return d-e}}),define("pilot/domtemplate",function(require,exports,module){function Templater(){this.scope=[]}Templater.prototype.processNode=function(a,b){typeof a==="string"&&(a=document.getElementById(a));if(b===null||b===undefined)b={};this.scope.push(a.nodeName+(a.id?"#"+a.id:""));try{if(a.attributes&&a.attributes.length){if(a.hasAttribute("foreach")){this.processForEach(a,b);return}if(a.hasAttribute("if"))if(!this.processIf(a,b))return;b.__element=a;var c=Array.prototype.slice.call(a.attributes);for(var d=0;d