<commit_before>define(["dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang"],
	function(declare, arr, lang){
	return declare(null, {
		// summary:
		//		Mixin for classes for widgets that manage a list of selected data items. Receiving class must extend
		//		dijit/_WidgetBase.

		constructor: function(){
			this.selectedItems = [];
		},

		// selectionMode: String
		//		Valid values are:
		//
		//		1. "none": No selection can be done.
		//		2. "single": Only one item can be selected at a time.
		//		3. "multiple": Several item can be selected using the control key modifier.
		//		Default value is "single".
		selectionMode: "single",

		_setSelectionModeAttr: function(value){
			if(value != "none" && value != "single" && value != "multiple"){
				throw new Error("selectionModel invalid value");
			}
			if(value != this.selectionMode){
				this.selectionMode = value;
				if(value == "none"){
					this.set("selectedItems", null);
				}else if(value == "single"){
					this.set("selectedItem", this.selectedItem); // null or last selected item
				}
			}
		},

		// selectedItem: Object
		//		In single selection mode, the selected item or in multiple selection mode the last selected item.
		//		Warning: Do not use this property directly, make sure to call set() or get() methods.
		selectedItem: null,

		_setSelectedItemAttr: function(value){
			if(this.selectedItem != value){
				this._set("selectedItem", value);
				this.set("selectedItems", value ? [value] : null);
			}
		},

		// selectedItems: Object[]
		//		The list of selected items.
		//		Warning: Do not use this property directly, make sure to call set() or get() methods.
		selectedItems: null,

		_setSelectedItemsAttr: function(value){
			var oldSelectedItems = this.selectedItems;

			this.selectedItems = value;
			this.selectedItem = null;

			if(oldSelectedItems != null && oldSelectedItems.length>0){
				this.updateRenderers(oldSelectedItems, true);
			}
			if(this.selectedItems && this.selectedItems.length>0){
				this.selectedItem = this.selectedItems[0];
				this.updateRenderers(this.selectedItems, true);
			}
		},

		_getSelectedItemsAttr: function(){
			return this.selectedItems == null ? [] : this.selectedItems.concat();
		},

		isItemSelected: function(item){
			// summary:
			//		Returns wether an item is selected or not.
			// item: Object
			//		The item to test the selection for.
			if(this.selectedItems == null || this.selectedItems.length== 0){
				return false;
			}

			return arr.some(this.selectedItems, lang.hitch(this, function(sitem){
				return this.getIdentity(sitem) == this.getIdentity(item);
			}));
		},

		getIdentity: function(item){
			// summary:
			//		This function must be implemented to return the id of a item.
			// item: Object
			//		The item to query the identity for.
		},

		setItemSelected: function(item, value){
			// summary:
			//		Change the selection state of an item.
			// item: Object
			//		The item to change the selection state for.
			// value: Boolean
			//		True to select the item, false to deselect it.

			if(this.selectionMode == "none" || item == null){
				return;
			}

			// copy is returned
			var sel = this.get("selectedItems");

			if(this.selectionMode == "single"){
				if(value){
					this.set("selectedItem", item);
				}else if(this.isItemSelected(item)){
					this.set("selectedItems", null);
				}
			}else{ // multiple
				if(value){
					if(this.isItemSelected(item)){
						return; // already selected
					}
					if(sel == null){
						sel = [item];
					}else{
						sel.unshift(item);
					}
					this.set("selectedItems", sel);
				}else{
					var res = arr.filter(sel, function(sitem){
						return sitem.id != item.id;
					});
					if(res == null || res.length == sel.length){
						return; // already not selected
					}
					this.set("selectedItems", res);
				}
			}
		},

		selectFromEvent: function(e, item, renderer, dispatch){
			// summary:
			//		Applies selection triggered by an user interaction
			// e: Event
			//		The source event of the user interaction.
			// item: Object
			//		The render item that has been selected/deselected.
			// renderer: Object
			//		The visual renderer of the selected/deselected item.
			// dispatch: Boolean
			//		Whether an event must be dispatched or not.
			// returns: Boolean
			//		Returns true if the selection has changed and false otherwise.
			// tags:
			//		protected

			if(this.selectionMode == "none"){
				return false;
			}

			var changed;
			var oldSelectedItem = this.get("selectedItem");
			var selected = item ? this.isItemSelected(item): false;

			if(item == null){
				if(!e.ctrlKey && this.selectedItem != null){
					this.set("selectedItem", null);
					changed = true;
				}
			}else if(this.selectionMode == "multiple"){
				 if(e.ctrlKey){
					this.setItemSelected(item, !selected);
					changed = true;
				}else{
					this.set("selectedItem", item);
					changed = true;
				}
			}else{ // single
				if(e.ctrlKey){
					//if the object is selected deselects it.
					this.set("selectedItem", selected ? null : item);
					changed = true;
				}else{
					if(!selected){
						this.set("selectedItem", item);
						changed = true;
					}
				}
			}

			if(dispatch && changed){
				this.dispatchSelectionChange(oldSelectedItem, this.get("selectedItem"), renderer, e);
			}

			return changed;
		},

		dispatchSelectionChange: function(oldSelectedItem, newSelectedItem, renderer, triggerEvent){
			// summary:
			//		Dispatch a selection change event.
			// oldSelectedItem: Object
			//		The previously selectedItem.
			// newSelectedItem: Object
			//		The new selectedItem.
			// renderer: Object
			//		The visual renderer of the selected/deselected item.
			// triggerEvent: Event
			//		The event that lead to the selection of the item.

			// we assume we are a WidgetBase and we have an emit method
			this.emit("selection-change", {
				oldValue: oldSelectedItem,
				newValue: newSelectedItem,
				renderer: renderer,
				triggerEvent: triggerEvent
			});
		}
	});
});
<commit_msg>rename set/isItemSelected<commit_after>define(["dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang"],
	function(declare, arr, lang){
	return declare(null, {
		// summary:
		//		Mixin for classes for widgets that manage a list of selected data items. Receiving class must extend
		//		dijit/_WidgetBase.

		constructor: function(){
			this.selectedItems = [];
		},

		// selectionMode: String
		//		Valid values are:
		//
		//		1. "none": No selection can be done.
		//		2. "single": Only one item can be selected at a time.
		//		3. "multiple": Several item can be selected using the control key modifier.
		//		Default value is "single".
		selectionMode: "single",

		_setSelectionModeAttr: function(value){
			if(value != "none" && value != "single" && value != "multiple"){
				throw new Error("selectionModel invalid value");
			}
			if(value != this.selectionMode){
				this.selectionMode = value;
				if(value == "none"){
					this.set("selectedItems", null);
				}else if(value == "single"){
					this.set("selectedItem", this.selectedItem); // null or last selected item
				}
			}
		},

		// selectedItem: Object
		//		In single selection mode, the selected item or in multiple selection mode the last selected item.
		//		Warning: Do not use this property directly, make sure to call set() or get() methods.
		selectedItem: null,

		_setSelectedItemAttr: function(value){
			if(this.selectedItem != value){
				this._set("selectedItem", value);
				this.set("selectedItems", value ? [value] : null);
			}
		},

		// selectedItems: Object[]
		//		The list of selected items.
		//		Warning: Do not use this property directly, make sure to call set() or get() methods.
		selectedItems: null,

		_setSelectedItemsAttr: function(value){
			var oldSelectedItems = this.selectedItems;

			this.selectedItems = value;
			this.selectedItem = null;

			if(oldSelectedItems != null && oldSelectedItems.length>0){
				this.updateRenderers(oldSelectedItems, true);
			}
			if(this.selectedItems && this.selectedItems.length>0){
				this.selectedItem = this.selectedItems[0];
				this.updateRenderers(this.selectedItems, true);
			}
		},

		_getSelectedItemsAttr: function(){
			return this.selectedItems == null ? [] : this.selectedItems.concat();
		},

		isSelected: function(item){
			// summary:
			//		Returns whether an item is selected or not.
			// item: Object
			//		The item to test the selection for.
			if(this.selectedItems == null || this.selectedItems.length== 0){
				return false;
			}

			return arr.some(this.selectedItems, lang.hitch(this, function(sitem){
				return this.getIdentity(sitem) == this.getIdentity(item);
			}));
		},

		getIdentity: function(item){
			// summary:
			//		This function must be implemented to return the id of a item.
			// item: Object
			//		The item to query the identity for.
		},

		setSelected: function(item, value){
			// summary:
			//		Change the selection state of an item.
			// item: Object
			//		The item to change the selection state for.
			// value: Boolean
			//		True to select the item, false to deselect it.

			if(this.selectionMode == "none" || item == null){
				return;
			}

			// copy is returned
			var sel = this.get("selectedItems");

			if(this.selectionMode == "single"){
				if(value){
					this.set("selectedItem", item);
				}else if(this.isItemSelected(item)){
					this.set("selectedItems", null);
				}
			}else{ // multiple
				if(value){
					if(this.isItemSelected(item)){
						return; // already selected
					}
					if(sel == null){
						sel = [item];
					}else{
						sel.unshift(item);
					}
					this.set("selectedItems", sel);
				}else{
					var res = arr.filter(sel, function(sitem){
						return sitem.id != item.id;
					});
					if(res == null || res.length == sel.length){
						return; // already not selected
					}
					this.set("selectedItems", res);
				}
			}
		},

		selectFromEvent: function(e, item, renderer, dispatch){
			// summary:
			//		Applies selection triggered by an user interaction
			// e: Event
			//		The source event of the user interaction.
			// item: Object
			//		The render item that has been selected/deselected.
			// renderer: Object
			//		The visual renderer of the selected/deselected item.
			// dispatch: Boolean
			//		Whether an event must be dispatched or not.
			// returns: Boolean
			//		Returns true if the selection has changed and false otherwise.
			// tags:
			//		protected

			if(this.selectionMode == "none"){
				return false;
			}

			var changed;
			var oldSelectedItem = this.get("selectedItem");
			var selected = item ? this.isItemSelected(item): false;

			if(item == null){
				if(!e.ctrlKey && this.selectedItem != null){
					this.set("selectedItem", null);
					changed = true;
				}
			}else if(this.selectionMode == "multiple"){
				 if(e.ctrlKey){
					this.setItemSelected(item, !selected);
					changed = true;
				}else{
					this.set("selectedItem", item);
					changed = true;
				}
			}else{ // single
				if(e.ctrlKey){
					//if the object is selected deselects it.
					this.set("selectedItem", selected ? null : item);
					changed = true;
				}else{
					if(!selected){
						this.set("selectedItem", item);
						changed = true;
					}
				}
			}

			if(dispatch && changed){
				this.dispatchSelectionChange(oldSelectedItem, this.get("selectedItem"), renderer, e);
			}

			return changed;
		},

		dispatchSelectionChange: function(oldSelectedItem, newSelectedItem, renderer, triggerEvent){
			// summary:
			//		Dispatch a selection change event.
			// oldSelectedItem: Object
			//		The previously selectedItem.
			// newSelectedItem: Object
			//		The new selectedItem.
			// renderer: Object
			//		The visual renderer of the selected/deselected item.
			// triggerEvent: Event
			//		The event that lead to the selection of the item.

			// we assume we are a WidgetBase and we have an emit method
			this.emit("selection-change", {
				oldValue: oldSelectedItem,
				newValue: newSelectedItem,
				renderer: renderer,
				triggerEvent: triggerEvent
			});
		}
	});
});
<|endoftext|>


<commit_before>

// Hello!
// You'll be reading this to gain a better understand of how everything here
// is coded! You've come to the right place! Let's get started right away!

// The define function lets us define "modules" or sections of the code,
// we use this to keep things neat and tidy.

// The first parameter in the define function is an array of dependences for the
// module. As you can see, we need jQuery, Lacuna, Template, Body and Library.
// These modules are then loaded and sent into the function that can be seen in
// parameter 2.
define(['jquery', 'lacuna', 'template', 'body', 'library', 'text!templates/building/planetaryCommand.tmpl'],
function($, Lacuna, Template, Body, Library, TmplBuildingPlanetaryCommand) {

    // Now we need to load the file that has all of the HTML templates we'll be
    // using within this file. Once this template has been loaded, they can be
    // accessed through the Template.read object. An example of how this loading
    // can be seen below in the getTabs function.
    Template.loadStrings(TmplBuildingPlanetaryCommand);

    // This function, at least to my way of thinking, is a JavaScript class. It
    // is what we use to represent it as a module for RequireJs to understand.
    // There's more notes on this near the bottom of the file.
    function PlanetaryCommand() {

        // Throughout the adventure that is this client, jQuery does some
        // strange things to the 'this' keyword. So, to counter that, we use
        // scope instead. The name of the variable does not matter, but we have
        // created the convention of calling it 'scope'.
        // When using scope, declare all functions and variables as children of
        // the scope object.
        var scope = this;

        // Get any additional tabs for this building (if there are none, then you
        // don't need to create this module!)
        //
        // vBuilding is the building object returned from the 'view' call to the
        // selected building.
        scope.getTabs = function(vBuilding, url) {
            console.log(scope);//debug
            // The getTabs function returns an array of tabs that will be
            // displayed in the selected building panel. The properties
            // of each object and their uses will be explain below.
            return [
                {
                    // Explains itself, it's the name label that the tab will
                    // have both in the DOM and on the screen.
                    name: 'Planet',

                    // Content is any of the HTML that can be thrown into the
                    // tab straight away, without needing to send a request.
                    // In this case, all of the data has been received in the
                    // previous server request (most likely 'view') and can be
                    // spat out onto the screen.
                    // As mentioned before, we use a template system for as
                    // much of the HTML used in the client as possible. Which
                    // ends up being about 99% of it. If we want a variable
                    // passed into that template, we can pass it in this here
                    // object. In this case, we are passing in strings and an
                    // object, both of which can be used like normal JavaScript
                    // inside the template.
                    content: Template.read.building_planetary_command_planet_tab({

                        body: Body.get,
                        result: scope.result, // For the next colony cost.
                        assetsUrl: window.assetsUrl,

                        // You can even call functions inside these templates!
                        library: Library
                    })
                },
                {
                    name: 'Abandon',
                    content: Template.read.building_planetary_command_abandon_tab({
                        name: Body.get.name
                    }),

                    // The select option, in my opinion, is the most useful of
                    // them all. :) It should be set to a function. This
                    // function is then called when the user selects this tab.
                    // Passed in as the first param of that function, is a tab
                    // object, it has a few utilities which can be used on the
                    // tab. They are covered in the scope.populatePlansTab
                    // function.
                    select: scope.setupAbandonTab
                },
                {
                    name: 'Rename',
                    content: Template.read.building_planetary_command_rename_tab(),
                    select: scope.setupRenameTab
                },
                {
                    name: 'Plans',
                    select: scope.populatePlansTab
                },
                {
                    name: 'Resources',
                    content: scope.populateResourcesTab()
                },
                {
                    name: 'Supply Chains',
                    select: scope.populateChainsTab
                }
            ];
        };

        scope.setupAbandonTab = function(tab) {
            $('#abandonPlanetButton').on('click', scope.abandonPlanet);
        };

        scope.setupRenameTab = function(tab) {
            $('#renamePlanetButton').on('click', scope.renamePlanet);
        };

        scope.populatePlansTab = function(tab) {
            var deferredViewPlans = Lacuna.send({
                module  : '/planetarycommand',
                method  : 'view_plans',
                params  : [
                    Lacuna.getSession(),
                    scope.building.id
                ]
            });

            deferredViewPlans.done(function(o) {
                if (o.result.plans.length) {

                    var content = [];

                    _.each(o.result.plans, function(plan) {
                        content.push(Template.read.building_planetary_command_plan({
                            plan: plan
                        }));
                    });

                    tab.html(Template.read.building_planetary_command_plans_heading({
                        content: content.join('')
                    }));

                }
                else {
                    tab.add(Template.read.building_planetary_command_plans_none());
                }
            });
        };

        scope.populateChainsTab = function(tab) {
            var deferedViewChains = Lacuna.send({
                module: '/planetarycommand',
                method: 'view_incoming_supply_chains',
                params: [
                    Lacuna.getSession(),
                    scope.building.id
                ]
            });

            deferedViewChains.done(function(o) {

                // Fake data to test with as a real test case can't be setup.
                o.result.supply_chains = [{
                    "id" : "id-goes-here",
                    "from_body" : {
                        "id" : "id-goes-here",
                        "name" : "Mars",
                        "x" : 0,
                        "y" : -123,
                        "image" : "station"
                    },
                    "resource_hour" : 10000000,
                    "resource_type" : 'water',
                    "percent_transferred" : 95,
                    "stalled" : 0
                }, {
                    "id" : "id-goes-here",
                    "from_body" : {
                        "id" : "id-goes-here",
                        "name" : "Mars",
                        "x" : 0,
                        "y" : -123,
                        "image" : "station"
                    },
                    "resource_hour" : 10000000,
                    "resource_type" : 'something shiny',
                    "percent_transferred" : 64,
                    "stalled" : 1
                }];//debug

                if (o.result.supply_chains.length) {
                    var content = [];

                    _.each(o.result.supply_chains, function(chain) {

                        content.push(Template.read.building_planetary_command_chain({
                            chain: chain,
                            library: Library
                        }));
                    });

                    tab.html(Template.read.building_planetary_command_chains_heading({
                        content: content.join('')
                    }));
                }
                else {
                    tab.html(Template.read.building_planetary_command_chains_none());
                }
            });
        };

        scope.populateResourcesTab = function() {
            var food = [],
                ore  = []
            ;

            // Food
            _.each(Library.foodTypes, function(type) {

                food.push(Template.read.building_planetary_command_resources_tab_row({
                    typeName: type,
                    resources: scope.result.food,
                    displayName: Library.upperFirstChar(type),
                    library: Library
                }));

            });

            // Ore
            _.each(Library.oreTypes.concat(['water', 'energy']), function(type) {

                ore.push(Template.read.building_planetary_command_resources_tab_row({
                    typeName: type,
                    resources: (type === 'water' || type === 'energy') ? scope.result.planet : scope.result.ore,
                    displayName: Library.upperFirstChar(type),
                    library: Library
                }));

            });

            return [
                // Food
                '
',
                    food.join(''),
                '
',

                // Ore
                '
',
                    ore.join(''),
                '
'
            ].join('');
        }

        // Function that makes the actual abandon call to the server.
        scope.abandonPlanet = function() {
            Lacuna.confirm(
                'Are you sure you want to abandon ' + Body.get.name + '?', // Message
                'Look out!', // Title of the Dialog.
                function(response) { // Callback fired when user makes a selection.

                if (response) {
                    var deferredAbandon = Lacuna.send({
                        module  : '/body',
                        method  : 'abandon',
                        params  : [
                            Lacuna.getSession(),
                            Body.get.id
                        ]
                    });

                    deferredAbandon.done(function(o) {
                        // TODO
                    });
                }

            });
        };

        scope.renamePlanet = function() {

            var newName = $('#renamePlanetInput').val();

            if (newName) {
                var deferredRename = Lacuna.send({
                    module  : '/body',
                    method  : 'rename',
                    params  : [
                        Lacuna.getSession(),
                        Body.get.id,
                        newName
                    ]
                });

                deferredRename.done(function(o) {
                    if (o.result === 1) {
                        $('#planetName').html(newName);
                    }
                });
            }
        };
    }

    // The define function must return what we want to be the class it
    // represents. After much experimentation, we've found that this is the
    // cleanest way to do it.
    return new PlanetaryCommand();
});
<commit_msg>Few more notes before I finish up for the night.<commit_after>

// Hello!
// You'll be reading this to gain a better understand of how everything here
// is coded! You've come to the right place! Let's get started right away!

// The define function lets us define "modules" or sections of the code,
// we use this to keep things neat and tidy.

// The first parameter in the define function is an array of dependences for the
// module. As you can see, we need jQuery, Lacuna, Template, Body and Library.
// These modules are then loaded and sent into the function that can be seen in
// parameter 2.
define(['jquery', 'lacuna', 'template', 'body', 'library', 'text!templates/building/planetaryCommand.tmpl'],
function($, Lacuna, Template, Body, Library, TmplBuildingPlanetaryCommand) {

    // Now we need to load the file that has all of the HTML templates we'll be
    // using within this file. Once this template has been loaded, they can be
    // accessed through the Template.read object. An example of how this loading
    // can be seen below in the getTabs function.
    Template.loadStrings(TmplBuildingPlanetaryCommand);

    // This function, at least to my way of thinking, is a JavaScript class. It
    // is what we use to represent it as a module for RequireJs to understand.
    // There's more notes on this near the bottom of the file.
    function PlanetaryCommand() {

        // Throughout the adventure that is this client, jQuery does some
        // strange things to the 'this' keyword. So, to counter that, we use
        // scope instead. The name of the variable does not matter, but we have
        // created the convention of calling it 'scope'.
        // When using scope, declare all functions and variables as children of
        // the scope object.
        var scope = this;

        // Get any additional tabs for this building (if there are none, then you
        // don't need to create this module!)
        //
        // vBuilding is the building object returned from the 'view' call to the
        // selected building.
        scope.getTabs = function(vBuilding, url) {

            // The getTabs function returns an array of tabs that will be
            // displayed in the selected building panel. The properties
            // of each object and their uses will be explain below.
            return [
                {
                    // Explains itself, it's the name label that the tab will
                    // have both in the DOM and on the screen.
                    name: 'Planet',

                    // Content is any of the HTML that can be thrown into the
                    // tab straight away, without needing to send a request.
                    // In this case, all of the data has been received in the
                    // previous server request (most likely 'view') and can be
                    // spat out onto the screen.
                    // As mentioned before, we use a template system for as
                    // much of the HTML used in the client as possible. Which
                    // ends up being about 99% of it. If we want a variable
                    // passed into that template, we can pass it in this here
                    // object. In this case, we are passing in strings and an
                    // object, both of which can be used like normal JavaScript
                    // inside the template.
                    content: Template.read.building_planetary_command_planet_tab({

                        body: Body.get,
                        result: scope.result, // For the next colony cost.
                        assetsUrl: window.assetsUrl,

                        // You can even call functions inside these templates!
                        library: Library
                    })
                },
                {
                    name: 'Abandon',
                    content: Template.read.building_planetary_command_abandon_tab({
                        name: Body.get.name
                    }),

                    // The select option, in my opinion, is the most useful of
                    // them all. :) It should be set to a function. This
                    // function is then called when the user selects this tab.
                    // Passed in as the first param of that function, is a tab
                    // object, it has a few utilities which can be used on the
                    // tab. They are covered in the scope.populatePlansTab
                    // function below.
                    select: scope.setupAbandonTab
                },
                {
                    name: 'Rename',
                    content: Template.read.building_planetary_command_rename_tab(),
                    select: scope.setupRenameTab
                },
                {
                    name: 'Plans',
                    select: scope.populatePlansTab
                },
                {
                    name: 'Resources',
                    content: scope.populateResourcesTab()
                },
                {
                    name: 'Supply Chains',
                    select: scope.populateChainsTab
                }
            ];
        };

        scope.setupAbandonTab = function(tab) {
            $('#abandonPlanetButton').on('click', scope.abandonPlanet);
        };

        scope.setupRenameTab = function(tab) {
            $('#renamePlanetButton').on('click', scope.renamePlanet);
        };

        scope.populatePlansTab = function(tab) {
            var deferredViewPlans = Lacuna.send({
                module  : '/planetarycommand',
                method  : 'view_plans',
                params  : [
                    Lacuna.getSession(),
                    scope.building.id
                ]
            });

            deferredViewPlans.done(function(o) {
                if (o.result.plans.length) {

                    var content = [];

                    _.each(o.result.plans, function(plan) {
                        content.push(Template.read.building_planetary_command_plan({
                            plan: plan
                        }));
                    });

                    tab.html(Template.read.building_planetary_command_plans_heading({
                        content: content.join('')
                    }));

                }
                else {
                    tab.add(Template.read.building_planetary_command_plans_none());
                }
            });
        };

        scope.populateChainsTab = function(tab) {
            var deferedViewChains = Lacuna.send({
                module: '/planetarycommand',
                method: 'view_incoming_supply_chains',
                params: [
                    Lacuna.getSession(),
                    scope.building.id
                ]
            });

            deferedViewChains.done(function(o) {

                // Fake data to test with as a real test case can't be setup.
                o.result.supply_chains = [{
                    "id" : "id-goes-here",
                    "from_body" : {
                        "id" : "id-goes-here",
                        "name" : "Mars",
                        "x" : 0,
                        "y" : -123,
                        "image" : "station"
                    },
                    "resource_hour" : 10000000,
                    "resource_type" : 'water',
                    "percent_transferred" : 95,
                    "stalled" : 0
                }, {
                    "id" : "id-goes-here",
                    "from_body" : {
                        "id" : "id-goes-here",
                        "name" : "Mars",
                        "x" : 0,
                        "y" : -123,
                        "image" : "station"
                    },
                    "resource_hour" : 10000000,
                    "resource_type" : 'something shiny',
                    "percent_transferred" : 64,
                    "stalled" : 1
                }];//debug

                if (o.result.supply_chains.length) {
                    var content = [];

                    _.each(o.result.supply_chains, function(chain) {

                        content.push(Template.read.building_planetary_command_chain({
                            chain: chain,
                            library: Library
                        }));
                    });

                    tab.html(Template.read.building_planetary_command_chains_heading({
                        content: content.join('')
                    }));
                }
                else {
                    tab.html(Template.read.building_planetary_command_chains_none());
                }
            });
        };

        scope.populateResourcesTab = function() {
            var food = [],
                ore  = []
            ;

            // Food
            _.each(Library.foodTypes, function(type) {

                food.push(Template.read.building_planetary_command_resources_tab_row({
                    typeName: type,
                    resources: scope.result.food,
                    displayName: Library.upperFirstChar(type),
                    library: Library
                }));

            });

            // Ore
            _.each(Library.oreTypes.concat(['water', 'energy']), function(type) {

                ore.push(Template.read.building_planetary_command_resources_tab_row({
                    typeName: type,
                    resources: (type === 'water' || type === 'energy') ? scope.result.planet : scope.result.ore,
                    displayName: Library.upperFirstChar(type),
                    library: Library
                }));

            });

            return [
                // Food
                '
',
                    food.join(''),
                '
',

                // Ore
                '
',
                    ore.join(''),
                '
'
            ].join('');
        }

        // Function that makes the actual abandon call to the server.
        scope.abandonPlanet = function() {
            Lacuna.confirm(
                'Are you sure you want to abandon ' + Body.get.name + '?', // Message
                'Look out!', // Title of the Dialog.
                function(response) { // Callback fired when user makes a selection.

                if (response) {
                    var deferredAbandon = Lacuna.send({
                        module  : '/body',
                        method  : 'abandon',
                        params  : [
                            Lacuna.getSession(),
                            Body.get.id
                        ]
                    });

                    deferredAbandon.done(function(o) {
                        // TODO
                    });
                }

            });
        };

        scope.renamePlanet = function() {

            var newName = $('#renamePlanetInput').val();

            if (newName) {
                var deferredRename = Lacuna.send({
                    module  : '/body',
                    method  : 'rename',
                    params  : [
                        Lacuna.getSession(),
                        Body.get.id,
                        newName
                    ]
                });

                deferredRename.done(function(o) {
                    if (o.result === 1) {
                        $('#planetName').html(newName);
                    }
                });
            }
        };
    }

    // The define function must return what we want to be the class it
    // represents. After much experimentation, we've found that this is the
    // cleanest way to do it.
    return new PlanetaryCommand();
});
<|endoftext|>


<commit_before>// Grunt software build task definitions.
/* global module:true */
module.exports = function(grunt) {
  'use strict';

  var fs = require('fs');

  var MockupGrunt = require('./bower_components/mockup-core/js/grunt'),
      requirejsOptions = require('./js/config'),
      mockup = new MockupGrunt(requirejsOptions),
      docsExtraIncludes = [];

  for (var i = 0; i < mockup.patterns.length; i = i + 1) {
    if (mockup.patterns[i].indexOf('-url') === -1) {
      docsExtraIncludes.push(mockup.patterns[i]);
      docsExtraIncludes.push('text!' + requirejsOptions.paths[mockup.patterns[i]] + '.js');
    }
  }

  mockup.registerBundle('docs', {
    less: {
      options : {
        paths : ['../../../'],
        modifyVars : {
          bowerPath: '"bower_components/"',
          mockupPath: '"patterns/"',
          mockuplessPath: '"less/"'
        }
      }
    },
    copy: {
      docs: {
        files: [
          { expand: true, src: '*.md', dest: 'docs/dev/' },
          { expand: true, src: 'bower_components/**', dest: 'docs/dev/' },
          { expand: true, src: 'index.html', dest: 'docs/dev/' },
          { expand: true, src: 'js/**', dest: 'docs/dev/' },
          { expand: true, src: 'less/**', dest: 'docs/dev/' },
          { expand: true, src: 'lib/**', dest: 'docs/dev/' },
          { expand: true, src: 'node_modules/requirejs/require.js', dest: 'docs/dev/' },
          { expand: true, src: 'patterns/**', dest: 'docs/dev/' },
          { expand: true, src: 'tests/**', dest: 'docs/dev/' },
        ]
      },
    },
    sed: {
      'docs-css': {
        path: 'docs/dev/index.html',
        pattern: 'href="docs/dev/docs.min.css"',
        replacement: 'href="docs.min.css"'
      },
      //'docs-js': {
      //  path: 'docs/dev/index.html',
      //  pattern: '<script src="node_modules/requirejs/require.js"></script>\n  <script src="js/config.js"></script>\n  <script>\n    window.DEBUG = true;\n    require\\(\\[\'mockup-bundles-docs\'\\]\\);\n  </script>',
      //  replacement: '<script src="docs.min.js"></script>'
      //},
      'docs-legacy-js': {
        path: 'docs/dev/index.html',
        pattern: '<script src="bower_components/es5-shim/es5-shim.js"></script>\n    <script src="bower_components/es5-shim/es5-sham.js"></script>\n    <script src="bower_components/console-polyfill/index.js"></script>',
        replacement: '<script src="docs-legacy.js"></script>'
      },
      'docs-catalogurl': {
        path: 'docs/dev/index.html',
        pattern: 'data-i18ncatalogurl="/tests/json/i18n.json"',
        replacement: 'data-i18ncatalogurl="/mockup/dev/tests/json/i18n.json"',
      }
    },
  }, {
    path: 'docs/dev/',
    url: 'docs',
    extraInclude: docsExtraIncludes,
  }, ['requirejs', 'uglify', 'less', 'copy', 'sed']);

  mockup.registerBundle('structure', {}, { url: '++resource++wildcard.foldercontents-structure' });
  mockup.registerBundle('filemanager', {}, { url: '++resource++plone.resourceeditor-filemanager' });
  mockup.registerBundle('resourceregistry');
  mockup.registerBundle('plone', {}, { path: 'build/', url: '++resource++plone' });
  mockup.registerBundle('widgets', {}, { path: 'build/', url: '++resource++plone.app.widgets' });

  mockup.initGrunt(grunt, {
    sed: {
      bootstrap: {
        path: '../node_modules/lcov-result-merger/index.js',
        pattern: 'throw new Error\\(\'Unknown Prefix ',
        replacement: '//throw// new Error(\'Unknown Prefix '
      }
    }
  });

  grunt.registerTask('i18n-dump', 'Dump i18n file for widgets', function(){
    var output = '# Gettext Message File for Plone mockup\n' +
                 'msgid ""\n' +
                 'msgstr ""\n' +
                 '"Project-Id-Version: mockup\\n"\n' +
                 '"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"\n' +
                 '"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"\n' +
                 '"MIME-Version: 1.0\\n"\n' +
                 '"Content-Type: text/plain; charset=utf-8\\n"\n' +
                 '"Content-Transfer-Encoding: 8bit\\n"\n' +
                 '"Plural-Forms: nplurals=1; plural=0;\\n"\n' +
                 '"Language-Code: en\\n"\n' +
                 '"Language-Name: English\\n"\n' +
                 '"Preferred-Encodings: utf-8\\n"\n' +
                 '"Domain: widgets\\n"\n\n';

    var okayFiles = ['xml', 'js', 'htm', 'html'];
    var found = [];
    var checkFile = function(filepath){
      var split = filepath.split('.');
      if(okayFiles.indexOf(split[split.length - 1]) === -1){
        return;
      }
      console.log('reading file: ' + filepath);
      var file = fs.readFileSync(filepath, {encoding: 'utf-8'});
      var re = /_t\(('|")([\s\d\w…\.\,\!\+\\\/]+)('|")(,\W{.*})?\)/g;
      var m;
      while (m = re.exec(file)) {
        if (m) {
          re.lastIndex = Math.max(m.index+1, re.lastIndex + 1);
          if(found.indexOf(m[2]) === -1){
            output += '#: ' + filepath + '\n' +
                      'msgid "' + m[2] + '"\n' +
                      'msgstr ""\n\n';
            found.push(m[2]);
          }
        }
      }
    };
    var checkDir = function(path){
      console.log('read folder: ' + path);
      var files = fs.readdirSync(path);
      files.forEach(function(filename){
        if(filename === 'bower_components' || filename === 'node_modules'){
          return;
        }
        var stats = fs.statSync(path + filename);
        if(stats.isDirectory()){
          checkDir(path + filename + '/');
        }else{
          checkFile(path + filename);
        }
      });
    };
    checkDir('./');
    fs.writeFileSync('../widgets.pot', output);
  });

};
<commit_msg>fix jshint errorg<commit_after>// Grunt software build task definitions.
/* global module:true */
module.exports = function(grunt) {
  'use strict';

  var fs = require('fs');

  var MockupGrunt = require('./bower_components/mockup-core/js/grunt'),
      requirejsOptions = require('./js/config'),
      mockup = new MockupGrunt(requirejsOptions),
      docsExtraIncludes = [];

  for (var i = 0; i < mockup.patterns.length; i = i + 1) {
    if (mockup.patterns[i].indexOf('-url') === -1) {
      docsExtraIncludes.push(mockup.patterns[i]);
      docsExtraIncludes.push('text!' + requirejsOptions.paths[mockup.patterns[i]] + '.js');
    }
  }

  mockup.registerBundle('docs', {
    less: {
      options : {
        paths : ['../../../'],
        modifyVars : {
          bowerPath: '"bower_components/"',
          mockupPath: '"patterns/"',
          mockuplessPath: '"less/"'
        }
      }
    },
    copy: {
      docs: {
        files: [
          { expand: true, src: '*.md', dest: 'docs/dev/' },
          { expand: true, src: 'bower_components/**', dest: 'docs/dev/' },
          { expand: true, src: 'index.html', dest: 'docs/dev/' },
          { expand: true, src: 'js/**', dest: 'docs/dev/' },
          { expand: true, src: 'less/**', dest: 'docs/dev/' },
          { expand: true, src: 'lib/**', dest: 'docs/dev/' },
          { expand: true, src: 'node_modules/requirejs/require.js', dest: 'docs/dev/' },
          { expand: true, src: 'patterns/**', dest: 'docs/dev/' },
          { expand: true, src: 'tests/**', dest: 'docs/dev/' },
        ]
      },
    },
    sed: {
      'docs-css': {
        path: 'docs/dev/index.html',
        pattern: 'href="docs/dev/docs.min.css"',
        replacement: 'href="docs.min.css"'
      },
      //'docs-js': {
      //  path: 'docs/dev/index.html',
      //  pattern: '<script src="node_modules/requirejs/require.js"></script>\n  <script src="js/config.js"></script>\n  <script>\n    window.DEBUG = true;\n    require\\(\\[\'mockup-bundles-docs\'\\]\\);\n  </script>',
      //  replacement: '<script src="docs.min.js"></script>'
      //},
      'docs-legacy-js': {
        path: 'docs/dev/index.html',
        pattern: '<script src="bower_components/es5-shim/es5-shim.js"></script>\n    <script src="bower_components/es5-shim/es5-sham.js"></script>\n    <script src="bower_components/console-polyfill/index.js"></script>',
        replacement: '<script src="docs-legacy.js"></script>'
      },
      'docs-catalogurl': {
        path: 'docs/dev/index.html',
        pattern: 'data-i18ncatalogurl="/tests/json/i18n.json"',
        replacement: 'data-i18ncatalogurl="/mockup/dev/tests/json/i18n.json"',
      }
    },
  }, {
    path: 'docs/dev/',
    url: 'docs',
    extraInclude: docsExtraIncludes,
  }, ['requirejs', 'uglify', 'less', 'copy', 'sed']);

  mockup.registerBundle('structure', {}, { url: '++resource++wildcard.foldercontents-structure' });
  mockup.registerBundle('filemanager', {}, { url: '++resource++plone.resourceeditor-filemanager' });
  mockup.registerBundle('resourceregistry');
  mockup.registerBundle('plone', {}, { path: 'build/', url: '++resource++plone' });
  mockup.registerBundle('widgets', {}, { path: 'build/', url: '++resource++plone.app.widgets' });

  mockup.initGrunt(grunt, {
    sed: {
      bootstrap: {
        path: '../node_modules/lcov-result-merger/index.js',
        pattern: 'throw new Error\\(\'Unknown Prefix ',
        replacement: '//throw// new Error(\'Unknown Prefix '
      }
    }
  });

  grunt.registerTask('i18n-dump', 'Dump i18n file for widgets', function(){
    var output = '# Gettext Message File for Plone mockup\n' +
                 'msgid ""\n' +
                 'msgstr ""\n' +
                 '"Project-Id-Version: mockup\\n"\n' +
                 '"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"\n' +
                 '"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\\n"\n' +
                 '"MIME-Version: 1.0\\n"\n' +
                 '"Content-Type: text/plain; charset=utf-8\\n"\n' +
                 '"Content-Transfer-Encoding: 8bit\\n"\n' +
                 '"Plural-Forms: nplurals=1; plural=0;\\n"\n' +
                 '"Language-Code: en\\n"\n' +
                 '"Language-Name: English\\n"\n' +
                 '"Preferred-Encodings: utf-8\\n"\n' +
                 '"Domain: widgets\\n"\n\n';

    var okayFiles = ['xml', 'js', 'htm', 'html'];
    var found = [];
    var checkFile = function(filepath){
      var split = filepath.split('.');
      if(okayFiles.indexOf(split[split.length - 1]) === -1){
        return;
      }
      console.log('reading file: ' + filepath);
      var file = fs.readFileSync(filepath, {encoding: 'utf-8'});
      var re = /_t\(('|")([\s\d\w…\.\,\!\+\\\/]+)('|")(,\W{.*})?\)/g;
      var m = re.exec(file);
      while (m) {
        if (m) {
          re.lastIndex = Math.max(m.index+1, re.lastIndex + 1);
          if(found.indexOf(m[2]) === -1){
            output += '#: ' + filepath + '\n' +
                      'msgid "' + m[2] + '"\n' +
                      'msgstr ""\n\n';
            found.push(m[2]);
          }
          m = re.exec(file);
        }
      }
    };
    var checkDir = function(path){
      console.log('read folder: ' + path);
      var files = fs.readdirSync(path);
      files.forEach(function(filename){
        if(filename === 'bower_components' || filename === 'node_modules'){
          return;
        }
        var stats = fs.statSync(path + filename);
        if(stats.isDirectory()){
          checkDir(path + filename + '/');
        }else{
          checkFile(path + filename);
        }
      });
    };
    checkDir('./');
    fs.writeFileSync('../widgets.pot', output);
  });

};
<|endoftext|>


<commit_before>/* RequireJS configuration
 */

/* global module:true */

(function() {
  'use strict';

  var tinymcePlugins = [
    'advlist', 'anchor', 'autolink', 'autoresize', 'autosave', 'bbcode',
    'charmap', 'code', 'colorpicker', 'contextmenu', 'directionality',
    'emoticons', 'fullpage', 'fullscreen', 'hr', 'image', 'importcss',
    'insertdatetime', 'layer', 'legacyoutput', 'link', 'lists', 'media',
    'nonbreaking', 'noneditable', 'pagebreak', 'paste', 'preview', 'print',
    'save', 'searchreplace', 'spellchecker', 'tabfocus', 'table', 'template',
    'textcolor', 'textpattern', 'visualblocks', 'visualchars', 'wordcount'
  ];

  var requirejsOptions = {
    baseUrl: './',
    optimize: 'none',
    paths: {
      'JSXTransformer': 'bower_components/react/JSXTransformer',
      'ace': 'bower_components/ace-builds/src/ace',
      'ace-mode-css': 'bower_components/ace-builds/src/mode-css',
      'ace-mode-javascript': 'bower_components/ace-builds/src/mode-javascript',
      'ace-mode-text': 'bower_components/ace-builds/src/mode-text',
      'ace-theme-monokai': 'bower_components/ace-builds/src/theme-monokai',
      'backbone': 'bower_components/backbone/backbone',
      'backbone.paginator': 'bower_components/backbone.paginator/lib/backbone.paginator',
      'bootstrap-alert': 'bower_components/bootstrap/js/alert',
      'bootstrap-collapse': 'bower_components/bootstrap/js/collapse',
      'bootstrap-dropdown': 'bower_components/bootstrap/js/dropdown',
      'bootstrap-tooltip': 'bower_components/bootstrap/js/tooltip',
      'bootstrap-transition': 'bower_components/bootstrap/js/transition',
      'docs-contribute': 'CONTRIBUTE.md',
      'docs-getting-started': 'GETTING_STARTED.md',
      'docs-learn': 'LEARN.md',
      'dropzone': 'bower_components/dropzone/downloads/dropzone-amd-module',
      'expect': 'bower_components/expect/index',
      'jqtree': 'bower_components/jqtree/tree.jquery',
      'jquery': 'bower_components/jquery/dist/jquery',
      'jquery.cookie': 'bower_components/jquery.cookie/jquery.cookie',
      'jquery.event.drag': 'lib/jquery.event.drag',
      'jquery.event.drop': 'lib/jquery.event.drop',
      'jquery.form': 'bower_components/jquery-form/jquery.form',
      'translate': 'js/i18n-wrapper',
      'marked': 'bower_components/marked/lib/marked',
      'mockup-bundles-docs': 'js/bundles/docs',
      'mockup-bundles-filemanager': 'js/bundles/filemanager',
      'mockup-bundles-plone': 'js/bundles/plone',
      'mockup-bundles-resourceregistry': 'js/bundles/resourceregistry',
      'mockup-bundles-structure': 'js/bundles/structure',
      'mockup-bundles-tiles': 'js/bundles/widgets',
      'mockup-bundles-widgets': 'js/bundles/widgets',
      'mockup-docs': 'bower_components/mockup-core/js/docs/app',
      'mockup-docs-navigation': 'bower_components/mockup-core/js/docs/navigation',
      'mockup-docs-page': 'bower_components/mockup-core/js/docs/page',
      'mockup-docs-pattern': 'bower_components/mockup-core/js/docs/pattern',
      'mockup-docs-view': 'bower_components/mockup-core/js/docs/view',
      'mockup-fakeserver': 'tests/fakeserver',
      'mockup-i18n': 'js/i18n',
      'mockup-patterns-accessibility': 'patterns/accessibility/pattern',
      'mockup-patterns-autotoc': 'patterns/autotoc/pattern',
      'mockup-patterns-backdrop': 'patterns/backdrop/pattern',
      'mockup-patterns-base': 'bower_components/mockup-core/js/pattern',
      'mockup-patterns-cookietrigger': 'patterns/cookietrigger/pattern',
      'mockup-patterns-eventedit': 'patterns/eventedit/pattern',
      'mockup-patterns-filemanager': 'patterns/filemanager/pattern',
      'mockup-patterns-filemanager-url': 'patterns/filemanager',
      'mockup-patterns-formautofocus': 'patterns/formautofocus/pattern',
      'mockup-patterns-formunloadalert': 'patterns/formunloadalert/pattern',
      'mockup-patterns-inlinevalidation': 'patterns/inlinevalidation/pattern',
      'mockup-patterns-markspeciallinks': 'patterns/markspeciallinks/pattern',
      'mockup-patterns-modal': 'patterns/modal/pattern',
      'mockup-patterns-moment': 'patterns/moment/pattern',
      'mockup-patterns-pickadate': 'patterns/pickadate/pattern',
      'mockup-patterns-preventdoublesubmit': 'patterns/preventdoublesubmit/pattern',
      'mockup-patterns-querystring': 'patterns/querystring/pattern',
      'mockup-patterns-relateditems': 'patterns/relateditems/pattern',
      'mockup-patterns-resourceregistry': 'patterns/resourceregistry/pattern',
      'mockup-patterns-resourceregistry-url': 'patterns/resourceregistry',
      'mockup-patterns-select2': 'patterns/select2/pattern',
      'mockup-patterns-sortable': 'patterns/sortable/pattern',
      'mockup-patterns-structure': 'patterns/structure/pattern',
      'mockup-patterns-structure-url': 'patterns/structure',
      'mockup-patterns-tablesorter': 'patterns/tablesorter/pattern',
      'mockup-patterns-textareamimetypeselector': 'patterns/textareamimetypeselector/pattern',
      'mockup-patterns-texteditor': 'patterns/texteditor/pattern',
      'mockup-patterns-thememapper': 'patterns/thememapper/pattern',
      'mockup-patterns-thememapper-url': 'patterns/thememapper',
      'mockup-patterns-tinymce': 'patterns/tinymce/pattern',
      'mockup-patterns-tinymce-url': 'patterns/tinymce',
      'mockup-patterns-toggle': 'patterns/toggle/pattern',
      'mockup-patterns-tooltip': 'patterns/tooltip/pattern',
      'mockup-patterns-tree': 'patterns/tree/pattern',
      'mockup-patterns-upload': 'patterns/upload/pattern',
      'mockup-patterns-upload-url': 'patterns/upload',
      'mockup-patterns-passwordstrength': 'patterns/passwordstrength/pattern',
      'mockup-patterns-passwordstrength-url': 'patterns/passwordstrength',
      'mockup-registry': 'bower_components/patternslib/src/core/registry',
      'mockup-router': 'js/router',
      'mockup-ui-url': 'js/ui',
      'mockup-utils': 'js/utils',
      'moment': 'bower_components/moment/moment',
      'picker': 'bower_components/pickadate/lib/picker',
      'picker.date': 'bower_components/pickadate/lib/picker.date',
      'picker.time': 'bower_components/pickadate/lib/picker.time',
      'react': 'bower_components/react/react',
      'select2': 'bower_components/select2/select2',
      'sinon': 'bower_components/sinonjs/sinon',
      'text': 'bower_components/requirejs-text/text',
      'tinymce': 'bower_components/tinymce-builded/js/tinymce/tinymce',
      'tinymce-modern-theme': 'bower_components/tinymce-builded/js/tinymce/themes/modern/theme',
      'underscore': 'bower_components/lodash/dist/lodash.underscore',

      // Patternslib
      "pat-compat": "bower_components/patternslib/src/core/compat",
      "pat-jquery-ext": "bower_components/patternslib/src/core/jquery-ext",
      "pat-logger": "bower_components/patternslib/src/core/logger",
      "pat-registry": "bower_components/patternslib/src/core/registry",
      "pat-utils": "bower_components/patternslib/src/core/utils",
      "logging": "bower_components/logging/src/logging"
    },
    shim: {
      'JSXTransformer': { exports: 'window.JSXTransformer' },
      'backbone': { exports: 'window.Backbone', deps: ['underscore', 'jquery'] },
      'backbone.paginator': { exports: 'window.Backbone.Paginator', deps: ['backbone'] },
      'bootstrap-alert': { deps: ['jquery'] },
      'bootstrap-collapse': {exports: 'window.jQuery.fn.collapse.Constructor', deps: ['jquery']},
      'bootstrap-dropdown': { deps: ['jquery'] },
      'bootstrap-tooltip': { deps: ['jquery'] },
      'bootstrap-transition': {exports: 'window.jQuery.support.transition', deps: ['jquery']},
      'expect': {exports: 'window.expect'},
      'jqtree': { deps: ['jquery'] },
      'jquery.cookie': { deps: ['jquery'] },
      'jquery.event.drag': { deps: ['jquery'] },
      'jquery.event.drop': { deps: ['jquery'], exports: '$.drop' },
      'picker.date': { deps: [ 'picker' ] },
      'picker.time': { deps: [ 'picker' ] },
      'sinon': {exports: 'window.sinon'},
      'tinymce': { exports: 'window.tinyMCE', init: function () { this.tinyMCE.DOM.events.domLoaded = true; return this.tinyMCE; }},
      'tinymce-modern-theme': { deps: ['tinymce'] },
      'underscore': { exports: 'window._' }
    },
    wrapShim: true
  };
  for(var i=0; i<tinymcePlugins.length; i=i+1){
    var plugin = tinymcePlugins[i];
    requirejsOptions.paths['tinymce-' + plugin] = 'bower_components/tinymce-builded/js/tinymce/plugins/' + plugin + '/plugin';
    requirejsOptions.shim['tinymce-' + plugin] = {
      deps: ['tinymce']
    };
  }

  if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
    module.exports = requirejsOptions;
  }
  if (typeof requirejs !== 'undefined' && requirejs.config) {
    requirejs.config(requirejsOptions);
  }

}());
<commit_msg>Restore mockup-registry.<commit_after>/* RequireJS configuration
 */

/* global module:true */

(function() {
  'use strict';

  var tinymcePlugins = [
    'advlist', 'anchor', 'autolink', 'autoresize', 'autosave', 'bbcode',
    'charmap', 'code', 'colorpicker', 'contextmenu', 'directionality',
    'emoticons', 'fullpage', 'fullscreen', 'hr', 'image', 'importcss',
    'insertdatetime', 'layer', 'legacyoutput', 'link', 'lists', 'media',
    'nonbreaking', 'noneditable', 'pagebreak', 'paste', 'preview', 'print',
    'save', 'searchreplace', 'spellchecker', 'tabfocus', 'table', 'template',
    'textcolor', 'textpattern', 'visualblocks', 'visualchars', 'wordcount'
  ];

  var requirejsOptions = {
    baseUrl: './',
    optimize: 'none',
    paths: {
      'JSXTransformer': 'bower_components/react/JSXTransformer',
      'ace': 'bower_components/ace-builds/src/ace',
      'ace-mode-css': 'bower_components/ace-builds/src/mode-css',
      'ace-mode-javascript': 'bower_components/ace-builds/src/mode-javascript',
      'ace-mode-text': 'bower_components/ace-builds/src/mode-text',
      'ace-theme-monokai': 'bower_components/ace-builds/src/theme-monokai',
      'backbone': 'bower_components/backbone/backbone',
      'backbone.paginator': 'bower_components/backbone.paginator/lib/backbone.paginator',
      'bootstrap-alert': 'bower_components/bootstrap/js/alert',
      'bootstrap-collapse': 'bower_components/bootstrap/js/collapse',
      'bootstrap-dropdown': 'bower_components/bootstrap/js/dropdown',
      'bootstrap-tooltip': 'bower_components/bootstrap/js/tooltip',
      'bootstrap-transition': 'bower_components/bootstrap/js/transition',
      'docs-contribute': 'CONTRIBUTE.md',
      'docs-getting-started': 'GETTING_STARTED.md',
      'docs-learn': 'LEARN.md',
      'dropzone': 'bower_components/dropzone/downloads/dropzone-amd-module',
      'expect': 'bower_components/expect/index',
      'jqtree': 'bower_components/jqtree/tree.jquery',
      'jquery': 'bower_components/jquery/dist/jquery',
      'jquery.cookie': 'bower_components/jquery.cookie/jquery.cookie',
      'jquery.event.drag': 'lib/jquery.event.drag',
      'jquery.event.drop': 'lib/jquery.event.drop',
      'jquery.form': 'bower_components/jquery-form/jquery.form',
      'translate': 'js/i18n-wrapper',
      'marked': 'bower_components/marked/lib/marked',
      'mockup-bundles-docs': 'js/bundles/docs',
      'mockup-bundles-filemanager': 'js/bundles/filemanager',
      'mockup-bundles-plone': 'js/bundles/plone',
      'mockup-bundles-resourceregistry': 'js/bundles/resourceregistry',
      'mockup-bundles-structure': 'js/bundles/structure',
      'mockup-bundles-tiles': 'js/bundles/widgets',
      'mockup-bundles-widgets': 'js/bundles/widgets',
      'mockup-docs': 'bower_components/mockup-core/js/docs/app',
      'mockup-docs-navigation': 'bower_components/mockup-core/js/docs/navigation',
      'mockup-docs-page': 'bower_components/mockup-core/js/docs/page',
      'mockup-docs-pattern': 'bower_components/mockup-core/js/docs/pattern',
      'mockup-docs-view': 'bower_components/mockup-core/js/docs/view',
      'mockup-fakeserver': 'tests/fakeserver',
      'mockup-i18n': 'js/i18n',
      'mockup-patterns-accessibility': 'patterns/accessibility/pattern',
      'mockup-patterns-autotoc': 'patterns/autotoc/pattern',
      'mockup-patterns-backdrop': 'patterns/backdrop/pattern',
      'mockup-patterns-base': 'bower_components/mockup-core/js/pattern',
      'mockup-patterns-cookietrigger': 'patterns/cookietrigger/pattern',
      'mockup-patterns-eventedit': 'patterns/eventedit/pattern',
      'mockup-patterns-filemanager': 'patterns/filemanager/pattern',
      'mockup-patterns-filemanager-url': 'patterns/filemanager',
      'mockup-patterns-formautofocus': 'patterns/formautofocus/pattern',
      'mockup-patterns-formunloadalert': 'patterns/formunloadalert/pattern',
      'mockup-patterns-inlinevalidation': 'patterns/inlinevalidation/pattern',
      'mockup-patterns-markspeciallinks': 'patterns/markspeciallinks/pattern',
      'mockup-patterns-modal': 'patterns/modal/pattern',
      'mockup-patterns-moment': 'patterns/moment/pattern',
      'mockup-patterns-pickadate': 'patterns/pickadate/pattern',
      'mockup-patterns-preventdoublesubmit': 'patterns/preventdoublesubmit/pattern',
      'mockup-patterns-querystring': 'patterns/querystring/pattern',
      'mockup-patterns-relateditems': 'patterns/relateditems/pattern',
      'mockup-patterns-resourceregistry': 'patterns/resourceregistry/pattern',
      'mockup-patterns-resourceregistry-url': 'patterns/resourceregistry',
      'mockup-patterns-select2': 'patterns/select2/pattern',
      'mockup-patterns-sortable': 'patterns/sortable/pattern',
      'mockup-patterns-structure': 'patterns/structure/pattern',
      'mockup-patterns-structure-url': 'patterns/structure',
      'mockup-patterns-tablesorter': 'patterns/tablesorter/pattern',
      'mockup-patterns-textareamimetypeselector': 'patterns/textareamimetypeselector/pattern',
      'mockup-patterns-texteditor': 'patterns/texteditor/pattern',
      'mockup-patterns-thememapper': 'patterns/thememapper/pattern',
      'mockup-patterns-thememapper-url': 'patterns/thememapper',
      'mockup-patterns-tinymce': 'patterns/tinymce/pattern',
      'mockup-patterns-tinymce-url': 'patterns/tinymce',
      'mockup-patterns-toggle': 'patterns/toggle/pattern',
      'mockup-patterns-tooltip': 'patterns/tooltip/pattern',
      'mockup-patterns-tree': 'patterns/tree/pattern',
      'mockup-patterns-upload': 'patterns/upload/pattern',
      'mockup-patterns-upload-url': 'patterns/upload',
      'mockup-patterns-passwordstrength': 'patterns/passwordstrength/pattern',
      'mockup-patterns-passwordstrength-url': 'patterns/passwordstrength',
      'mockup-registry': 'bower_components/mockup-core/js/registry',
      'mockup-router': 'js/router',
      'mockup-ui-url': 'js/ui',
      'mockup-utils': 'js/utils',
      'moment': 'bower_components/moment/moment',
      'picker': 'bower_components/pickadate/lib/picker',
      'picker.date': 'bower_components/pickadate/lib/picker.date',
      'picker.time': 'bower_components/pickadate/lib/picker.time',
      'react': 'bower_components/react/react',
      'select2': 'bower_components/select2/select2',
      'sinon': 'bower_components/sinonjs/sinon',
      'text': 'bower_components/requirejs-text/text',
      'tinymce': 'bower_components/tinymce-builded/js/tinymce/tinymce',
      'tinymce-modern-theme': 'bower_components/tinymce-builded/js/tinymce/themes/modern/theme',
      'underscore': 'bower_components/lodash/dist/lodash.underscore',

      // Patternslib
      "pat-compat": "bower_components/patternslib/src/core/compat",
      "pat-jquery-ext": "bower_components/patternslib/src/core/jquery-ext",
      "pat-logger": "bower_components/patternslib/src/core/logger",
      "pat-registry": "bower_components/patternslib/src/core/registry",
      "pat-utils": "bower_components/patternslib/src/core/utils",
      "logging": "bower_components/logging/src/logging"
    },
    shim: {
      'JSXTransformer': { exports: 'window.JSXTransformer' },
      'backbone': { exports: 'window.Backbone', deps: ['underscore', 'jquery'] },
      'backbone.paginator': { exports: 'window.Backbone.Paginator', deps: ['backbone'] },
      'bootstrap-alert': { deps: ['jquery'] },
      'bootstrap-collapse': {exports: 'window.jQuery.fn.collapse.Constructor', deps: ['jquery']},
      'bootstrap-dropdown': { deps: ['jquery'] },
      'bootstrap-tooltip': { deps: ['jquery'] },
      'bootstrap-transition': {exports: 'window.jQuery.support.transition', deps: ['jquery']},
      'expect': {exports: 'window.expect'},
      'jqtree': { deps: ['jquery'] },
      'jquery.cookie': { deps: ['jquery'] },
      'jquery.event.drag': { deps: ['jquery'] },
      'jquery.event.drop': { deps: ['jquery'], exports: '$.drop' },
      'picker.date': { deps: [ 'picker' ] },
      'picker.time': { deps: [ 'picker' ] },
      'sinon': {exports: 'window.sinon'},
      'tinymce': { exports: 'window.tinyMCE', init: function () { this.tinyMCE.DOM.events.domLoaded = true; return this.tinyMCE; }},
      'tinymce-modern-theme': { deps: ['tinymce'] },
      'underscore': { exports: 'window._' }
    },
    wrapShim: true
  };
  for(var i=0; i<tinymcePlugins.length; i=i+1){
    var plugin = tinymcePlugins[i];
    requirejsOptions.paths['tinymce-' + plugin] = 'bower_components/tinymce-builded/js/tinymce/plugins/' + plugin + '/plugin';
    requirejsOptions.shim['tinymce-' + plugin] = {
      deps: ['tinymce']
    };
  }

  if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
    module.exports = requirejsOptions;
  }
  if (typeof requirejs !== 'undefined' && requirejs.config) {
    requirejs.config(requirejsOptions);
  }

}());
<|endoftext|>


<commit_before>const queries = require('../db/queries');
const utils = require('../utils');

const attributes = ['id', 'performanceId', 'userNameNumber', 'spotId'];

class Challenge {

  static getAttributes() {
    return attributes;
  }

  static getIdName() {
    return 'id';
  }

  static getTableName() {
    return 'challenges';
  }

  create(userId, spotId, performanceId) {
    const sql = 'SELECT make_challenge($1, $2, $3)';

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();
      let returnCode;

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [userId, performanceId, spotId]);

      query.on('row', ({ make_challenge }) => {
        returnCode = parseInt(make_challenge, 10);
      });
      query.on('end', () => {
        client.end();
        return returnCode === 0 ? resolve() : reject(returnCode);
      });
      query.on('error', (err) => {
        client.end();
        reject(err);
      });
    });
  }

  findAllChallengeablePeopleForUser(user, performanceId) {
    // eslint-disable-next-line
    const sql = queries.challengeablePeople;

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();
      const users = [];

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [user.instrument, user.part, user.spotId, user.nameNumber, performanceId]);

      query.on('row', (dbUser) => users.push(this.parseChallengeAblePerson(dbUser)));
      query.on('end', () => {
        client.end();
        resolve(users);
      });
      query.on('error', (err) => reject(err));
    });
  }

  findAllForPerformanceCSV(performanceId) {
    const sql = queries.challengesForCSV;

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();
      const challenges = [];

      client.connect();
      client.on('error', err => reject(err));

      const query = client.query(sql, [performanceId]);

      query.on('row', challenge => challenges.push(challenge));
      query.on('end', () => {
        client.end();
        resolve(challenges);
      });
      query.on('error', err => {
        client.end();
        reject(err);
      });
    });
  }

  findForUser(nameNumber) {
    const sql = 'SELECT * FROM challenges AS C, performances AS P WHERE userNameNumber = $1 AND C.performanceId = P.id ORDER BY C.id LIMIT 1';

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [nameNumber]);

      query.on('row', (result) => {
        client.end();
        resolve(this.parseChallenge(result));
      });
      query.on('end', () => {
        client.end();
        resolve(null);
      });
      query.on('error', (err) => {
        client.end();
        reject(err);
      });
    });
  }

  parseChallenge(challenge) {
    return {
      spotId: challenge.spotid,
      performanceName: challenge.name
    };
  }

  parseChallengeAblePerson(challenge) {
    return {
      challengedCount: challenge.challengedcount,
      challengeFull: challenge.open ? challenge.challengedcount === 2 : challenge.challengedcount === 1,
      name: challenge.name,
      spotOpen: challenge.open,
      spotId: challenge.spotid
    };
  }
}

module.exports = Challenge;
<commit_msg>Models: check for undefined performanceId for challengeable people query<commit_after>const queries = require('../db/queries');
const utils = require('../utils');

const attributes = ['id', 'performanceId', 'userNameNumber', 'spotId'];

class Challenge {

  static getAttributes() {
    return attributes;
  }

  static getIdName() {
    return 'id';
  }

  static getTableName() {
    return 'challenges';
  }

  create(userId, spotId, performanceId) {
    const sql = 'SELECT make_challenge($1, $2, $3)';

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();
      let returnCode;

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [userId, performanceId, spotId]);

      query.on('row', ({ make_challenge }) => {
        returnCode = parseInt(make_challenge, 10);
      });
      query.on('end', () => {
        client.end();
        return returnCode === 0 ? resolve() : reject(returnCode);
      });
      query.on('error', (err) => {
        client.end();
        reject(err);
      });
    });
  }

  findAllChallengeablePeopleForUser(user, performanceId) {
    // eslint-disable-next-line
    const sql = queries.challengeablePeople;

    return new Promise((resolve, reject) => {
      if (!performanceId) {
        resolve(null);
      }

      const client = utils.db.createClient();
      const users = [];

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [user.instrument, user.part, user.spotId, user.nameNumber, performanceId]);

      query.on('row', (dbUser) => users.push(this.parseChallengeAblePerson(dbUser)));
      query.on('end', () => {
        client.end();
        resolve(users);
      });
      query.on('error', (err) => reject(err));
    });
  }

  findAllForPerformanceCSV(performanceId) {
    const sql = queries.challengesForCSV;

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();
      const challenges = [];

      client.connect();
      client.on('error', err => reject(err));

      const query = client.query(sql, [performanceId]);

      query.on('row', challenge => challenges.push(challenge));
      query.on('end', () => {
        client.end();
        resolve(challenges);
      });
      query.on('error', err => {
        client.end();
        reject(err);
      });
    });
  }

  findForUser(nameNumber) {
    const sql = 'SELECT * FROM challenges AS C, performances AS P WHERE userNameNumber = $1 AND C.performanceId = P.id ORDER BY C.id LIMIT 1';

    return new Promise((resolve, reject) => {
      const client = utils.db.createClient();

      client.connect();
      client.on('error', (err) => reject(err));

      const query = client.query(sql, [nameNumber]);

      query.on('row', (result) => {
        client.end();
        resolve(this.parseChallenge(result));
      });
      query.on('end', () => {
        client.end();
        resolve(null);
      });
      query.on('error', (err) => {
        client.end();
        reject(err);
      });
    });
  }

  parseChallenge(challenge) {
    return {
      spotId: challenge.spotid,
      performanceName: challenge.name
    };
  }

  parseChallengeAblePerson(challenge) {
    return {
      challengedCount: challenge.challengedcount,
      challengeFull: challenge.open ? challenge.challengedcount === 2 : challenge.challengedcount === 1,
      name: challenge.name,
      spotOpen: challenge.open,
      spotId: challenge.spotid
    };
  }
}

module.exports = Challenge;
<|endoftext|>


<commit_before>import db from './database/dbContext.js';
import Book from './viewModels/bookViewModel.js';

import errorHelper from './helpers/errorHelper.js';

class bookModel {
    addBook(title, author, category, isbn, price, pictureURL, kindleURL, description) {
        var book = new Book(title, author, category, isbn, +price, pictureURL, kindleURL, description);

        var promise = new Promise(function (resolve, reject) {
            var errors = errorHelper.getErrors();

            if (errors.length === 0) {
                db.add('Book', book);
                resolve()
            } else {
                reject(errors);
            }

            errors = [];
        });

        return promise;
    }

    getBooks() {
        return db.get('Book');
    }

    updateBook(book) {
        book.save(null, {
            success: function (bookObject) {
                bookObject.save();
            },
            error: function (bookObject, error) {
                console.log('Cannot access the given book' + object);
                console.log(error);
            }
        });
    }

    getBookById(id) {
        var that = this;
        return new Promise(function(resolve, reject) {
            that.getBooks().get(id, {
                success: function(book) {
                    resolve(book);
                },
                error: function(book, error) {
                    reject(error);
                }
            });
        });
    }

    getBookBy(prop, value) {
        var that = this;
        return new Promise(function(resolve, reject) {
            var bookQuery = that.getBooks();
                bookQuery.equalTo(prop, value);
                bookQuery.find({
                    success: function(book) {
                        resolve(book);
                    },
                    error: function(book, error) {
                        reject(error);
                    }
                });
        });
    }

    removeBookBy(prop) {
    	return this.getBookBy(prop)
            .then(function(bookToRemove) {
                bookToRemove.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            });
    }

    removeBookById(id) {
        return this.getBooks().get(id, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }

    removeBookByTitle(title) {
        return this.getBooks().get(title, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }

    removeBookByISBN(isbn) {
        return this.getBooks().get(isbn, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }
}

export default new bookModel();
<commit_msg>getBooksBy method finally working properly.<commit_after>import db from './database/dbContext.js';
import Book from './viewModels/bookViewModel.js';

import errorHelper from './helpers/errorHelper.js';

class bookModel {
    addBook(title, author, category, isbn, price, pictureURL, kindleURL, description) {
        var book = new Book(title, author, category, isbn, +price, pictureURL, kindleURL, description);

        var promise = new Promise(function (resolve, reject) {
            var errors = errorHelper.getErrors();

            if (errors.length === 0) {
                db.add('Book', book);
                resolve()
            } else {
                reject(errors);
            }

            errors = [];
        });

        return promise;
    }

    getBooks() {
        return db.get('Book');
    }

    updateBook(book) {
        book.save(null, {
            success: function (bookObject) {
                bookObject.save();
            },
            error: function (bookObject, error) {
                console.log('Cannot access the given book' + object);
                console.log(error);
            }
        });
    }

    getBookById(id) {
        var that = this;
        return new Promise(function(resolve, reject) {
            that.getBooks().get(id, {
                success: function(book) {
                    resolve(book);
                },
                error: function(book, error) {
                    reject(error);
                }
            });
        });
    }

    getBooksBy(prop, value) {
        var that = this;
        return new Promise(function(resolve, reject) {
            that.getBooks()
                .equalTo(prop, value)
                .find({
                    success: function(books) {
                        if (books.length < 1) {
                            reject({
                                message: 'Could not retrieve any books from "' + prop + '" with "' + value + '"'
                            });
                        }

                        resolve(books);
                    }
                });
        });
    }

    removeBookBy(prop) {
    	return this.getBookBy(prop)
            .then(function(bookToRemove) {
                bookToRemove.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            });
    }

    removeBookById(id) {
        return this.getBooks().get(id, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }

    removeBookByTitle(title) {
        return this.getBooks().get(title, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }

    removeBookByISBN(isbn) {
        return this.getBooks().get(isbn, {
            success: function(receivedBook) {
                receivedBook.destroy({
                  success: function(myObject) {
                    console.log('Book deleted successfully!');
                    // The object was deleted from the Parse Cloud.
                  },
                  error: function(myObject, error) {
                    console.log('Error at book destroying!');
                    // The delete failed.
                    // error is a Parse.Error with an error code and message.
                  }
                });
            }
        });
    }
}

export default new bookModel();
<|endoftext|>


<commit_before>/**
 * User
 *
 * @module      :: Model
 * @description :: Represent data model for the Users
 * @author      :: Adam Gavish
 */

var mongoose = require('mongoose');
var	Schema = mongoose.Schema;
var Review = require('mongoose').model('Review');
var Business = require('mongoose').model('Business');

var userSchema = new Schema({
  // we identify users by their facebook id which is of type string
  _id:                   { type: String, required: true },
  firstname:             { type: String, required: true },
  lastname:              { type: String, required: true },
  email:                 { type: String, required: true },
  username:              { type: String },
  imagePath:             { type: String },
  reviews:               { type: [ Review.Schema ] },
  favoriteBusiness:      { type: [ Schema.ObjectId ], ref: 'Business' },
  lastVisitedBusiness:   { type: [ Schema.ObjectId ], ref: 'Business' }
});

module.exports = mongoose.model('User', userSchema);

<commit_msg>user model - email not required<commit_after>/**
 * User
 *
 * @module      :: Model
 * @description :: Represent data model for the Users
 * @author      :: Adam Gavish
 */

var mongoose = require('mongoose');
var	Schema = mongoose.Schema;
var Review = require('mongoose').model('Review');
var Business = require('mongoose').model('Business');

var userSchema = new Schema({
  // we identify users by their facebook id which is of type string
  _id:                   { type: String, required: true },
  firstname:             { type: String, required: true },
  lastname:              { type: String, required: true },
  email:                 { type: String },
  username:              { type: String },
  imagePath:             { type: String },
  reviews:               { type: [ Review.Schema ] },
  favoriteBusiness:      { type: [ Schema.ObjectId ], ref: 'Business' },
  lastVisitedBusiness:   { type: [ Schema.ObjectId ], ref: 'Business' }
});

module.exports = mongoose.model('User', userSchema);

<|endoftext|>


<commit_before>'use strict'

var marble = require('marble')
var slugify = require('markdown-slug')

module.exports = {
  basePath: '/crocks',
  deployOptions: {
    branch: 'gh-pages'
  },
  codeMirrorTheme: 'blackboard',
  codeMirrorLanguages: ['javascript', 'haskell'],
  envOptions: {
    dev: {
      basePath: ''
    }
  },
  markdownOptions: {
    html: true
  },
  markdownRenderer: function (md) {
    const origHtmlblock = md.renderer.rules.htmlblock

    // add links to headers
    md.renderer.rules.heading_open = function (t, idx) {
      var slug = slugify(t[idx + 1].content)
      return '<h' + t[idx].hLevel + '>'
    }

    md.renderer.rules.heading_close = function (t, idx) {
      return '</h' + t[idx].hLevel + '>'
    }

    // Remove all html comments from markdown docs
    // as they break. We use the comments for the linter
    md.renderer.rules.htmlblock = function (t, idx) {
      const content = t[idx].content

      const htmlComment =
        //g

      return htmlComment.test(content)
        ? t[idx].content.replace(htmlComment, '')
        : origHtmlblock(t, idx)
    }

    return md
  },
  metalComponents: [
    'electric-marble-components',
    'marble-topbar'
  ],
  sassOptions: {
    includePaths: [
      'node_modules', marble.src
    ]
  },
  vendorSrc: [
    'node_modules/marble/build/fonts/**'
  ]
};
<commit_msg>fix docs base path<commit_after>'use strict'

var marble = require('marble')
var slugify = require('markdown-slug')

module.exports = {
  basePath: '',
  deployOptions: {
    branch: 'gh-pages'
  },
  codeMirrorTheme: 'blackboard',
  codeMirrorLanguages: ['javascript', 'haskell'],
  envOptions: {
    dev: {
      basePath: ''
    }
  },
  markdownOptions: {
    html: true
  },
  markdownRenderer: function (md) {
    const origHtmlblock = md.renderer.rules.htmlblock

    // add links to headers
    md.renderer.rules.heading_open = function (t, idx) {
      var slug = slugify(t[idx + 1].content)
      return '<h' + t[idx].hLevel + '>'
    }

    md.renderer.rules.heading_close = function (t, idx) {
      return '</h' + t[idx].hLevel + '>'
    }

    // Remove all html comments from markdown docs
    // as they break. We use the comments for the linter
    md.renderer.rules.htmlblock = function (t, idx) {
      const content = t[idx].content

      const htmlComment =
        //g

      return htmlComment.test(content)
        ? t[idx].content.replace(htmlComment, '')
        : origHtmlblock(t, idx)
    }

    return md
  },
  metalComponents: [
    'electric-marble-components',
    'marble-topbar'
  ],
  sassOptions: {
    includePaths: [
      'node_modules', marble.src
    ]
  },
  vendorSrc: [
    'node_modules/marble/build/fonts/**'
  ]
};
<|endoftext|>


<commit_before>+//Eat Lunch Meat!!!!
<commit_msg>Update scripts.js<commit_after>exports.BattleScripts = {
    init: function() {
        for (var i in this.data.FormatsData)
            this.data.FormatsData[i].dreamWorldRelease = true;
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].fissure;
},
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].meditate;
},
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].sharpen;
},
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].flameburst;
},
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].howl;
},
        for (var i in this.data.Learnsets) {
            delete this.data.Learnsets[i].lockon;
}

                this.data.Pokedex.charizard.types = ["Fire","Dragon"];
                this.data.Pokedex.charizard.abilities['DW'] = 'Levitate';
                this.data.Learnsets.charizard.learnset.dracometeor = ['5T'];

                this.data.Pokedex.blastoise.abilities['DW'] = 'Water Veil';

                this.data.Learnsets.nidoking.learnset.gammastrike = ['5L0'];

                this.data.Pokedex.clefable.types = ["Normal","Psychic"];
                this.data.Pokedex.clefable.abilities['0'] = 'Friend Guard';
                this.data.Learnsets.clefable.learnset.lunardance = ['5L0'];

                this.data.Learnsets.dugtrio.learnset.fissure = ['5L0'];

                this.data.Pokedex.arcanine.abilities['1'] = 'Adrenaline';

                this.data.Learnsets.magneton.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.magneton.learnset.zapcannon;

                this.data.Pokedex.electrode.abilities['1'] = 'Volt Absorb';
                this.data.Learnsets.electrode.learnset.lockon = ['5L0'];

                this.data.Learnsets.muk.learnset.gammastrike = ['5L0'];

                this.data.Pokedex.exeggutor.abilities['1'] = 'Trickster';

                this.data.Pokedex.weezing.types = ["Poison","Electric"];
                this.data.Learnsets.weezing.learnset.gammastrike = ['5L0'];
                this.data.Learnsets.weezing.learnset.wildcharge = ['5M'];
                this.data.Learnsets.weezing.learnset.lockon = ['5L0'];

                this.data.Pokedex.chansey.abilities['1'] = 'Friend Guard';

                this.data.Pokedex.jynx.abilities['0'] = 'Caution';

                this.data.Learnsets.aerodactyl.learnset.bravebird = ['5L0'];

                this.data.Pokedex.dragonair.types = ["Dragon","Water"];
                this.data.Learnsets.dragonair.learnset.coil = ['5L0'];

                this.data.Learnsets.dragonite.learnset.coil = ['5L0'];

                this.data.Pokedex.mewtwo.abilities['0'] = 'Dauntless';

                this.data.Learnsets.typhlosion.learnset.flameburst = ['5L0'];

                this.data.Learnsets.ampharos.learnset.tailglow = ['5L0'];

                this.data.Learnsets.qwilfish.learnset.gammastrike = ['5L0'];
                this.data.Learnsets.qwilfish.learnset.poisontail = ['5L0'];

                this.data.Pokedex.piloswine.abilities['0'] = 'Arctic Rush';

                this.data.Pokedex.skarmory.abilities['0'] = 'Ancient Wind';

                this.data.Pokedex.mantine.abilities['DW'] = 'Storm Drain';

                this.data.Learnsets.houndoom.learnset.howl = ['5L0'];

                this.data.Pokedex.kingdra.abilities['DW'] = 'Water Veil';

                this.data.Learnsets.porygon2.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.porygon2.learnset.zapcannon;

                this.data.Pokedex.blissey.abilities['1'] = 'Friend Guard';

                this.data.Pokedex.blaziken.abilities['DW'] = 'Adrenaline';

                this.data.Learnsets.swampert.learnset.fissure = ['5L0'];

                this.data.Pokedex.gardevoir.abilities['0'] = 'Caution';
                this.data.Pokedex.gardevoir.abilities['DW'] = 'Justified';

                this.data.Learnsets.manectric.learnset.howl = ['5L0'];
                this.data.Learnsets.manectric.learnset.flameburst = ['5L0'];

                this.data.Pokedex.cacturne.abilities['0'] = 'Sand Rush';
                this.data.Learnsets.cacturne.learnset.sharpen = ['5L0'];

                this.data.Pokedex.wailord.abilities['0'] = 'Hydration';

                this.data.Pokedex.claydol.abilities['0'] = 'Magic Guard';
                this.data.Pokedex.claydol.abilities['DW'] = 'Caution';
                this.data.Learnsets.claydol.learnset.lockon = ['5L0'];

                this.data.Pokedex.milotic.abilities['0'] = 'Multiscale';

                this.data.Learnsets.absol.learnset.howl = ['5L0'];

                this.data.Pokedex.metagross.abilities['1'] = 'Light Metal';
                this.data.Pokedex.metagross.abilities['DW'] = 'Gravotonize';

                this.data.Learnsets.regice.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.regice.learnset.zapcannon;

                this.data.Pokedex.regirock.abilities['DW'] = 'Sand Veil';
                this.data.Learnsets.regirock.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.regirock.learnset.zapcannon = ['5L0'];

                this.data.Pokedex.registeel.abilities['DW'] = 'Heavy Metal';
                this.data.Learnsets.registeel.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.registeel.learnset.zapcannon;
                this.data.Learnsets.registeel.learnset.heavyslam = ['5L0'];

                this.data.Learnsets.latias.learnset.lunardance = ['5L0'];

                this.data.Learnsets.latios.learnset.lunardance = ['5L0'];

                this.data.Learnsets.infernape.learnset.flameburst = ['5L0'];

                this.data.Pokedex.luxray.types = ["Electric","Dark"];
                this.data.Learnsets.luxray.learnset.howl = ['5L0'];

                this.data.Pokedex.bastiodon.types = ["Steel"];
                this.data.Learnsets.bastiodon.learnset.shieldbash = ['5L0'];

                this.data.Pokedex.drifblim.abilities['0'] = 'Tempest';

                this.data.Learnsets.honchkrow.learnset.blackhole = ['5L0'];

                this.data.Pokedex.spiritomb.abilities['DW'] = 'Trickster';
                this.data.Learnsets.spiritomb.learnset.blackhole = ['5L0'];

                this.data.Pokedex.garchomp.abilities['DW'] = 'Mach Scale';

                this.data.Pokedex.hippowdon.abilities['DW'] = 'Sand Veil';
                this.data.Learnsets.hippowdon.learnset.fissure = ['5L0'];

                this.data.Learnsets.toxicroak.learnset.gammastrike = ['5L0'];

                this.data.Pokedex.lumineon.types = ["Water","Flying"];
                this.data.Learnsets.lumineon.learnset.hurricane = ['5L0'];
                this.data.Learnsets.lumineon.learnset.airslash = ['5L0'];

                this.data.Learnsets.magnezone.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.magnezone.learnset.zapcannon;

                this.data.Pokedex.weavile.abilities['0'] = 'Technician';

                this.data.Learnsets.magmortar.learnset.flameburst = ['5L0'];

                this.data.Pokedex.electivire.types = ["Electric","Fighting"];
                this.data.Learnsets.electivire.learnset.submission = ['5L0'];
                this.data.Learnsets.electivire.learnset.drainpunch = ['5T'];

                this.data.Learnsets.togekiss.learnset.lunardance = ['5L0'];

                this.data.Pokedex.yanmega.types = ["Bug","Dragon"];
                this.data.Pokedex.yanmega.abilities['1'] = 'Compoundeyes';
                this.data.Learnsets.yanmega.learnset.dracometeor = ['5T'];
                this.data.Learnsets.yanmega.learnset.dragonpulse = ['5T'];
                delete this.data.Learnsets.yanmega.learnset.hypnosis;

                this.data.Pokedex.glaceon.abilities['0'] = 'Arctic Rush';

                this.data.Pokedex.mamoswine.abilities['0'] = 'Arctic Rush';

                this.data.Learnsets.porygonz.learnset.lockon = ['5L0'];
                delete this.data.Learnsets.porygonz.learnset.zapcannon;

                this.data.Pokedex.gallade.abilities['0'] = 'Caution';
                this.data.Pokedex.gallade.abilities['1'] = 'Trace';
                this.data.Learnsets.gallade.learnset.shieldbash = ['5L0'];

                this.data.Pokedex.dusknoir.types = ["Ghost","Fighting"];
                this.data.Pokedex.dusknoir.abilities['0'] = 'Iron Fist';
                this.data.Learnsets.dusknoir.learnset.drainpunch = ['5T'];
                this.data.Learnsets.dusknoir.learnset.superpower = ['5T'];
                this.data.Learnsets.dusknoir.learnset.moonlight = ['5L0'];

        }
};

<|endoftext|>