mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 14:33:22 +00:00
JShint fixes
This commit is contained in:
1
.jshintignore
Normal file
1
.jshintignore
Normal file
@@ -0,0 +1 @@
|
||||
app/js/db.js
|
||||
@@ -1,9 +1,9 @@
|
||||
angular.module('app', ['ngRoute','shipyard','ngLodash','app.templates'])
|
||||
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
//$locationProvider.html5Mode(true);
|
||||
$routeProvider
|
||||
.when('/:ship', { templateUrl: 'views/ship.html', controller: 'ShipController' })
|
||||
.when('/', { templateUrl: 'views/ships.html', controller: 'ShipyardController' })
|
||||
.when('/', { templateUrl: 'views/ships.html', controller: 'ShipyardController' });
|
||||
|
||||
}])
|
||||
.run(['$rootScope','commonArray','shipPurpose', 'shipSize', 'hardPointClass', 'internalGroupMap', function ($rootScope, CArr, shipPurpose, sz, hpc, igMap) {
|
||||
@@ -23,7 +23,7 @@ angular.module('app', ['ngRoute','shipyard','ngLodash','app.templates'])
|
||||
$rootScope.fPct = d3.format(',.2%');
|
||||
|
||||
$rootScope.calcJumpRange = function(mass, fsd, fuel) {
|
||||
return Math.pow( (fuel || fsd.maxfuel) / fds.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||
return Math.pow( (fuel || fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||
};
|
||||
|
||||
// TODO: Load Saved Ships List from Local Storage
|
||||
|
||||
@@ -5,6 +5,6 @@ angular.module('app')
|
||||
$scope.availCS = Components.forShip($scope.shipId);
|
||||
|
||||
// for debugging
|
||||
window.ship = $scope.ship;
|
||||
window.availcs = $scope.availCS;
|
||||
//window.ship = $scope.ship;
|
||||
//window.availcs = $scope.availCS;
|
||||
}]);
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module('app')
|
||||
.controller('ShipyardController', ['$rootScope', '$scope', function ($rootScope, $scope) {
|
||||
.controller('ShipyardController', function () {
|
||||
|
||||
}]);
|
||||
});
|
||||
@@ -1,14 +1,11 @@
|
||||
angular.module('app').directive('costList', ['$rootScope', 'lodash', function ($r, _) {
|
||||
angular.module('app').directive('costList', ['$rootScope', function ($r) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
ship: '='
|
||||
},
|
||||
templateUrl: 'views/costs.html',
|
||||
link: function (scope, element, attributes) {
|
||||
scope.hps = ship.hardpoints;
|
||||
scope.ints = ship.internal;
|
||||
scope.com = ship.common;
|
||||
link: function (scope) {
|
||||
scope.$r = $r;
|
||||
scope.insuranceOptions = {
|
||||
Alpha: 0.975,
|
||||
@@ -20,7 +17,7 @@ angular.module('app').directive('costList', ['$rootScope', 'lodash', function ($
|
||||
scope.toggle = function(item) {
|
||||
item.incCost = !item.incCost;
|
||||
scope.ship.updateTotals();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -1,18 +1,18 @@
|
||||
angular.module('app')
|
||||
.directive('powerList', ['$rootScope', 'lodash', function ($r, _) {
|
||||
.directive('powerList', ['$rootScope', function ($r) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
ship: '=ship'
|
||||
},
|
||||
templateUrl: 'views/power.html',
|
||||
link: function (scope, element, attributes) {
|
||||
link: function (scope) {
|
||||
scope.$r = $r;
|
||||
|
||||
scope.toggle = function(slot) {
|
||||
slot.enabled = !slot.enabled;
|
||||
scope.ship.updateTotals();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -1,13 +1,13 @@
|
||||
angular.module('app').directive('shipyardMenu', ['$rootScope', 'lodash', function ($rootScope, _) {
|
||||
angular.module('app').directive('shipyardMenu', function () {
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'views/menu.html',
|
||||
link: function (scope, element, attributes) {
|
||||
link: function () {
|
||||
|
||||
// TODO: Saved Ships: load, save, save as, delete, export
|
||||
// TODO: Links: github, forum, etc
|
||||
|
||||
}
|
||||
};
|
||||
}]);
|
||||
});
|
||||
@@ -10,7 +10,8 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
this.id = id;
|
||||
this.defaults = shipData.defaultComponents;
|
||||
this.incCost = true;
|
||||
this.cargoScoop = { enabled: true, c: { name: 'Cargo Scoop', class: 1, rating: 'H', power: .6} };
|
||||
this.cargoScoop = { enabled: true, c: { name: 'Cargo Scoop', class: 1, rating: 'H', power: 0.6} };
|
||||
this.sgSI = null; // Shield Generator Slot Index
|
||||
|
||||
angular.forEach(shipData,function(o,k){
|
||||
if(typeof o != 'object') {
|
||||
@@ -25,7 +26,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
maxClass: arr[i]
|
||||
});
|
||||
}
|
||||
}.bind(this))
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
@@ -55,29 +56,30 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
var availCommon = DB.components.common;
|
||||
var availHardPoints = DB.components.hardpoints;
|
||||
var availInternal = DB.components.internal;
|
||||
var i,l;
|
||||
|
||||
this.bulkheads = { incCost: true, id: comps.bulkheads || 0, c: DB.components.bulkheads[this.id][comps.bulkheads || 0] };
|
||||
|
||||
for(var i = 0, l = comps.common.length; i < l; i++) {
|
||||
for(i = 0, l = comps.common.length; i < l; i++) {
|
||||
common[i].id = comps.common[i];
|
||||
common[i].c = availCommon[i][comps.common[i]];
|
||||
}
|
||||
|
||||
for(var i = 0, l = comps.hardpoints.length; i < l; i++) {
|
||||
for(i = 0, l = comps.hardpoints.length; i < l; i++) {
|
||||
if(comps.hardpoints[i] !== 0) {
|
||||
hps[i].id = comps.hardpoints[i];
|
||||
hps[i].c = availHardPoints[comps.hardpoints[i]];
|
||||
}
|
||||
}
|
||||
|
||||
for(var i = 0, l = comps.internal.length; i < l; i++) {
|
||||
for(i = 0, l = comps.internal.length; i < l; i++) {
|
||||
if(comps.internal[i] !== 0) {
|
||||
internal[i].id = comps.internal[i];
|
||||
internal[i].c = availInternal[comps.internal[i]];
|
||||
}
|
||||
}
|
||||
this.updateTotals();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Serializes the selected components for all slots to a URL friendly string.
|
||||
@@ -103,7 +105,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
* @return {string} The id of the selected component or '-' if none selected
|
||||
*/
|
||||
function idToStr(slot) {
|
||||
return o.id === undefined? '-' : o.id;
|
||||
return slot.id === undefined? '-' : slot.id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +130,9 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
if (c < commonCount) {
|
||||
comps.common[c] = code.substring(i, i + 2);
|
||||
} else if (c < hpCount) {
|
||||
comps.hardpoints[c - commonCount] = code.substring(i, i + 2)
|
||||
comps.hardpoints[c - commonCount] = code.substring(i, i + 2);
|
||||
} else {
|
||||
comps.internal[c - hpCount] = code.substring(i, i + 2)
|
||||
comps.internal[c - hpCount] = code.substring(i, i + 2);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -138,7 +140,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
}
|
||||
|
||||
this.defaults = comps;
|
||||
this.buildWidth(data);
|
||||
this.buildWidth(comps);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -159,32 +161,37 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
this.powerDeployed = this.powerRetracted + h.power;
|
||||
|
||||
// TODO: range
|
||||
this.calcShieldStrength = this.sgSI !== null? calcShieldStrength(this.mass, this.shields, this.internal[this.sgSI], 1) : 0;
|
||||
this.armourAdded = 0; // internal.armoradd TODO: Armour (reinforcement, bulkheads)
|
||||
this.armorTotal = this.armourAdded + this.armour;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a slot with a the component if the id is different from the current id for this slot.
|
||||
* Frees the slot of the current component if the id matches the current id for the slot.
|
||||
*
|
||||
* @param {object} slot The component slot
|
||||
* @param {string} id Unique ID for the selected component
|
||||
* @param {object} componentData Properties for the selected component
|
||||
* @param {object} slot The component slot
|
||||
* @param {string} id Unique ID for the selected component
|
||||
* @param {object} component Properties for the selected component
|
||||
*/
|
||||
Ship.prototype.use = function(slot, id, componentData) {
|
||||
if (slot.id != id) { // Selecting a different option
|
||||
Ship.prototype.use = function(slot, id, component) {
|
||||
if (slot.id != id) { // Selecting a different component
|
||||
slot.id = id;
|
||||
slot.c = componentData;
|
||||
slot.c = component;
|
||||
|
||||
// New componnent is a Shield Generator
|
||||
if(componentData.group == 'sg') {
|
||||
// Selected componnent is a Shield Generator
|
||||
if(component.group == 'sg') {
|
||||
var slotIndex = this.internal.indexOf(slot);
|
||||
// You can only have one shield Generator
|
||||
// TODO: find shield generator that is not this one
|
||||
// set c.id = null, c.c = null;
|
||||
if (this.sgSI !== null && this.sgSI != slotIndex) {
|
||||
// A shield generator is already selected in a different slot
|
||||
this.internal[this.sgSI].id = null;
|
||||
this.internal[this.sgSI].c = null;
|
||||
}
|
||||
this.sgSI = slotIndex;
|
||||
}
|
||||
// Deselecting current option
|
||||
} else {
|
||||
// Deselect current component
|
||||
slot.id = null;
|
||||
slot.c = null;
|
||||
}
|
||||
@@ -212,7 +219,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
return shields * multiplier * (sg.optmul + (mass - sg.optmass) / (sg.maxmass - sg.optmass) * (sg.maxmul - sg.optmul));
|
||||
}
|
||||
return shields * multiplier * sg.maxmul;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilify function for summing the components properties
|
||||
|
||||
@@ -69,8 +69,6 @@ angular.module('shipyard', [])
|
||||
case 'u':
|
||||
l.push('Utility');
|
||||
break;
|
||||
default:
|
||||
console.error('Invalid group size', grp);
|
||||
}
|
||||
switch(a[1]) {
|
||||
case 'o':
|
||||
@@ -91,8 +89,6 @@ angular.module('shipyard', [])
|
||||
case 'm':
|
||||
l.push('Mount');
|
||||
break;
|
||||
default:
|
||||
console.error('Invalid group category', grp);
|
||||
}
|
||||
return l.join(' ');
|
||||
}
|
||||
|
||||
@@ -23,7 +23,12 @@ gulp.task('less', function() {
|
||||
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src('app/js/**/*.js')
|
||||
.pipe(jshint())
|
||||
.pipe(jshint({
|
||||
undef: true,
|
||||
unused: true,
|
||||
curly: true,
|
||||
predef: [ "angular",'DB','d3' ]
|
||||
}))
|
||||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
@@ -121,6 +126,7 @@ gulp.task('watch', function() {
|
||||
gulp.watch('app/less/*.less', ['less']);
|
||||
gulp.watch('app/views/**/*', ['html2js']);
|
||||
gulp.watch('app/js/**/*.js', ['js']);
|
||||
gulp.watch('data/**/*.json', ['jsonToDB']);
|
||||
});
|
||||
|
||||
gulp.task('clean', function (done) { del(['build'], done); });
|
||||
|
||||
Reference in New Issue
Block a user