Linting fixes

This commit is contained in:
Colin McLeod
2015-06-10 00:23:21 -07:00
parent 1367418fb2
commit 7140dcce95
4 changed files with 15 additions and 16 deletions

View File

@@ -38,7 +38,7 @@ angular.module('app', ['ui.router', 'ct.ui.router.extras.sticky', 'ui.sortable',
$rootScope.cName = function (c) {
return c.c? c.c.name? c.c.name : GroupMap[c.c.grp] : null;
}
};
// Formatters
$rootScope.fCrd = d3.format(',.0f');

View File

@@ -1,4 +1,4 @@
angular.module('app').controller('OutfitController', ['$window','$rootScope','$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', 'lodash', function ($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist, _) {
angular.module('app').controller('OutfitController', ['$window','$rootScope','$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', function ($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist) {
var data = Ships[$p.shipId]; // Retrieve the basic ship properties, slots and defaults
var ship = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship instance
var win = angular.element($window); // Angularized window object for event triggering

View File

@@ -6,15 +6,14 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
available: '='
},
link: function(scope, element) {
var color = d3.scale.ordinal().range([ '#7b6888', '#6b486b', '#3182bd', '#a05d56', '#d0743c']),
margin = {top: 20, right: 130, bottom: 20, left: 40},
var margin = {top: 20, right: 130, bottom: 20, left: 40},
barHeight = 20,
innerHeight = (barHeight * 2) + 3,
height = innerHeight + margin.top + margin.bottom + 1,
wattScale = d3.scale.linear(),
pctScale = d3.scale.linear().domain([0, 1]),
wattFmt = d3.format('.2f');
pctFmt = d3.format('.1%');
wattFmt = d3.format('.2f'),
pctFmt = d3.format('.1%'),
wattAxis = d3.svg.axis().scale(wattScale).outerTickSize(0).orient('top').tickFormat(d3.format('.2r')),
pctAxis = d3.svg.axis().scale(pctScale).outerTickSize(0).orient('bottom').tickFormat(d3.format('%')),
// Create chart
@@ -29,8 +28,8 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
vis.append("text").attr('x', -35).attr('y', 15).attr('class','primary').text('RET');
vis.append("text").attr('x', -35).attr('y', barHeight + 17).attr('class','primary').text('DEP');
var retLbl = vis.append("text").attr('y', 15)
var depLbl = vis.append("text").attr('y', barHeight + 17).attr('class','primary');
var retLbl = vis.append("text").attr('y', 15);
var depLbl = vis.append("text").attr('y', barHeight + 17);
// Watch for changes to data and events
scope.$watchCollection('available', render);
@@ -41,7 +40,7 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
available = scope.available,
width = element[0].offsetWidth,
w = width - margin.left - margin.right,
maxBand = bands[bands.length - 1];
maxBand = bands[bands.length - 1],
maxPwr = Math.max(available, maxBand.deployedSum);
// Update chart size
@@ -81,7 +80,7 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
.attr('y', 15)
.style('text-anchor', 'middle')
.attr('class','primary-bg')
.text(function(d,i) { return bandText(d.retracted, i, available); });
.text(function(d,i) { return bandText(d.retracted, i); });
deployed.selectAll("rect").data(bands).enter().append("rect")
.attr("height", barHeight)
@@ -95,11 +94,11 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
.attr('y', barHeight + 17)
.style('text-anchor', 'middle')
.attr('class','primary-bg')
.text(function(d,i) { return bandText(d.deployed + d.retracted, i, available); });
.text(function(d,i) { return bandText(d.deployed + d.retracted, i); });
}
function bandText(val, index, available) {
function bandText(val, index) {
if (val > 0) {
if( wattScale(val) > 100) {
return (index + 1) + ' (' + wattFmt(val) + ' MW)';

View File

@@ -184,14 +184,14 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
}
}
return false;
}
};
Ship.prototype.setCostIncluded = function (item, included) {
if (item.incCost != included && item.c) {
this.totalCost += included? item.c.cost : -item.c.cost;
}
item.incCost = included;
}
};
Ship.prototype.setSlotEnabled = function (slot, enabled) {
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
@@ -200,7 +200,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.updatePower();
}
slot.enabled = enabled;
}
};
Ship.prototype.getSlotStatus = function (slot, deployed) {
if(!slot.c) { // Empty Slot
@@ -216,7 +216,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
return 0; // No Status (Not possible)
}
return this.priorityBands[slot.priority].retractedSum > this.powerAvailable? 2 : 3; // Offline : Online
}
};
/**
* Updates the ship's cumulative and aggregated stats based on the component change.