'];
@@ -8,17 +8,17 @@ angular.module('app').directive('comparisonTable', ['$state', function ($state)
var f = facets[i];
var p = f.props;
var pl = p.length;
- r1.push('
');
for (var j = 0, fl = facets.length; j < fl; j++) {
if (facets[j].active) {
@@ -59,13 +59,13 @@ angular.module('app').directive('comparisonTable', ['$state', function ($state)
return {
restrict: 'A',
- link: function (scope, element) {
+ link: function(scope, element) {
var header = angular.element('');
var body = angular.element('
');
element.append(header);
element.append(body);
- var updateAll = function (){
+ var updateAll = function() {
header.html(tblHeader(scope.facets));
body.html(tblBody(scope.facets, scope.builds));
};
@@ -77,4 +77,4 @@ angular.module('app').directive('comparisonTable', ['$state', function ($state)
});
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/directives/directive-component-select.js b/app/js/directives/directive-component-select.js
index 2f0b851b..b4070927 100755
--- a/app/js/directives/directive-component-select.js
+++ b/app/js/directives/directive-component-select.js
@@ -1,4 +1,4 @@
-angular.module('app').directive('componentSelect', function () {
+angular.module('app').directive('componentSelect', function() {
// Generting the HTML in this manner is MUCH faster than using an angular template.
@@ -8,42 +8,42 @@ angular.module('app').directive('componentSelect', function () {
var o = opts[i];
var id = o.id || (o.class + o.rating); // Common components' ID is their class and rating
- if(i > 0 && opts.length > 3 && o.class != prevClass && (!o.grp || o.rating != prevRating || o.mode)) {
+ if (i > 0 && opts.length > 3 && o.class != prevClass && (!o.grp || o.rating != prevRating || o.mode)) {
list.push(' ');
}
- list.push('
');
prevClass = o.class;
- prevRating= o.rating;
+ prevRating = o.rating;
}
}
return {
restrict: 'A',
- scope:{
+ scope: {
opts: '=', // Component Options object
groups: '=', // Groups of Component Options
mass: '=', // Current ship unladen mass
@@ -57,13 +57,13 @@ angular.module('app').directive('componentSelect', function () {
var groups = scope.groups;
var mass = scope.mass || 0;
- if(groups) {
+ if (groups) {
// At present time slots with grouped options (Hardpoints and Internal) can be empty
list.push('
EMPTY
');
for (var g in groups) {
var grp = groups[g];
var grpCode = grp[Object.keys(grp)[0]].grp; // Nasty operation to get the grp property of the first/any single component
- list.push('
');
}
@@ -77,9 +77,9 @@ angular.module('app').directive('componentSelect', function () {
// If groups are present and a component is already selectd
if (groups && component && component.grp) {
var groupElement = angular.element(document.getElementById(component.grp));
- var parentElem = element[0].parentElement;
+ var parentElem = element[0].parentElement;
parentElem.scrollTop = groupElement[0].offsetTop; // Scroll to currently selected group
}
}
};
-});
\ No newline at end of file
+});
diff --git a/app/js/directives/directive-header.js b/app/js/directives/directive-header.js
index 1d61b560..c6beeebe 100755
--- a/app/js/directives/directive-header.js
+++ b/app/js/directives/directive-header.js
@@ -1,10 +1,10 @@
-angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Persist', 'ShipsDB', function (_, $rootScope, Persist, ships) {
+angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Persist', 'ShipsDB', function(_, $rootScope, Persist, ships) {
return {
restrict: 'E',
templateUrl: 'views/_header.html',
scope: true,
- link: function (scope) {
+ link: function(scope) {
scope.openedMenu = null;
scope.ships = ships;
scope.allBuilds = Persist.builds;
@@ -15,22 +15,22 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
// Insurance options and management here for now.
$rootScope.insurance = {
opts: [
- { name:'Standard', pct: 0.05 },
- { name:'Alpha', pct: 0.025 },
- { name:'Beta', pct: 0.035 }
+ { name: 'Standard', pct: 0.05 },
+ { name: 'Alpha', pct: 0.025 },
+ { name: 'Beta', pct: 0.035 }
]
};
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
- $rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1? insIndex : 0];
+ $rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1 ? insIndex : 0];
// Close menus if a navigation change event occurs
- $rootScope.$on('$stateChangeStart',function(){
+ $rootScope.$on('$stateChangeStart', function() {
scope.openedMenu = null;
});
// Listen to close event to close opened menus or modals
- $rootScope.$on('close', function () {
+ $rootScope.$on('close', function() {
scope.openedMenu = null;
$rootScope.showAbout = false;
});
@@ -38,13 +38,13 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
/**
* Save selected insurance option
*/
- scope.updateInsurance = function(){
+ scope.updateInsurance = function() {
Persist.setInsurance($rootScope.insurance.current.name);
};
- scope.openMenu = function (e, menu) {
+ scope.openMenu = function(e, menu) {
e.stopPropagation();
- if(menu == scope.openedMenu) {
+ if (menu == scope.openedMenu) {
scope.openedMenu = null;
return;
}
@@ -63,7 +63,7 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
$rootScope.showAbout = true;
};
- $rootScope.hideAbout = function (){
+ $rootScope.hideAbout = function() {
$rootScope.showAbout = false;
};
@@ -72,4 +72,4 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
});
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/directives/directive-power-bands.js b/app/js/directives/directive-power-bands.js
index 2dd55c70..f680c064 100644
--- a/app/js/directives/directive-power-bands.js
+++ b/app/js/directives/directive-power-bands.js
@@ -1,12 +1,12 @@
-angular.module('app').directive('powerBands', ['$window', function ($window) {
+angular.module('app').directive('powerBands', ['$window', function($window) {
return {
restrict: 'A',
- scope:{
+ scope: {
bands: '=',
available: '='
},
link: function(scope, element) {
- var 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,
@@ -25,11 +25,11 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
// Create Y Axis SVG Elements
vis.append('g').attr('class', 'watt axis');
vis.append('g').attr('class', 'pct axis');
- vis.append("text").attr('x', -35).attr('y', 16).attr('class','primary').text('RET');
- vis.append("text").attr('x', -35).attr('y', barHeight + 18).attr('class','primary').text('DEP');
+ vis.append('text').attr('x', -35).attr('y', 16).attr('class', 'primary').text('RET');
+ vis.append('text').attr('x', -35).attr('y', barHeight + 18).attr('class', 'primary').text('DEP');
- var retLbl = vis.append("text").attr('y', 16);
- var depLbl = vis.append("text").attr('y', barHeight + 18);
+ var retLbl = vis.append('text').attr('y', 16);
+ var depLbl = vis.append('text').attr('y', barHeight + 18);
// Watch for changes to data and events
scope.$watchCollection('available', render);
@@ -61,40 +61,41 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
retLbl
.attr('x', w + 5 )
- .attr('class',maxBand.retractedSum > available? 'warning': 'primary')
- .text(wattFmt(Math.max(0,maxBand.retractedSum)) + ' (' + pctFmt(Math.max(0,maxBand.retractedSum / available)) + ')');
+ .attr('class', maxBand.retractedSum > available ? 'warning' : 'primary')
+ .text(wattFmt(Math.max(0, maxBand.retractedSum)) + ' (' + pctFmt(Math.max(0, maxBand.retractedSum / available)) + ')');
+
depLbl
.attr('x', w + 5 )
- .attr('class',maxBand.deployedSum > available? 'warning': 'primary')
- .text(wattFmt(Math.max(0,maxBand.deployedSum)) + ' (' + pctFmt(Math.max(0,maxBand.deployedSum / available)) + ')');
+ .attr('class', maxBand.deployedSum > available ? 'warning' : 'primary')
+ .text(wattFmt(Math.max(0, maxBand.deployedSum)) + ' (' + pctFmt(Math.max(0, maxBand.deployedSum / available)) + ')');
- retracted.selectAll("rect").data(bands).enter().append("rect")
- .attr("height", barHeight)
- .attr("width", function(d) { return Math.max(wattScale(d.retracted) - 1, 0); })
- .attr("x", function(d) { return wattScale(d.retractedSum) - wattScale(d.retracted); })
+ retracted.selectAll('rect').data(bands).enter().append('rect')
+ .attr('height', barHeight)
+ .attr('width', function(d) { return Math.max(wattScale(d.retracted) - 1, 0); })
+ .attr('x', function(d) { return wattScale(d.retractedSum) - wattScale(d.retracted); })
.attr('y', 1)
- .attr('class',function(d){ return (d.retractedSum > available)? 'warning' :'primary'; });
+ .attr('class', function(d) { return (d.retractedSum > available) ? 'warning' : 'primary'; });
- retracted.selectAll("text").data(bands).enter().append("text")
+ retracted.selectAll('text').data(bands).enter().append('text')
.attr('x', function(d) { return wattScale(d.retractedSum) - (wattScale(d.retracted) / 2); })
.attr('y', 15)
.style('text-anchor', 'middle')
- .attr('class','primary-bg')
- .text(function(d,i) { return bandText(d.retracted, i); });
+ .attr('class', 'primary-bg')
+ .text(function(d, i) { return bandText(d.retracted, i); });
- deployed.selectAll("rect").data(bands).enter().append("rect")
- .attr("height", barHeight)
- .attr("width", function(d) { return Math.max(wattScale(d.deployed + d.retracted) - 1, 0); })
- .attr("x", function(d) { return wattScale(d.deployedSum) - wattScale(d.retracted) - wattScale(d.deployed); })
+ deployed.selectAll('rect').data(bands).enter().append('rect')
+ .attr('height', barHeight)
+ .attr('width', function(d) { return Math.max(wattScale(d.deployed + d.retracted) - 1, 0); })
+ .attr('x', function(d) { return wattScale(d.deployedSum) - wattScale(d.retracted) - wattScale(d.deployed); })
.attr('y', barHeight + 2)
- .attr('class',function(d){ return (d.deployedSum > available)? 'warning' :'primary'; });
+ .attr('class', function(d) { return (d.deployedSum > available) ? 'warning' : 'primary'; });
- deployed.selectAll("text").data(bands).enter().append("text")
+ deployed.selectAll('text').data(bands).enter().append('text')
.attr('x', function(d) { return wattScale(d.deployedSum) - ((wattScale(d.retracted) + wattScale(d.deployed)) / 2); })
.attr('y', barHeight + 17)
.style('text-anchor', 'middle')
- .attr('class','primary-bg')
- .text(function(d,i) { return bandText(d.deployed + d.retracted, i); });
+ .attr('class', 'primary-bg')
+ .text(function(d, i) { return bandText(d.deployed + d.retracted, i); });
}
@@ -110,4 +111,4 @@ angular.module('app').directive('powerBands', ['$window', function ($window) {
});
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/directives/directive-slider.js b/app/js/directives/directive-slider.js
index 4ab39544..e175bdd5 100644
--- a/app/js/directives/directive-slider.js
+++ b/app/js/directives/directive-slider.js
@@ -1,33 +1,33 @@
-angular.module('app').directive('slider', ['$window', function ($window) {
+angular.module('app').directive('slider', ['$window', function($window) {
return {
restrict: 'A',
- scope:{
+ scope: {
max: '=',
unit: '=',
change: '&onChange'
},
link: function(scope, element) {
- var margin = {top: -10, right: 140, bottom: 0, left: 50},
+ var margin = { top: -10, right: 140, bottom: 0, left: 50 },
height = 40, // Height is fixed
h = height - margin.top - margin.bottom,
fmt = d3.format('.2f'),
pct = d3.format('.1%'),
unit = scope.unit,
val = scope.max,
- svg = d3.select(element[0]).append("svg"),
- vis = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"),
- xAxis = vis.append("g").attr("class", "x slider-axis").attr("transform", "translate(0," + h / 2 + ")"),
+ svg = d3.select(element[0]).append('svg'),
+ vis = svg.append('g').attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'),
+ xAxis = vis.append('g').attr('class', 'x slider-axis').attr('transform', 'translate(0,' + h / 2 + ')'),
x = d3.scale.linear(),
- slider = vis.append("g").attr("class", "slider"),
- filled = slider.append('path').attr('class', 'filled').attr("transform", "translate(0," + h/2 + ")"),
- brush = d3.svg.brush().x(x).extent([scope.max, scope.max]).on("brush", brushed),
- handle = slider.append("circle").attr("class", "handle").attr("r", '0.6em'),
- lbl = slider.append("g").append("text").attr("y", h/2);
+ slider = vis.append('g').attr('class', 'slider'),
+ filled = slider.append('path').attr('class', 'filled').attr('transform', 'translate(0,' + h / 2 + ')'),
+ brush = d3.svg.brush().x(x).extent([scope.max, scope.max]).on('brush', brushed),
+ handle = slider.append('circle').attr('class', 'handle').attr('r', '0.6em'),
+ lbl = slider.append('g').append('text').attr('y', h / 2);
slider.call(brush);
- slider.select(".background").attr("height", h);
- handle.attr("transform", "translate(0," + h / 2 + ")");
+ slider.select('.background').attr('height', h);
+ handle.attr('transform', 'translate(0,' + h / 2 + ')');
/**
* Watch for changes in the max, window size
@@ -42,21 +42,21 @@ angular.module('app').directive('slider', ['$window', function ($window) {
function render() {
var width = element[0].offsetWidth, w = width - margin.left - margin.right;
- svg.attr("width", width).attr("height", height);
+ svg.attr('width', width).attr('height', height);
x.domain([0, scope.max]).range([0, w]).clamp(true);
- handle.attr("cx", x(val));
+ handle.attr('cx', x(val));
xAxis
.call(d3.svg.axis()
.scale(x)
- .orient("bottom")
+ .orient('bottom')
.tickFormat(function(d) { return d + unit; })
.tickValues([0, scope.max / 4, scope.max / 2, (3 * scope.max) / 4, scope.max])
.tickSize(0)
.tickPadding(12))
- .select(".domain");
+ .select('.domain');
lbl.attr('x', w + 20);
slider.call(brush.extent([val, val])).call(brush.event);
- slider.selectAll(".extent,.resize").remove();
+ slider.selectAll('.extent,.resize').remove();
}
function brushed() {
@@ -65,10 +65,10 @@ angular.module('app').directive('slider', ['$window', function ($window) {
val = x.invert(d3.mouse(this)[0]);
brush.extent([val, val]);
}
- lbl.text(fmt(val) + ' ' + unit + ' ' + pct(val / scope.max));
- scope.change({val: val});
- handle.attr("cx", x(val));
- filled.attr("d", "M0,0V0H" + x(val) + "V0");
+ lbl.text(fmt(val) + ' ' + unit + ' ' + pct(val / scope.max));
+ scope.change({ val: val });
+ handle.attr('cx', x(val));
+ filled.attr('d', 'M0,0V0H' + x(val) + 'V0');
}
scope.$on('$destroy', function() {
@@ -77,4 +77,4 @@ angular.module('app').directive('slider', ['$window', function ($window) {
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/directives/directive-slot-hardpoint.js b/app/js/directives/directive-slot-hardpoint.js
index b35a8b35..262cc561 100755
--- a/app/js/directives/directive-slot-hardpoint.js
+++ b/app/js/directives/directive-slot-hardpoint.js
@@ -1,14 +1,14 @@
-angular.module('app').directive('slotHardpoint', ['$rootScope', function ($r) {
+angular.module('app').directive('slotHardpoint', ['$rootScope', function($r) {
return {
restrict: 'A',
- scope:{
+ scope: {
hp: '=',
size: '=',
- lbl: '=',
+ lbl: '='
},
templateUrl: 'views/_slot-hardpoint.html',
- link: function (scope) {
+ link: function(scope) {
scope.$r = $r;
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/directives/directive-slot-internal.js b/app/js/directives/directive-slot-internal.js
index d6aabb9d..2b67a7e8 100755
--- a/app/js/directives/directive-slot-internal.js
+++ b/app/js/directives/directive-slot-internal.js
@@ -1,7 +1,7 @@
-angular.module('app').directive('slotInternal', ['$rootScope', function ($r) {
+angular.module('app').directive('slotInternal', ['$rootScope', function($r) {
return {
restrict: 'A',
- scope:{
+ scope: {
c: '=slot',
lbl: '=',
fuel: '='
@@ -11,4 +11,4 @@ angular.module('app').directive('slotInternal', ['$rootScope', function ($r) {
scope.$r = $r;
}
};
-}]);
\ No newline at end of file
+}]);
diff --git a/app/js/factory-utils.js b/app/js/factory-utils.js
index 34c90579..452772a4 100755
--- a/app/js/factory-utils.js
+++ b/app/js/factory-utils.js
@@ -1,17 +1,17 @@
/**
* BBCode Generator functions for embedding in the Elite Dangerous Forums
*/
-angular.module('app').factory('Utils', ['$window','$state','$http', '$q', function ($window, $state, $http, $q) {
+angular.module('app').factory('Utils', ['$window', '$state', '$http', '$q', function($window, $state, $http, $q) {
var shortenAPI = 'https://www.googleapis.com/urlshortener/v1/url?key=';
function shortenUrl(url) {
if ($window.navigator.onLine) {
- return $http.post(shortenAPI + GAPI_KEY, {longUrl:url}).then(function(response) {
+ return $http.post(shortenAPI + GAPI_KEY, { longUrl: url }).then(function(response) {
return response.data.id;
});
} else {
- return $q.reject({statusText: 'Not Online'});
+ return $q.reject({ statusText: 'Not Online' });
}
}
@@ -39,7 +39,7 @@ angular.module('app').factory('Utils', ['$window','$state','$http', '$q', functi
for (i = 0; i < builds.length; i++) {
b = builds[i];
//var href = $state.href('outfit',{shipId: b.id, code: b.code, bn: b.buildName}, {absolute: true});
- l.push('[tr][td]', b.name,'[/td][td]', b.buildName ,'[/td]');
+ l.push('[tr][td]', b.name, '[/td][td]', b.buildName, '[/td]');
for (j = 0, fl = facets.length; j < fl; j++) {
if (facets[j].active) {
@@ -52,8 +52,8 @@ angular.module('app').factory('Utils', ['$window','$state','$http', '$q', functi
}
l.push('[/tr]\n');
}
- l.push('[tr][td="align: center, colspan:',colCount,'"][size=-3]\n[url=', link,']Interactive Comparison at Coriolis.io[/url][/td][/tr]\n[/size][/table]');
- l.unshift('[table="width:', colCount * 90,',align: center"]\n[tr][th][B][COLOR=#FF8C0D]Ship[/COLOR][/B][/th][th][B][COLOR="#FF8C0D"]Build[/COLOR][/B][/th]');
+ l.push('[tr][td="align: center, colspan:', colCount, '"][size=-3]\n[url=', link, ']Interactive Comparison at Coriolis.io[/url][/td][/tr]\n[/size][/table]');
+ l.unshift('[table="width:', colCount * 90, ',align: center"]\n[tr][th][B][COLOR=#FF8C0D]Ship[/COLOR][/B][/th][th][B][COLOR="#FF8C0D"]Build[/COLOR][/B][/th]');
return l.join('');
}
diff --git a/app/js/service-persist.js b/app/js/service-persist.js
index 75ef5e5f..bf7c9e30 100755
--- a/app/js/service-persist.js
+++ b/app/js/service-persist.js
@@ -1,7 +1,7 @@
/**
* [description]
*/
-angular.module('app').service('Persist', ['$window','lodash', function ($window, _) {
+angular.module('app').service('Persist', ['$window', 'lodash', function($window, _) {
var LS_KEY_BUILDS = 'builds';
var LS_KEY_COMPARISONS = 'comparisons';
var localStorage = $window.localStorage;
@@ -19,8 +19,8 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
this.lsEnabled = false;
}
- this.builds = buildJson? angular.fromJson(buildJson) : {};
- this.comparisons = comparisonJson? angular.fromJson(comparisonJson) : {};
+ this.builds = buildJson ? angular.fromJson(buildJson) : {};
+ this.comparisons = comparisonJson ? angular.fromJson(comparisonJson) : {};
var buildCount = Object.keys(this.builds).length;
this.state = {
@@ -35,7 +35,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* @param {string} name The name of the build
* @param {string} code The serialized code
*/
- this.saveBuild = function (shipId, name, code) {
+ this.saveBuild = function(shipId, name, code) {
if (!this.lsEnabled) {
return;
}
@@ -44,7 +44,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
this.builds[shipId] = {};
}
- if(!this.builds[shipId][name]) {
+ if (!this.builds[shipId][name]) {
this.state.buildCount++;
this.state.hasBuilds = true;
}
@@ -62,7 +62,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* @param {string} name The name of the build
* @return {string} The serialized build string.
*/
- this.getBuild = function (shipId, name) {
+ this.getBuild = function(shipId, name) {
if (this.builds[shipId] && this.builds[shipId][name]) {
return this.builds[shipId][name];
}
@@ -76,8 +76,8 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* @param {string} shipId The unique id for a model of ship
* @param {string} name The name of the build
*/
- this.deleteBuild = function (shipId, name) {
- if(this.lsEnabled && this.builds[shipId][name]) {
+ this.deleteBuild = function(shipId, name) {
+ if (this.lsEnabled && this.builds[shipId][name]) {
delete this.builds[shipId][name];
if (Object.keys(this.builds[shipId]).length === 0) {
delete this.builds[shipId];
@@ -90,8 +90,8 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
var comps = this.comparisons;
for (var c in comps) {
for (var i = 0; i < comps[c].builds.length; i++) { // For all builds in the current comparison
- if(comps[c].builds[i].shipId == shipId && comps[c].builds[i].buildName == name) {
- comps[c].builds.splice(i,1);
+ if (comps[c].builds[i].shipId == shipId && comps[c].builds[i].buildName == name) {
+ comps[c].builds.splice(i, 1);
break; // A build is unique ber comparison
}
}
@@ -107,7 +107,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* @param {array} builds Array of builds
* @param {array} facets Array of facet indices
*/
- this.saveComparison = function (name, builds, facets){
+ this.saveComparison = function(name, builds, facets) {
if (!this.lsEnabled) {
return;
}
@@ -117,7 +117,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
}
this.comparisons[name] = {
facets: facets,
- builds: _.map(builds, function (b) { return {shipId: b.id, buildName: b.buildName }; })
+ builds: _.map(builds, function(b) { return { shipId: b.id, buildName: b.buildName }; })
};
localStorage.setItem(LS_KEY_COMPARISONS, angular.toJson(this.comparisons));
this.state.hasComparisons = true;
@@ -128,7 +128,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* @param {string} name [description]
* @return {object} Object containing array of facets and ship id + build names
*/
- this.getComparison = function (name) {
+ this.getComparison = function(name) {
if (this.comparisons[name]) {
return this.comparisons[name];
}
@@ -139,7 +139,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* Removes the comparison from localstorage.
* @param {string} name Comparison name
*/
- this.deleteComparison = function (name) {
+ this.deleteComparison = function(name) {
if (this.lsEnabled && this.comparisons[name]) {
delete this.comparisons[name];
localStorage.setItem(LS_KEY_COMPARISONS, angular.toJson(this.comparisons));
@@ -166,7 +166,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* Get the saved insurance type
* @return {string} The name of the saved insurance type of null
*/
- this.getInsurance = function () {
+ this.getInsurance = function() {
if (this.lsEnabled) {
return localStorage.getItem('insurance');
}
@@ -177,7 +177,7 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* Persist selected insurance type
* @param {string} name Insurance type name
*/
- this.setInsurance = function (name) {
+ this.setInsurance = function(name) {
if (this.lsEnabled) {
return localStorage.setItem('insurance', name);
}
@@ -187,9 +187,9 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* Retrieve the last router state from local storage
* @param {object} state State object containing state name and params
*/
- this.getState = function () {
+ this.getState = function() {
if (this.lsEnabled) {
- var state = localStorage.getItem('state');
+ var state = localStorage.getItem('state');
if (state) {
return angular.fromJson(state);
}
@@ -201,9 +201,9 @@ angular.module('app').service('Persist', ['$window','lodash', function ($window,
* Save the current router state to localstorage
* @param {object} state State object containing state name and params
*/
- this.setState = function (state) {
+ this.setState = function(state) {
if (this.lsEnabled) {
- localStorage.setItem('state',angular.toJson(state));
+ localStorage.setItem('state', angular.toJson(state));
}
};
diff --git a/app/js/service-serializer.js b/app/js/service-serializer.js
index 17723d5b..a17ffc4d 100755
--- a/app/js/service-serializer.js
+++ b/app/js/service-serializer.js
@@ -1,7 +1,7 @@
/**
* Service managing seralization and deserialization of models for use in URLs and persistene.
*/
-angular.module('app').service('Serializer', ['lodash', function (_) {
+angular.module('app').service('Serializer', ['lodash', function(_) {
/**
* Serializes the ships selected components for all slots to a URL friendly string.
@@ -10,7 +10,7 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
*/
this.fromShip = function(ship) {
var power = {
- enabled: [ship.cargoScoop.enabled? 1 : 0],
+ enabled: [ship.cargoScoop.enabled ? 1 : 0],
priorities: [ship.cargoScoop.priority]
};
@@ -20,9 +20,9 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
_.map(ship.hardpoints, mapGroup, power),
_.map(ship.internal, mapGroup, power),
'.',
- LZString.compressToBase64(power.enabled.join('')).replace(/\//g,'-'),
+ LZString.compressToBase64(power.enabled.join('')).replace(/\//g, '-'),
'.',
- LZString.compressToBase64(power.priorities.join('')).replace(/\//g,'-')
+ LZString.compressToBase64(power.priorities.join('')).replace(/\//g, '-')
];
return _.flatten(data).join('');
@@ -35,11 +35,8 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
* @param {Ship} ship The ship instance to be updated
* @param {string} code The string to deserialize
*/
- this.toShip = function (ship, dataString) {
- var commonCount = ship.common.length,
- hpCount = commonCount + ship.hardpoints.length,
- totalCount = hpCount + ship.internal.length,
- common = new Array(ship.common.length),
+ this.toShip = function(ship, dataString) {
+ var common = new Array(ship.common.length),
hardpoints = new Array(ship.hardpoints.length),
internal = new Array(ship.internal.length),
parts = dataString.split('.'),
@@ -47,12 +44,12 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
enabled = null,
code = parts[0];
- if(parts[1]) {
- enabled = LZString.decompressFromBase64(parts[1].replace(/-/g,'/')).split('');
+ if (parts[1]) {
+ enabled = LZString.decompressFromBase64(parts[1].replace(/-/g, '/')).split('');
}
- if(parts[2]) {
- priorities = LZString.decompressFromBase64(parts[2].replace(/-/g,'/')).split('');
+ if (parts[2]) {
+ priorities = LZString.decompressFromBase64(parts[2].replace(/-/g, '/')).split('');
}
decodeToArray(code, internal, decodeToArray(code, hardpoints, decodeToArray(code, common, 1)));
@@ -61,19 +58,23 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
// - priorities
// - enabled/disabled
- ship.buildWith({
- bulkheads: code.charAt(0) * 1,
- common: common,
- hardpoints: hardpoints,
- internal: internal,
- }, priorities, enabled);
+ ship.buildWith(
+ {
+ bulkheads: code.charAt(0) * 1,
+ common: common,
+ hardpoints: hardpoints,
+ internal: internal
+ },
+ priorities,
+ enabled
+ );
};
- this.fromComparison = function (name, builds, facets, predicate, desc) {
+ this.fromComparison = function(name, builds, facets, predicate, desc) {
var shipBuilds = [];
- builds.forEach(function (b) {
- shipBuilds.push({s: b.id, n: b.buildName, c: this.fromShip(b)});
+ builds.forEach(function(b) {
+ shipBuilds.push({ s: b.id, n: b.buildName, c: this.fromShip(b) });
}.bind(this));
return LZString.compressToBase64(angular.toJson({
@@ -81,12 +82,12 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
b: shipBuilds,
f: facets,
p: predicate,
- d: desc? 1 : 0
- })).replace(/\//g,'-');
+ d: desc ? 1 : 0
+ })).replace(/\//g, '-');
};
- this.toComparison = function (code) {
- return angular.fromJson(LZString.decompressFromBase64(code.replace(/-/g,'/')));
+ this.toComparison = function(code) {
+ return angular.fromJson(LZString.decompressFromBase64(code.replace(/-/g, '/')));
};
/**
@@ -98,14 +99,14 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
* @return {string} The id of the selected component or '-' if none selected
*/
function mapGroup(slot) {
- this.enabled.push(slot.enabled? 1 : 0);
+ this.enabled.push(slot.enabled ? 1 : 0);
this.priorities.push(slot.priority);
- return (slot.id === null)? '-' : slot.id;
+ return slot.id === null ? '-' : slot.id;
}
function decodeToArray(code, arr, codePos) {
- for (i = 0; i < arr.length; i++) {
+ for (var i = 0; i < arr.length; i++) {
if (code.charAt(codePos) == '-') {
arr[i] = 0;
codePos++;
diff --git a/app/js/shipyard/factory-component-set.js b/app/js/shipyard/factory-component-set.js
index 8ba6bcc6..15aeca64 100755
--- a/app/js/shipyard/factory-component-set.js
+++ b/app/js/shipyard/factory-component-set.js
@@ -1,4 +1,10 @@
-angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
+angular.module('shipyard').factory('ComponentSet', ['lodash', function(_) {
+
+ function filter(data, maxClass, minClass, mass) {
+ return _.filter(data, function(c) {
+ return c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass);
+ });
+ }
function ComponentSet(components, mass, maxCommonArr, maxInternal, maxHardPoint) {
this.mass = mass;
@@ -8,7 +14,7 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
this.hpClass = {};
this.intClass = {};
- for (var i = 0; i < components.common.length; i ++) {
+ for (var i = 0; i < components.common.length; i++) {
var max = maxCommonArr[i];
switch (i) {
// Slots where component class must be equal to slot class
@@ -22,21 +28,21 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
}
}
- for(var h in components.hardpoints) {
+ for (var h in components.hardpoints) {
this.hardpoints[h] = filter(components.hardpoints[h], maxHardPoint, 0, this.mass);
}
- for(var g in components.internal) {
+ for (var g in components.internal) {
this.internal[g] = filter(components.internal[g], maxInternal, 0, this.mass);
}
}
ComponentSet.prototype.getHps = function(c) {
- if(!this.hpClass[c]) {
- var o = this.hpClass[c] = {};
- for(var key in this.hardpoints) {
- var data = filter(this.hardpoints[key], c, c? 1 : 0, this.mass);
- if(data.length) { // If group is not empty
+ if (!this.hpClass[c]) {
+ var o = this.hpClass[c] = {};
+ for (var key in this.hardpoints) {
+ var data = filter(this.hardpoints[key], c, c ? 1 : 0, this.mass);
+ if (data.length) { // If group is not empty
o[key] = data;
}
}
@@ -45,11 +51,11 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
};
ComponentSet.prototype.getInts = function(c) {
- if(!this.intClass[c]) {
- var o = this.intClass[c] = {};
- for(var key in this.internal) {
+ if (!this.intClass[c]) {
+ var o = this.intClass[c] = {};
+ for (var key in this.internal) {
var data = filter(this.internal[key], c, 0, this.mass);
- if(data.length) { // If group is not empty
+ if (data.length) { // If group is not empty
o[key] = data;
}
}
@@ -57,12 +63,6 @@ angular.module('shipyard').factory('ComponentSet', ['lodash', function (_) {
return this.intClass[c];
};
- function filter (data, maxClass, minClass, mass) {
- return _.filter(data, function (c) {
- return c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass);
- });
- }
-
return ComponentSet;
}]);
diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js
index d6d026c7..a808b866 100755
--- a/app/js/shipyard/factory-ship.js
+++ b/app/js/shipyard/factory-ship.js
@@ -1,4 +1,4 @@
-angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'lodash', function (Components, calcShieldStrength, calcJumpRange, _) {
+angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, _) {
/**
* Ship model used to track all ship components and properties.
@@ -17,8 +17,8 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (var slotType in slots) { // Initialize all slots
var slotGroup = slots[slotType];
var group = this[slotType] = []; // Initialize Slot group (Common, Hardpoints, Internal)
- for(var i = 0; i < slotGroup.length; i++){
- group.push({id: null, c: null, incCost: true, maxClass: slotGroup[i]});
+ for (var i = 0; i < slotGroup.length; i++) {
+ group.push({ id: null, c: null, incCost: true, maxClass: slotGroup[i] });
}
}
this.c = { incCost: true, c: { name: this.name, cost: this.cost } }; // Make a 'Ship' component similar to other components
@@ -37,11 +37,11 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.powerList.unshift(this.common[0]); // Add Power Plant
this.priorityBands = [
- {deployed: 0, retracted: 0},
- {deployed: 0, retracted: 0},
- {deployed: 0, retracted: 0},
- {deployed: 0, retracted: 0},
- {deployed: 0, retracted: 0}
+ { deployed: 0, retracted: 0 },
+ { deployed: 0, retracted: 0 },
+ { deployed: 0, retracted: 0 },
+ { deployed: 0, retracted: 0 },
+ { deployed: 0, retracted: 0 }
];
// Cumulative and aggragate stats
@@ -64,32 +64,32 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
common = this.common,
hps = this.hardpoints,
bands = this.priorityBands,
- cl = common.length, hl = hps.length, il = internal.length,
- i,l;
+ cl = common.length,
+ i, l;
this.useBulkhead(comps.bulkheads || 0, true);
- this.cargoScoop.priority = priorities? priorities[0] * 1 : 0;
- this.cargoScoop.enabled = enabled? enabled[0] * 1 : true;
+ this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0;
+ this.cargoScoop.enabled = enabled ? enabled[0] * 1 : true;
if (this.cargoScoop.enabled) {
bands[this.cargoScoop.priority].retracted += this.cargoScoop.c.power;
}
- for(i = 0; i < cl; i++) {
- common[i].enabled = enabled? enabled[i + 1] * 1 : true;
- common[i].priority = priorities? priorities[i + 1] * 1 : 0;
+ for (i = 0; i < cl; i++) {
+ common[i].enabled = enabled ? enabled[i + 1] * 1 : true;
+ common[i].priority = priorities ? priorities[i + 1] * 1 : 0;
common[i].type = 'SYS';
this.use(common[i], comps.common[i], Components.common(i, comps.common[i]), true);
}
common[1].type = 'ENG'; // Thrusters
common[2].type = 'ENG'; // FSD
- cl++; // Increase accounting for Cargo Scoop
+ cl++; // Increase accounts for Cargo Scoop
- for(i = 0, l = comps.hardpoints.length; i < l; i++) {
- hps[i].enabled = enabled? enabled[cl + i] * 1 : true;
- hps[i].priority = priorities? priorities[cl + i] * 1 : 0;
- hps[i].type = hps[i].maxClass? 'WEP' : 'SYS';
+ for (i = 0, l = hps.length; i < l; i++) {
+ hps[i].enabled = enabled ? enabled[cl + i] * 1 : true;
+ hps[i].priority = priorities ? priorities[cl + i] * 1 : 0;
+ hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS';
if (comps.hardpoints[i] !== 0) {
this.use(hps[i], comps.hardpoints[i], Components.hardpoints(comps.hardpoints[i]), true);
@@ -98,9 +98,11 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
}
}
- for(i = 0, l = comps.internal.length; i < l; i++) {
- internal[i].enabled = enabled? enabled[hl + cl + i] * 1 : true;
- internal[i].priority = priorities? priorities[hl + cl + i] * 1 : 0;
+ cl += hps.length; // Increase accounts for hardpoints
+
+ for (i = 0, l = internal.length; i < l; i++) {
+ internal[i].enabled = enabled ? enabled[cl + i] * 1 : true;
+ internal[i].priority = priorities ? priorities[cl + i] * 1 : 0;
internal[i].type = 'SYS';
if (comps.internal[i] !== 0) {
@@ -117,7 +119,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
};
Ship.prototype.useBulkhead = function(index, preventUpdate) {
- var oldBulkhead = this.bulkheads.c;
+ var oldBulkhead = this.bulkheads.c;
this.bulkheads.id = index;
this.bulkheads.c = Components.bulkheads(this.id, index);
this.updateStats(this.bulkheads, this.bulkheads.c, oldBulkhead, preventUpdate);
@@ -136,7 +138,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
if (slot.id != id) { // Selecting a different component
var slotIndex = this.internal.indexOf(slot);
// Slot is an internal slot, is not being emptied, and the selected component group/type must be of unique
- if(slotIndex != -1 && component && _.includes(['sg','rf','fs'],component.grp)) {
+ if (slotIndex != -1 && component && _.includes(['sg', 'rf', 'fs'], component.grp)) {
// Find another internal slot that already has this type/group installed
var similarSlotIndex = this.findInternalByGroup(component.grp);
// If another slot has an installed component with of the same type
@@ -163,7 +165,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
* @param {number} fuel Fuel available in tons
* @return {number} Jump range in Light Years
*/
- Ship.prototype.jumpRangeWithMass = function (mass, fuel) {
+ Ship.prototype.jumpRangeWithMass = function(mass, fuel) {
return calcJumpRange(mass, this.common[2].c, fuel);
};
@@ -173,19 +175,19 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
* @param {string} group Component group/type
* @return {number} The index of the slot in ship.internal
*/
- Ship.prototype.findInternalByGroup = function (group) {
- return _.findIndex(this.internal, function (slot) {
+ Ship.prototype.findInternalByGroup = function(group) {
+ return _.findIndex(this.internal, function(slot) {
return slot.c && slot.c.grp == group;
});
};
- Ship.prototype.changePriority = function (slot, newPriority) {
- if(newPriority >= 0 && newPriority < this.priorityBands.length) {
+ Ship.prototype.changePriority = function(slot, newPriority) {
+ if (newPriority >= 0 && newPriority < this.priorityBands.length) {
var oldPriority = slot.priority;
slot.priority = newPriority;
if (slot.enabled) {
- var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1)? 'retracted' : 'deployed';
+ var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1) ? 'retracted' : 'deployed';
this.priorityBands[oldPriority][usage] -= slot.c.power;
this.priorityBands[newPriority][usage] += slot.c.power;
this.updatePower();
@@ -195,36 +197,33 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
return false;
};
- Ship.prototype.setCostIncluded = function (item, included) {
+ Ship.prototype.setCostIncluded = function(item, included) {
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;
};
- Ship.prototype.setSlotEnabled = function (slot, enabled) {
+ Ship.prototype.setSlotEnabled = function(slot, enabled) {
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
- var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1)? 'retracted' : 'deployed';
- this.priorityBands[slot.priority][usage] += enabled? slot.c.power : -slot.c.power;
+ var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1) ? 'retracted' : 'deployed';
+ this.priorityBands[slot.priority][usage] += enabled ? slot.c.power : -slot.c.power;
this.updatePower();
}
slot.enabled = enabled;
};
- Ship.prototype.getSlotStatus = function (slot, deployed) {
- if(!slot.c) { // Empty Slot
+ Ship.prototype.getSlotStatus = function(slot, deployed) {
+ if (!slot.c) { // Empty Slot
return 0; // No Status (Not possible)
- }
- else if (!slot.enabled) {
+ } else if (!slot.enabled) {
return 1; // Disabled
- }
- else if (deployed) {
- return this.priorityBands[slot.priority].deployedSum > this.powerAvailable? 2 : 3; // Offline : Online
- }
- else if (this.hardpoints.indexOf(slot) != -1 && !slot.c.passive) { // Active hardpoints have no retracted status
+ } else if (deployed) {
+ return this.priorityBands[slot.priority].deployedSum > this.powerAvailable ? 2 : 3; // Offline : Online
+ } else if (this.hardpoints.indexOf(slot) != -1 && !slot.c.passive) { // Active hardpoints have no retracted status
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
};
/**
@@ -254,8 +253,8 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.totalCost -= old.cost;
}
- if(old.power) {
- this.priorityBands[slot.priority][(isHardPoint && !old.passive)? 'deployed' : 'retracted'] -= old.power;
+ if (old.power) {
+ this.priorityBands[slot.priority][(isHardPoint && !old.passive) ? 'deployed' : 'retracted'] -= old.power;
powerChange = true;
}
this.unladenMass -= old.mass || 0;
@@ -285,7 +284,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
}
if (n.power) {
- this.priorityBands[slot.priority][(isHardPoint && !n.passive)? 'deployed' : 'retracted'] += n.power;
+ this.priorityBands[slot.priority][(isHardPoint && !n.passive) ? 'deployed' : 'retracted'] += n.power;
powerChange = true;
}
this.unladenMass += n.mass || 0;
@@ -294,7 +293,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity;
this.armourTotal = this.armourAdded + this.armour;
- if(!preventUpdate) {
+ if (!preventUpdate) {
if (powerChange) {
this.updatePower();
}
@@ -307,10 +306,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
var bands = this.priorityBands;
var prevRetracted = 0, prevDeployed = 0;
- for(var i = 0, l = bands.length; i < l; i++) {
+ for (var i = 0, l = bands.length; i < l; i++) {
var band = bands[i];
- prevRetracted = band.retractedSum = prevRetracted + band.retracted;
- prevDeployed = band.deployedSum = prevDeployed + band.deployed + band.retracted;
+ prevRetracted = band.retractedSum = prevRetracted + band.retracted;
+ prevDeployed = band.deployedSum = prevDeployed + band.deployed + band.retracted;
}
this.powerAvailable = this.common[0].c.pGen;
@@ -320,7 +319,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
Ship.prototype.updateShieldStrength = function() {
var sgSI = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
- this.shieldStrength = sgSI != -1? calcShieldStrength(this.mass, this.shields, this.internal[sgSI].c, this.shieldMultiplier) : 0;
+ this.shieldStrength = sgSI != -1 ? calcShieldStrength(this.mass, this.shields, this.internal[sgSI].c, this.shieldMultiplier) : 0;
};
/**
@@ -336,8 +335,8 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.maxJumpCount = Math.ceil(jumps); // Number of full fuel jumps + final jump to empty tank
// Going backwards, start with the last jump using the remaining fuel
- this.unladenTotalRange = fuelRemaining > 0? calcJumpRange(this.unladenMass + fuelRemaining, fsd, fuelRemaining): 0;
- this.ladenTotalRange = fuelRemaining > 0? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining): 0;
+ this.unladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + fuelRemaining, fsd, fuelRemaining) : 0;
+ this.ladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining) : 0;
// For each max fuel jump, calculate the max jump range based on fuel left in the tank
for (var j = 0, l = Math.floor(jumps); j < l; j++) {
diff --git a/app/js/shipyard/module-shipyard.js b/app/js/shipyard/module-shipyard.js
index 8702f923..4a91c034 100755
--- a/app/js/shipyard/module-shipyard.js
+++ b/app/js/shipyard/module-shipyard.js
@@ -22,48 +22,48 @@ angular.module('shipyard', ['ngLodash'])
// Map to lookup group labels/names for component grp
.value('GroupMap', {
// Common
- pp:'Power Plant',
- t:'Thrusters',
- fsd:'Frame Shift Drive',
- ls:'Life Support',
- pd:'Power Distributor',
- s:'Sensors',
- ft:'Fuel Tank',
+ pp: 'Power Plant',
+ t: 'Thrusters',
+ fsd: 'Frame Shift Drive',
+ ls: 'Life Support',
+ pd: 'Power Distributor',
+ s: 'Sensors',
+ ft: 'Fuel Tank',
// Internal
- fs:'Fuel Scoop',
- sc:'Scanners',
- am:'Auto Field-Maint. Unit',
- cr:'Cargo Racks',
- fi:'FSD Interdictor',
- hb:'Hatch Breaker Limpet Ctrl',
- hr:'Hull Reinforcement Package',
- rf:'Refinery',
- scb:'Shield Cell Bank',
- sg:'Shield Generator',
- dc:'Docking Computer',
- fx:'Fuel Transfer Limpet Ctrl',
- pc:'Prospector Limpet Ctrl',
- cc:'Collector Limpet Ctrl',
+ fs: 'Fuel Scoop',
+ sc: 'Scanners',
+ am: 'Auto Field-Maint. Unit',
+ cr: 'Cargo Racks',
+ fi: 'FSD Interdictor',
+ hb: 'Hatch Breaker Limpet Ctrl',
+ hr: 'Hull Reinforcement Package',
+ rf: 'Refinery',
+ scb: 'Shield Cell Bank',
+ sg: 'Shield Generator',
+ dc: 'Docking Computer',
+ fx: 'Fuel Transfer Limpet Ctrl',
+ pc: 'Prospector Limpet Ctrl',
+ cc: 'Collector Limpet Ctrl',
// Hard Points
- bl: "Beam Laser",
- ul: "Burst Laser",
- c: "Cannon",
- cs: "Cargo Scanner",
- cm: "Countermeasure",
- fc: "Fragment Cannon",
- ws: "Frame Shift Wake Scanner",
- kw: "Kill Warrant Scanner",
- nl: "Mine Launcher",
- ml: "Mining Laser",
- mr: "Missile Rack",
- pa: "Plasma Accelerator",
- mc: "Multi-cannon",
- pl: "Pulse Laser",
- rg: "Rail Gun",
- sb: "Shield Booster",
- tp: "Torpedo Pylon"
+ bl: 'Beam Laser',
+ ul: 'Burst Laser',
+ c: 'Cannon',
+ cs: 'Cargo Scanner',
+ cm: 'Countermeasure',
+ fc: 'Fragment Cannon',
+ ws: 'Frame Shift Wake Scanner',
+ kw: 'Kill Warrant Scanner',
+ nl: 'Mine Launcher',
+ ml: 'Mining Laser',
+ mr: 'Missile Rack',
+ pa: 'Plasma Accelerator',
+ mc: 'Multi-cannon',
+ pl: 'Pulse Laser',
+ rg: 'Rail Gun',
+ sb: 'Shield Booster',
+ tp: 'Torpedo Pylon'
})
.value('shipPurpose', {
mp: 'Multi Purpose',
@@ -77,7 +77,7 @@ angular.module('shipyard', ['ngLodash'])
'Small',
'Medium',
'Large',
- 'Capital',
+ 'Capital'
])
.value('hardPointClass', [
'Utility',
@@ -146,7 +146,7 @@ angular.module('shipyard', ['ngLodash'])
},
{ // 8
title: 'Power',
- props: ['powerRetracted','powerDeployed','powerAvailable'],
+ props: ['powerRetracted', 'powerDeployed', 'powerAvailable'],
lbls: ['Retracted', 'Deployed', 'Available'],
unit: 'MW',
fmt: 'fPwr'
@@ -163,7 +163,7 @@ angular.module('shipyard', ['ngLodash'])
lbls: ['Unladen', 'Laden'],
unit: 'LY',
fmt: 'fRound'
- },
+ }
])
/**
* Calculate the maximum single jump range based on mass and a specific FSD
@@ -174,7 +174,7 @@ angular.module('shipyard', ['ngLodash'])
* @return {number} Distance in Light Years
*/
.value('calcJumpRange', function(mass, fsd, fuel) {
- return Math.pow(Math.min(fuel === undefined? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
+ return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
})
/**
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.
@@ -186,7 +186,7 @@ angular.module('shipyard', ['ngLodash'])
* @param {number} multiplier Shield multiplier for ship (1 + shield boosters if any)
* @return {number} Approximate shield strengh in MJ
*/
- .value('calcShieldStrength', function (mass, shields, sg, multiplier) {
+ .value('calcShieldStrength', function(mass, shields, sg, multiplier) {
if (!sg) {
return 0;
}
diff --git a/app/js/shipyard/service-components.js b/app/js/shipyard/service-components.js
index ac9c1e95..8c023ada 100755
--- a/app/js/shipyard/service-components.js
+++ b/app/js/shipyard/service-components.js
@@ -1,10 +1,10 @@
-angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'ShipsDB', 'ComponentSet', function (_, C, Ships, ComponentSet) {
+angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'ShipsDB', 'ComponentSet', function(_, C, Ships, ComponentSet) {
this.cargoScoop = function() {
- return { name: 'Cargo Hatch', class: 1, rating: 'H', power: 0.6};
+ return { name: 'Cargo Hatch', class: 1, rating: 'H', power: 0.6 };
};
- this.common = function (typeIndex, componentId) {
+ this.common = function(typeIndex, componentId) {
return C.common[typeIndex][componentId];
};
@@ -12,7 +12,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
for (var n in C.hardpoints) {
var group = C.hardpoints[n];
for (var i = 0; i < group.length; i++) {
- if (group[i].id == id) {
+ if (group[i].id === id) {
return group[i];
}
}
@@ -24,7 +24,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
for (var n in C.internal) {
var group = C.internal[n];
for (var i = 0; i < group.length; i++) {
- if (group[i].id == id) {
+ if (group[i].id === id) {
return group[i];
}
}
@@ -49,9 +49,9 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
* @param {string} shipId Unique ship Id/Key
* @return {ComponentSet} The set of components the ship can install
*/
- this.forShip = function (shipId) {
+ this.forShip = function(shipId) {
var ship = Ships[shipId];
return new ComponentSet(C, ship.properties.mass + 5, ship.slots.common, ship.slots.internal[0], ship.slots.hardpoints[0]);
};
-}]);
\ No newline at end of file
+}]);
From cc2d91cc517d5ccaf4d16f09bf7e08aa6031f7fc Mon Sep 17 00:00:00 2001
From: Colin McLeod
Date: Thu, 11 Jun 2015 21:04:52 -0700
Subject: [PATCH 05/53] Adding karma and unit tests to get started
---
gulpfile.js | 12 ++++--
package.json | 5 +++
test/karma.conf.js | 34 +++++++++++++++++
test/tests/test-data.js | 66 ++++++++++++++++++++++++++++++++
test/tests/test-factory-ship.js | 35 +++++++++++++++++
tests/test-data.js | 68 ---------------------------------
6 files changed, 148 insertions(+), 72 deletions(-)
create mode 100644 test/karma.conf.js
create mode 100644 test/tests/test-data.js
create mode 100644 test/tests/test-factory-ship.js
delete mode 100644 tests/test-data.js
diff --git a/gulpfile.js b/gulpfile.js
index deba614b..2a16e8b8 100755
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -10,8 +10,8 @@ var appCache = require("gulp-manifest"),
eslint = require('gulp-eslint');
gutil = require('gulp-util'),
htmlmin = require('gulp-htmlmin'),
- jasmine = require('gulp-jasmine'),
jsonlint = require("gulp-jsonlint"),
+ karma = require('karma').server,
less = require('gulp-less'),
mainBowerFiles = require('main-bower-files'),
minifyCSS = require('gulp-minify-css'),
@@ -252,9 +252,13 @@ gulp.task('upload', function(done) {
);
});
-gulp.task('test', function () {
- return gulp.src('tests/test-*.js')
- .pipe(jasmine());
+gulp.task('test', function (done) {
+ karma.start({
+ configFile: __dirname + '/test/karma.conf.js',
+ singleRun: true
+ }, function(exitStatus) {
+ done(exitStatus ? new gutil.PluginError('karma', { message: 'Unit tests failed!' }) : undefined);
+ });
});
gulp.task('lint', ['js-lint', 'json-lint']);
diff --git a/package.json b/package.json
index 31414320..a6d27931 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"engine": "node >= 0.12.2",
"dependencies": {},
"devDependencies": {
+ "angular-mocks": "^1.3.16",
"async": "^0.9.0",
"del": "^1.1.1",
"gulp": "^3.8.11",
@@ -28,7 +29,11 @@
"gulp-template": "^3.0.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
+ "jasmine-core": "^2.3.4",
"json-concat": "0.0.0",
+ "karma": "^0.12.36",
+ "karma-chrome-launcher": "^0.1.12",
+ "karma-jasmine": "^0.3.5",
"main-bower-files": "^2.6.2",
"run-sequence": "^1.0.2",
"uglify-js": "^2.4.19"
diff --git a/test/karma.conf.js b/test/karma.conf.js
new file mode 100644
index 00000000..03f3c6cc
--- /dev/null
+++ b/test/karma.conf.js
@@ -0,0 +1,34 @@
+// Karma configuration
+// Generated on Thu Jun 11 2015 19:39:40 GMT-0700 (PDT)
+
+module.exports = function(config) {
+ config.set({
+ basePath: '',
+ // frameworks to use
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: ['jasmine'],
+ // list of files / patterns to load in the browser
+ files: [
+ '../build/lib*.js',
+ '../node_modules/angular-mocks/angular-mocks.js',
+ '../build/app*.js',
+ 'tests/**/*.js'
+ ],
+ // list of files to exclude
+ exclude: [],
+ // preprocess matching files before serving them to the browser
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: {},
+ // test results reporter to use
+ // possible values: 'dots', 'progress'
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['progress'],
+ port: 9876,
+ colors: true,
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+ autoWatch: false,
+ browsers: ['Chrome'],
+ singleRun: false
+ });
+};
diff --git a/test/tests/test-data.js b/test/tests/test-data.js
new file mode 100644
index 00000000..3523e70f
--- /dev/null
+++ b/test/tests/test-data.js
@@ -0,0 +1,66 @@
+describe("Database", function() {
+
+ var shipProperties = ["grp", "name", "manufacturer", "class", "cost", "speed", "boost", "agility", "shields", "armour", "fuelcost", "mass"];
+
+ it("has ships and components", function() {
+ expect(DB.ships).toBeDefined()
+ expect(DB.components.common).toBeDefined();
+ expect(DB.components.hardpoints).toBeDefined();
+ expect(DB.components.internal).toBeDefined();
+ expect(DB.components.bulkheads).toBeDefined();
+ });
+
+ it("has unique IDs for every hardpoint", function() {
+ var ids = {};
+ var groups = DB.components.hardpoints;
+
+ for (var g in groups) {
+ var group = groups[g];
+ for (var i = 0; i < group.length; i++) {
+ var id = group[i].id;
+ expect(ids[id]).toBeFalsy('ID already exists: ' + id);
+ expect(group[i].grp).toBeDefined('Hardpoint has no group defined, ID:' + id);
+ ids[id] = true;
+ }
+ }
+ });
+
+ it("has valid internal components", function() {
+ var ids = {};
+ var groups = DB.components.internal;
+
+ for (var g in groups) {
+ var group = groups[g];
+ for (var i = 0; i < group.length; i++) {
+ var id = group[i].id;
+ expect(ids[id]).toBeFalsy('ID already exists: ' + id);
+ expect(group[i].grp).toBeDefined('Internal component has no group defined, ID:' + id);
+ ids[id] = true;
+ }
+ }
+ });
+
+ it("has data for every ship", function() {
+ for (var s in DB.ships) {
+ for (var p = 0; p < shipProperties.length; p++) {
+ expect(DB.ships[s].properties[shipProperties[p]]).toBeDefined(shipProperties[p] + ' is missing for ' + s);
+ }
+ expect(DB.ships[s].slots.common.length).toEqual(7, s + ' is missing common slots');
+ expect(DB.ships[s].defaults.common.length).toEqual(7, s + ' is missing common defaults');
+ expect(DB.ships[s].slots.hardpoints.length).toEqual(DB.ships[s].defaults.hardpoints.length, s + ' hardpoint slots and defaults dont match');
+ expect(DB.ships[s].slots.internal.length).toEqual(DB.ships[s].defaults.internal.length, s + ' hardpoint slots and defaults dont match');
+ expect(DB.ships[s].retailCost).toBeGreaterThan(DB.ships[s].properties.cost, s + ' has invalid retail cost');
+ expect(DB.components.bulkheads[s]).toBeDefined(s + ' is missing bulkheads');
+ }
+ });
+
+ it("has components with a group defined", function() {
+ for (var i = 0; i < DB.components.common.length; i++) {
+ var group = DB.components.common[i];
+ for (var c in group) {
+ expect(group[c].grp).toBeDefined('Common component has no group defined, Type: ' + i + ', ID: ' + c);
+ }
+ }
+ });
+
+});
diff --git a/test/tests/test-factory-ship.js b/test/tests/test-factory-ship.js
new file mode 100644
index 00000000..b59c6d5c
--- /dev/null
+++ b/test/tests/test-factory-ship.js
@@ -0,0 +1,35 @@
+describe("Ship Factory", function() {
+
+ var Ship;
+
+ beforeEach(module('shipyard'));
+ beforeEach(inject(['Ship', function (_Ship_) {
+ Ship = _Ship_;
+ }]));
+
+ it("can build all ships", function() {
+ for (var s in DB.ships) {
+ var shipData = DB.ships[s];
+ var ship = new Ship(s, shipData.properties, shipData.slots);
+
+ for (p in shipData.properties) {
+ expect(ship[p]).toEqual(shipData.properties[p], s + ' property [' + p + '] does not match when built');
+ }
+
+ ship.buildWith(shipData.defaults);
+
+ expect(ship.totalCost).toEqual(shipData.retailCost, s + ' retail cost does not match default build cost');
+ expect(ship.priorityBands[0].retracted).toBeGreaterThan(0);
+ expect(ship.powerAvailable).toBeGreaterThan(0);
+ expect(ship.unladenRange).toBeGreaterThan(0);
+ expect(ship.ladenRange).toBeGreaterThan(0);
+ expect(ship.cargoCapacity).toBeGreaterThan(0);
+ expect(ship.fuelCapacity).toBeGreaterThan(0);
+ expect(ship.unladenTotalRange).toBeGreaterThan(0);
+ expect(ship.ladenTotalRange).toBeGreaterThan(0);
+ expect(ship.shieldStrength).toBeGreaterThan(0);
+ expect(ship.armourTotal).toBeGreaterThan(0);
+ }
+ });
+
+});
\ No newline at end of file
diff --git a/tests/test-data.js b/tests/test-data.js
deleted file mode 100644
index bf652a8d..00000000
--- a/tests/test-data.js
+++ /dev/null
@@ -1,68 +0,0 @@
-var data = require('../app/db.json');
-
-var shipProperties = ["grp", "name", "manufacturer", "class", "cost", "speed", "boost", "agility", "shields", "armour", "fuelcost", "mass"];
-
-describe("Database", function() {
-
- it("has ships and components", function() {
- expect(data.ships).toBeDefined()
- expect(data.components.common).toBeDefined();
- expect(data.components.hardpoints).toBeDefined();
- expect(data.components.internal).toBeDefined();
- expect(data.components.bulkheads).toBeDefined();
- });
-
- it("has unique IDs for every hardpoint", function() {
- var ids = {};
- var groups = data.components.hardpoints;
-
- for (var g in groups) {
- var group = groups[g];
- for (var i = 0; i < group.length; i++) {
- var id = group[i].id;
- expect(ids[id]).toBeFalsy('ID already exists: ' + id);
- expect(group[i].grp).toBeDefined('Hardpoint has no group defined, ID:' + id);
- ids[id] = true;
- }
- }
- });
-
- it("has valid internal components", function() {
- var ids = {};
- var groups = data.components.internal;
-
- for (var g in groups) {
- var group = groups[g];
- for (var i = 0; i < group.length; i++) {
- var id = group[i].id;
- expect(ids[id]).toBeFalsy('ID already exists: ' + id);
- expect(group[i].grp).toBeDefined('Internal component has no group defined, ID:' + id);
- ids[id] = true;
- }
- }
- });
-
- it("has data for every ship", function() {
- for (var s in data.ships) {
- for (var p = 0; p < shipProperties.length; p++) {
- expect(data.ships[s].properties[shipProperties[p]]).toBeDefined(shipProperties[p] + ' is missing for ' + s);
- }
- expect(data.ships[s].slots.common.length).toEqual(7, s + ' is missing common slots');
- expect(data.ships[s].defaults.common.length).toEqual(7, s + ' is missing common defaults');
- expect(data.ships[s].slots.hardpoints.length).toEqual(data.ships[s].defaults.hardpoints.length, s + ' hardpoint slots and defaults dont match');
- expect(data.ships[s].slots.internal.length).toEqual(data.ships[s].defaults.internal.length, s + ' hardpoint slots and defaults dont match');
- expect(data.ships[s].retailCost).toBeGreaterThan(data.ships[s].properties.cost, s + ' has invalid retail cost');
- expect(data.components.bulkheads[s]).toBeDefined(s + ' is missing bulkheads');
- }
- });
-
- it("has components with a group defined", function() {
- for (var i = 0; i < data.components.common.length; i++) {
- var group = data.components.common[i];
- for (var c in group) {
- expect(group[c].grp).toBeDefined('Common component has no group defined, Type: ' + i + ', ID: ' + c);
- }
- }
- });
-
-});
From 3b02536cf746ddf93d17c092083437ed426c0be0 Mon Sep 17 00:00:00 2001
From: Colin McLeod
Date: Thu, 11 Jun 2015 21:05:39 -0700
Subject: [PATCH 06/53] Fix some power bugs
---
app/js/shipyard/factory-ship.js | 26 ++++++++++++++++++--------
app/js/shipyard/service-components.js | 4 ++--
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js
index a808b866..3e97d552 100755
--- a/app/js/shipyard/factory-ship.js
+++ b/app/js/shipyard/factory-ship.js
@@ -71,6 +71,11 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0;
this.cargoScoop.enabled = enabled ? enabled[0] * 1 : true;
+ for (i = 0, l = this.priorityBands.length; i < l; i++) {
+ this.priorityBands[i].deployed = 0;
+ this.priorityBands[i].retracted = 0;
+ }
+
if (this.cargoScoop.enabled) {
bands[this.cargoScoop.priority].retracted += this.cargoScoop.c.power;
}
@@ -79,6 +84,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
common[i].enabled = enabled ? enabled[i + 1] * 1 : true;
common[i].priority = priorities ? priorities[i + 1] * 1 : 0;
common[i].type = 'SYS';
+ common[i].c = common[i].id = null; // Resetting 'old' component if there was one
this.use(common[i], comps.common[i], Components.common(i, comps.common[i]), true);
}
@@ -90,11 +96,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
hps[i].enabled = enabled ? enabled[cl + i] * 1 : true;
hps[i].priority = priorities ? priorities[cl + i] * 1 : 0;
hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS';
+ hps[i].c = hps[i].id = null; // Resetting 'old' component if there was one
if (comps.hardpoints[i] !== 0) {
this.use(hps[i], comps.hardpoints[i], Components.hardpoints(comps.hardpoints[i]), true);
- } else {
- hps[i].c = hps[i].id = null;
}
}
@@ -104,11 +109,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
internal[i].enabled = enabled ? enabled[cl + i] * 1 : true;
internal[i].priority = priorities ? priorities[cl + i] * 1 : 0;
internal[i].type = 'SYS';
+ internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one
if (comps.internal[i] !== 0) {
this.use(internal[i], comps.internal[i], Components.internal(comps.internal[i]), true);
- } else {
- internal[i].id = internal[i].c = null;
}
}
@@ -181,18 +185,24 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
});
};
+ /**
+ * Will change the priority of the specified slot if the new priority is valid
+ * @param {object} slot The slot to be updated
+ * @param {number} newPriority The new priority to be set
+ * @return {boolean} Returns true if the priority was changed (within range)
+ */
Ship.prototype.changePriority = function(slot, newPriority) {
if (newPriority >= 0 && newPriority < this.priorityBands.length) {
var oldPriority = slot.priority;
slot.priority = newPriority;
- if (slot.enabled) {
+ if (slot.enabled) { // Only update power if the slot is enabled
var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1) ? 'retracted' : 'deployed';
this.priorityBands[oldPriority][usage] -= slot.c.power;
this.priorityBands[newPriority][usage] += slot.c.power;
this.updatePower();
- return true;
}
+ return true;
}
return false;
};
@@ -253,7 +263,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.totalCost -= old.cost;
}
- if (old.power) {
+ if (old.power && slot.enabled) {
this.priorityBands[slot.priority][(isHardPoint && !old.passive) ? 'deployed' : 'retracted'] -= old.power;
powerChange = true;
}
@@ -283,7 +293,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.totalCost += n.cost;
}
- if (n.power) {
+ if (n.power && slot.enabled) {
this.priorityBands[slot.priority][(isHardPoint && !n.passive) ? 'deployed' : 'retracted'] += n.power;
powerChange = true;
}
diff --git a/app/js/shipyard/service-components.js b/app/js/shipyard/service-components.js
index 8c023ada..05a8f202 100755
--- a/app/js/shipyard/service-components.js
+++ b/app/js/shipyard/service-components.js
@@ -12,7 +12,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
for (var n in C.hardpoints) {
var group = C.hardpoints[n];
for (var i = 0; i < group.length; i++) {
- if (group[i].id === id) {
+ if (group[i].id == id) {
return group[i];
}
}
@@ -24,7 +24,7 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
for (var n in C.internal) {
var group = C.internal[n];
for (var i = 0; i < group.length; i++) {
- if (group[i].id === id) {
+ if (group[i].id == id) {
return group[i];
}
}
From 2498c0e0b129028d693eada398190287d3e72f64 Mon Sep 17 00:00:00 2001
From: Colin McLeod
Date: Thu, 11 Jun 2015 21:10:57 -0700
Subject: [PATCH 07/53] Fix tests to pass build
---
test/tests/test-factory-ship.js | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/test/tests/test-factory-ship.js b/test/tests/test-factory-ship.js
index b59c6d5c..084829dc 100644
--- a/test/tests/test-factory-ship.js
+++ b/test/tests/test-factory-ship.js
@@ -19,16 +19,15 @@ describe("Ship Factory", function() {
ship.buildWith(shipData.defaults);
expect(ship.totalCost).toEqual(shipData.retailCost, s + ' retail cost does not match default build cost');
- expect(ship.priorityBands[0].retracted).toBeGreaterThan(0);
- expect(ship.powerAvailable).toBeGreaterThan(0);
- expect(ship.unladenRange).toBeGreaterThan(0);
- expect(ship.ladenRange).toBeGreaterThan(0);
- expect(ship.cargoCapacity).toBeGreaterThan(0);
- expect(ship.fuelCapacity).toBeGreaterThan(0);
- expect(ship.unladenTotalRange).toBeGreaterThan(0);
- expect(ship.ladenTotalRange).toBeGreaterThan(0);
- expect(ship.shieldStrength).toBeGreaterThan(0);
- expect(ship.armourTotal).toBeGreaterThan(0);
+ expect(ship.priorityBands[0].retracted).toBeGreaterThan(0, s + ' cargo');
+ expect(ship.powerAvailable).toBeGreaterThan(0, s + ' powerAvailable');
+ expect(ship.unladenRange).toBeGreaterThan(0, s + ' unladenRange');
+ expect(ship.ladenRange).toBeGreaterThan(0, s + ' ladenRange');
+ expect(ship.fuelCapacity).toBeGreaterThan(0, s + ' fuelCapacity');
+ expect(ship.unladenTotalRange).toBeGreaterThan(0, s + ' unladenTotalRange');
+ expect(ship.ladenTotalRange).toBeGreaterThan(0, s + ' ladenTotalRange');
+ expect(ship.shieldStrength).toBeGreaterThan(0, s + ' shieldStrength');
+ expect(ship.armourTotal).toBeGreaterThan(0, s + ' armourTotal');
}
});
From 31579213b1acb0d8ea70f8742428a7c23ea1249b Mon Sep 17 00:00:00 2001
From: Colin McLeod
Date: Thu, 11 Jun 2015 23:01:14 -0700
Subject: [PATCH 08/53] Responsive build menu improvements, donate button tweak
---
app/less/header.less | 34 +++++++++++++++++++++++++++-------
app/views/_header.html | 16 +++++++++-------
app/views/modal-about.html | 2 +-
3 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/app/less/header.less b/app/less/header.less
index 2f30123c..02e919d1 100755
--- a/app/less/header.less
+++ b/app/less/header.less
@@ -63,7 +63,7 @@ header {
.menu-item-label {
margin-left: 1em;
- .medPhone({
+ .largePhone({
display: none;
});
}
@@ -92,21 +92,41 @@ header {
.tablet({
- a {
+ li, a {
padding: 0.3em 0;
}
});
+ }
+ .dbl {
+ -webkit-column-count: 2; /* Chrome, Safari, Opera */
+ -moz-column-count: 2; /* Firefox */
+ column-count: 2;
+ ul {
+ min-width: 10em;
+ }
+ .smallTablet({
+ -webkit-column-count: 3; /* Chrome, Safari, Opera */
+ -moz-column-count: 3; /* Firefox */
+ column-count: 3;
- &.dbl {
+ ul {
+ min-width: 20em;
+ }
+ });
+
+ .largePhone({
-webkit-column-count: 2; /* Chrome, Safari, Opera */
-moz-column-count: 2; /* Firefox */
column-count: 2;
- ul {
- width: 10em;
- }
- }
+ });
+
+ .smallPhone({
+ -webkit-column-count: 1; /* Chrome, Safari, Opera */
+ -moz-column-count: 1; /* Firefox */
+ column-count: 1;
+ });
}
ul {
diff --git a/app/views/_header.html b/app/views/_header.html
index 162878b7..b7580acc 100755
--- a/app/views/_header.html
+++ b/app/views/_header.html
@@ -18,13 +18,15 @@
Builds
-
-
- {{ships[shipId].properties.name}}
-
-
-
-
+
+
+
+ {{ships[shipId].properties.name}}
+
+
+
+
+
diff --git a/app/views/modal-about.html b/app/views/modal-about.html
index 962f8bfc..85b5c887 100755
--- a/app/views/modal-about.html
+++ b/app/views/modal-about.html
@@ -16,7 +16,7 @@
Any and all contributions and feedback are welcome. If you encounter any bugs please report them and provide as much detail as possible.