<commit_before>define([ "UpgradeCard", "ui/UpgradeTypeUI" ], function(UpgradeCard, UpgradeTypeUI)
{
    "use strict";
    var SquadColumns = [
    {
        key: "pilot",
        label: "Pilot",
        className: "squadUIPilotName",
    },
    {
        key: "ship",
        label: "Ship",
        className: "squadUIPilotName",
    },
    {
        key: "pilotSkill",
        label: "Pilot Skill",
        className: "numberCell",
    },
    {
        key: "primaryWeapon",
        label: "Primary Weapon",
        className: "numberCell",
    },
    {
        key: "agility",
        label: "Agility",
        className: "numberCell",
    },
    {
        key: "hull",
        label: "Hull",
        className: "numberCell",
    },
    {
        key: "shield",
        label: "Shield",
        className: "numberCell",
    },
    {
        key: "squadPointCost",
        label: "Squad Points",
        className: "numberCell",
    },
    {
        key: "action",
        label: "Action",
        className: "actionCell",
    }, ];

    /*
     * Provides a user interface for a starfighter squadron.
     * 
     * @param squad Squad.
     * 
     * @param iconBase Icon base URL.
     * 
     * @param removeFunction Called after an item is removed.
     */
    var SquadUI = React.createClass(
    {
        // Factories.
        Table: React.createFactory(Reactable.Table),
        Tr: React.createFactory(Reactable.Tr),
        Td: React.createFactory(Reactable.Td),
        Tfoot: React.createFactory(Reactable.Tfoot),

        render: function()
        {
            var squad = this.props.squad;
            var self = this;

            // Assign actions.
            squad.forEach(function(token)
            {
                if (!token.removeAction)
                {
                    token.removeAction = self.createRemoveAction(token);
                }
            });

            var rows = squad.map(function(token, i)
            {
                return self.createRows(token, i);
            });
            var footer = this.Tfoot(
            {
                key: "footer",
            }, this.createTotalsRow());
            var myColumns = (this.isEditable() ? SquadColumns : SquadColumns.slice(0, SquadColumns.length - 1));

            return this.Table(
            {
                className: "squadUI",
                columns: myColumns,
            }, rows, footer);
        },

        createCell: function(key, column, value)
        {
            return this.Td(
            {
                key: key,
                className: column.className,
                column: column.key,
            }, value);
        },

        createRemoveAction: function(token)
        {
            var removeFunction = this.props.removeFunction;
            var myOnClick = function(event)
            {
                removeFunction(token);
            };
            var image = React.DOM.img(
            {
                src: iconBase + "delete.png",
            });

            return React.DOM.a(
            {
                href: "#",
                className: "removeButton",
                onClick: myOnClick,
            }, image);
        },

        createRows: function(token, i)
        {
            var answer = [];

            answer.push(this.createTokenRow(token, i));

            var upgrades = token.upgradeKeys();
            var self = this;

            upgrades.forEach(function(upgrade, j)
            {
                answer.push(self.createUpgradeRow(upgrade, j));
            });

            return answer;
        },

        createTokenRow: function(token, i)
        {
            var cells = [];
            var createCell = this.createCell;
            var j = 0;

            var pilotProps = token.pilot();
            var shipProps = pilotProps.shipTeam.ship;
            cells.push(createCell(cells.length, SquadColumns[j++], React.DOM.span(
            {
                title: pilotProps.description,
            }, pilotProps.name)));
            cells.push(createCell(cells.length, SquadColumns[j++], shipProps.name));

            var shipState = pilotProps.shipState;
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.pilotSkillValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.primaryWeaponValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.agilityValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.hullValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.shieldValue()));

            cells.push(createCell(cells.length, SquadColumns[j++], pilotProps.squadPointCost));

            var actionFunction = token.removeAction;
            cells.push(createCell(cells.length, SquadColumns[j++], actionFunction));
<commit_msg>Changed to show a ship silhouette.<commit_after>define([ "UpgradeCard", "ui/ShipSilhouetteUI", "ui/UpgradeTypeUI" ], function(UpgradeCard, ShipSilhouetteUI,
        UpgradeTypeUI)
{
    "use strict";
    var SquadColumns = [
    {
        key: "pilot",
        label: "Pilot",
        className: "squadUIPilotName",
    },
    {
        key: "ship",
        label: "Ship",
        className: "squadUIPilotName",
    },
    {
        key: "pilotSkill",
        label: "Pilot Skill",
        className: "numberCell",
    },
    {
        key: "primaryWeapon",
        label: "Primary Weapon",
        className: "numberCell",
    },
    {
        key: "agility",
        label: "Agility",
        className: "numberCell",
    },
    {
        key: "hull",
        label: "Hull",
        className: "numberCell",
    },
    {
        key: "shield",
        label: "Shield",
        className: "numberCell",
    },
    {
        key: "squadPointCost",
        label: "Squad Points",
        className: "numberCell",
    },
    {
        key: "action",
        label: "Action",
        className: "actionCell",
    }, ];

    /*
     * Provides a user interface for a starfighter squadron.
     * 
     * @param squad Squad.
     * 
     * @param iconBase Icon base URL.
     * 
     * @param removeFunction Called after an item is removed.
     */
    var SquadUI = React.createClass(
    {
        // Factories.
        Table: React.createFactory(Reactable.Table),
        Tr: React.createFactory(Reactable.Tr),
        Td: React.createFactory(Reactable.Td),
        Tfoot: React.createFactory(Reactable.Tfoot),

        render: function()
        {
            var squad = this.props.squad;

            // Assign actions.
            squad.forEach(function(token)
            {
                if (!token.removeAction)
                {
                    token.removeAction = this.createRemoveAction(token);
                }
            }, this);

            var rows = squad.map(function(token, i)
            {
                return this.createRows(token, i);
            }, this);
            var footer = this.Tfoot(
            {
                key: "footer",
            }, this.createTotalsRow());
            var myColumns = (this.isEditable() ? SquadColumns : SquadColumns.slice(0, SquadColumns.length - 1));

            return this.Table(
            {
                className: "squadUI",
                columns: myColumns,
            }, rows, footer);
        },

        createCell: function(key, column, value)
        {
            return this.Td(
            {
                key: key,
                className: column.className,
                column: column.key,
            }, value);
        },

        createRemoveAction: function(token)
        {
            var removeFunction = this.props.removeFunction;
            var myOnClick = function(event)
            {
                removeFunction(token);
            };
            var image = React.DOM.img(
            {
                src: iconBase + "delete.png",
            });

            return React.DOM.a(
            {
                href: "#",
                className: "removeButton",
                onClick: myOnClick,
            }, image);
        },

        createRows: function(token, i)
        {
            var answer = [];

            answer.push(this.createTokenRow(token, i));

            var upgrades = token.upgradeKeys();
            var self = this;

            upgrades.forEach(function(upgrade, j)
            {
                answer.push(self.createUpgradeRow(upgrade, j));
            });

            return answer;
        },

        createTokenRow: function(token, i)
        {
            var cells = [];
            var createCell = this.createCell;
            var j = 0;

            var pilotProps = token.pilot();
            var shipProps = pilotProps.shipTeam.ship;
            cells.push(createCell(cells.length, SquadColumns[j++], React.DOM.span(
            {
                title: pilotProps.description,
            }, pilotProps.name)));
            cells.push(createCell(cells.length, SquadColumns[j++], React.createElement(ShipSilhouetteUI,
            {
                shipKey: pilotProps.shipTeam.shipKey,
            })));

            var shipState = pilotProps.shipState;
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.pilotSkillValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.primaryWeaponValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.agilityValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.hullValue()));
            cells.push(createCell(cells.length, SquadColumns[j++], shipState.shieldValue()));

            cells.push(createCell(cells.length, SquadColumns[j++], pilotProps.squadPointCost));

            var actionFunction = token.removeAction;
            cells.push(createCell(cells.length, SquadColumns[j++], actionFunction));

{'fraction_non_alphanumeric': 0.12143504988410762, 'fraction_numerical': 0.0006046558500453492, 'mean_word_length': 1.5683229813664596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4326430', 'n_tokens_mistral': 2791, 'n_tokens_neox': 2662, 'n_words': 514}