From 7140dcce950d31dc0a1fa3588e0f5cf423a45dee Mon Sep 17 00:00:00 2001 From: Colin McLeod Date: Wed, 10 Jun 2015 00:23:21 -0700 Subject: [PATCH] Linting fixes --- app/js/app.js | 2 +- app/js/controllers/controller-outfit.js | 2 +- app/js/directives/directive-power-bands.js | 19 +++++++++---------- app/js/shipyard/factory-ship.js | 8 ++++---- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/js/app.js b/app/js/app.js index d85ecb32..d9b54d43 100755 --- a/app/js/app.js +++ b/app/js/app.js @@ -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'); diff --git a/app/js/controllers/controller-outfit.js b/app/js/controllers/controller-outfit.js index cbb9ab04..16cc8940 100755 --- a/app/js/controllers/controller-outfit.js +++ b/app/js/controllers/controller-outfit.js @@ -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 diff --git a/app/js/directives/directive-power-bands.js b/app/js/directives/directive-power-bands.js index a5ac1e21..7c72e43e 100644 --- a/app/js/directives/directive-power-bands.js +++ b/app/js/directives/directive-power-bands.js @@ -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)'; diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index 130f77e5..316d723e 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -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.