mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 15:15:34 +00:00
Linting fixes
This commit is contained in:
@@ -38,7 +38,7 @@ angular.module('app', ['ui.router', 'ct.ui.router.extras.sticky', 'ui.sortable',
|
|||||||
|
|
||||||
$rootScope.cName = function (c) {
|
$rootScope.cName = function (c) {
|
||||||
return c.c? c.c.name? c.c.name : GroupMap[c.c.grp] : null;
|
return c.c? c.c.name? c.c.name : GroupMap[c.c.grp] : null;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Formatters
|
// Formatters
|
||||||
$rootScope.fCrd = d3.format(',.0f');
|
$rootScope.fCrd = d3.format(',.0f');
|
||||||
|
|||||||
@@ -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 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 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
|
var win = angular.element($window); // Angularized window object for event triggering
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
|
|||||||
available: '='
|
available: '='
|
||||||
},
|
},
|
||||||
link: function(scope, element) {
|
link: function(scope, element) {
|
||||||
var color = d3.scale.ordinal().range([ '#7b6888', '#6b486b', '#3182bd', '#a05d56', '#d0743c']),
|
var margin = {top: 20, right: 130, bottom: 20, left: 40},
|
||||||
margin = {top: 20, right: 130, bottom: 20, left: 40},
|
|
||||||
barHeight = 20,
|
barHeight = 20,
|
||||||
innerHeight = (barHeight * 2) + 3,
|
innerHeight = (barHeight * 2) + 3,
|
||||||
height = innerHeight + margin.top + margin.bottom + 1,
|
height = innerHeight + margin.top + margin.bottom + 1,
|
||||||
wattScale = d3.scale.linear(),
|
wattScale = d3.scale.linear(),
|
||||||
pctScale = d3.scale.linear().domain([0, 1]),
|
pctScale = d3.scale.linear().domain([0, 1]),
|
||||||
wattFmt = d3.format('.2f');
|
wattFmt = d3.format('.2f'),
|
||||||
pctFmt = d3.format('.1%');
|
pctFmt = d3.format('.1%'),
|
||||||
wattAxis = d3.svg.axis().scale(wattScale).outerTickSize(0).orient('top').tickFormat(d3.format('.2r')),
|
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('%')),
|
pctAxis = d3.svg.axis().scale(pctScale).outerTickSize(0).orient('bottom').tickFormat(d3.format('%')),
|
||||||
// Create chart
|
// 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', 15).attr('class','primary').text('RET');
|
||||||
vis.append("text").attr('x', -35).attr('y', barHeight + 17).attr('class','primary').text('DEP');
|
vis.append("text").attr('x', -35).attr('y', barHeight + 17).attr('class','primary').text('DEP');
|
||||||
|
|
||||||
var retLbl = vis.append("text").attr('y', 15)
|
var retLbl = vis.append("text").attr('y', 15);
|
||||||
var depLbl = vis.append("text").attr('y', barHeight + 17).attr('class','primary');
|
var depLbl = vis.append("text").attr('y', barHeight + 17);
|
||||||
|
|
||||||
// Watch for changes to data and events
|
// Watch for changes to data and events
|
||||||
scope.$watchCollection('available', render);
|
scope.$watchCollection('available', render);
|
||||||
@@ -41,7 +40,7 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
|
|||||||
available = scope.available,
|
available = scope.available,
|
||||||
width = element[0].offsetWidth,
|
width = element[0].offsetWidth,
|
||||||
w = width - margin.left - margin.right,
|
w = width - margin.left - margin.right,
|
||||||
maxBand = bands[bands.length - 1];
|
maxBand = bands[bands.length - 1],
|
||||||
maxPwr = Math.max(available, maxBand.deployedSum);
|
maxPwr = Math.max(available, maxBand.deployedSum);
|
||||||
|
|
||||||
// Update chart size
|
// Update chart size
|
||||||
@@ -81,7 +80,7 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
|
|||||||
.attr('y', 15)
|
.attr('y', 15)
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.attr('class','primary-bg')
|
.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")
|
deployed.selectAll("rect").data(bands).enter().append("rect")
|
||||||
.attr("height", barHeight)
|
.attr("height", barHeight)
|
||||||
@@ -95,11 +94,11 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
|
|||||||
.attr('y', barHeight + 17)
|
.attr('y', barHeight + 17)
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.attr('class','primary-bg')
|
.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 (val > 0) {
|
||||||
if( wattScale(val) > 100) {
|
if( wattScale(val) > 100) {
|
||||||
return (index + 1) + ' (' + wattFmt(val) + ' MW)';
|
return (index + 1) + ' (' + wattFmt(val) + ' MW)';
|
||||||
|
|||||||
@@ -184,14 +184,14 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
Ship.prototype.setCostIncluded = function (item, included) {
|
Ship.prototype.setCostIncluded = function (item, included) {
|
||||||
if (item.incCost != included && item.c) {
|
if (item.incCost != included && item.c) {
|
||||||
this.totalCost += included? item.c.cost : -item.c.cost;
|
this.totalCost += included? item.c.cost : -item.c.cost;
|
||||||
}
|
}
|
||||||
item.incCost = included;
|
item.incCost = included;
|
||||||
}
|
};
|
||||||
|
|
||||||
Ship.prototype.setSlotEnabled = function (slot, enabled) {
|
Ship.prototype.setSlotEnabled = function (slot, enabled) {
|
||||||
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
|
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
|
||||||
@@ -200,7 +200,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
this.updatePower();
|
this.updatePower();
|
||||||
}
|
}
|
||||||
slot.enabled = enabled;
|
slot.enabled = enabled;
|
||||||
}
|
};
|
||||||
|
|
||||||
Ship.prototype.getSlotStatus = function (slot, deployed) {
|
Ship.prototype.getSlotStatus = function (slot, deployed) {
|
||||||
if(!slot.c) { // Empty Slot
|
if(!slot.c) { // Empty Slot
|
||||||
@@ -216,7 +216,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
return 0; // No Status (Not possible)
|
return 0; // No Status (Not possible)
|
||||||
}
|
}
|
||||||
return this.priorityBands[slot.priority].retractedSum > this.powerAvailable? 2 : 3; // Offline : Online
|
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.
|
* Updates the ship's cumulative and aggregated stats based on the component change.
|
||||||
|
|||||||
Reference in New Issue
Block a user