Linting fixes

This commit is contained in:
Colin McLeod
2015-06-11 17:23:13 -07:00
parent c80e0a51bf
commit 3f8cf106a1
27 changed files with 470 additions and 470 deletions

View File

@@ -1,48 +1,49 @@
angular.module('app').controller('ComparisonController', ['lodash', '$rootScope', '$filter', '$scope', '$state', '$stateParams', 'Utils', 'ShipFacets', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function (_, $rootScope, $filter, $scope, $state, $stateParams, Utils, ShipFacets, Ships, Ship, Persist, Serializer) {
angular.module('app').controller('ComparisonController', ['lodash', '$rootScope', '$filter', '$scope', '$state', '$stateParams', 'Utils', 'ShipFacets', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function(_, $rootScope, $filter, $scope, $state, $stateParams, Utils, ShipFacets, Ships, Ship, Persist, Serializer) {
$rootScope.title = 'Coriolis - Compare';
$scope.predicate = 'name'; // Sort by ship name as default
$scope.desc = false;
$scope.facetSortOpts = { containment: '#facet-container', orderChanged: function () { $scope.saved = false; } };
$scope.facetSortOpts = { containment: '#facet-container', orderChanged: function() { $scope.saved = false; } };
$scope.builds = [];
$scope.unusedBuilds = [];
$scope.name = $stateParams.name;
$scope.compareMode = !$stateParams.code;
$scope.importObj = {}; // Used for importing comparison builds (from permalinked comparison)
var defaultFacets = [9,6,4,1,3,2]; // Reverse order of Armour, Shields, Speed, Jump Range, Cargo Capacity, Cost
var defaultFacets = [9, 6, 4, 1, 3, 2]; // Reverse order of Armour, Shields, Speed, Jump Range, Cargo Capacity, Cost
var facets = $scope.facets = angular.copy(ShipFacets);
var shipId, buildName, comparisonData;
/**
* Add an existing build to the comparison. The build must be saved locally.
* @param {string} shipId The unique ship key/id
* @param {string} buildName The build name
* @param {string} id The unique ship key/id
* @param {string} name The build name
*/
$scope.addBuild = function (shipId, buildName, code) {
var data = Ships[shipId]; // Get ship properties
code = code? code : Persist.builds[shipId][buildName]; // Retrieve build code if not passed
var b = new Ship(shipId, data.properties, data.slots); // Create a new Ship instance
$scope.addBuild = function(id, name, code) {
var data = Ships[id]; // Get ship properties
code = code ? code : Persist.builds[id][name]; // Retrieve build code if not passed
var b = new Ship(id, data.properties, data.slots); // Create a new Ship instance
Serializer.toShip(b, code); // Populate components from code
// Extend ship instance and add properties below
b.buildName = buildName;
b.buildName = name;
b.code = code;
b.pctRetracted = b.powerRetracted / b.powerAvailable;
b.pctDeployed = b.powerDeployed / b.powerAvailable;
$scope.builds.push(b); // Add ship build to comparison
$scope.builds = $filter('orderBy')($scope.builds, $scope.predicate, $scope.desc); // Resort
_.remove($scope.unusedBuilds, function (b) { // Remove from unused builds
return b.id == shipId && b.buildName == buildName;
_.remove($scope.unusedBuilds, function(o) { // Remove from unused builds
return o.id == id && o.buildName == name;
});
$scope.saved = false;
};
/**
* Removes a build from the comparison
* @param {string} shipId The unique ship key/id
* @param {string} buildName The build name
* @param {string} id The unique ship key/id
* @param {string} name The build name
*/
$scope.removeBuild = function (shipId, buildName) {
_.remove($scope.builds, function (b) {
if (b.id == shipId && b.buildName == buildName) {
$scope.unusedBuilds.push({id: shipId, buildName: buildName, name: b.name}); // Add build back to unused builds
$scope.removeBuild = function(id, name) {
_.remove($scope.builds, function(s) {
if (s.id == id && s.buildName == name) {
$scope.unusedBuilds.push({ id: id, buildName: name, name: s.name }); // Add build back to unused builds
return true;
}
return false;
@@ -54,7 +55,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
* Toggles the selected the set of facets used in the comparison
* @param {number} i The index of the facet in facets
*/
$scope.toggleFacet = function (i) {
$scope.toggleFacet = function(i) {
facets[i].active = !facets[i].active;
$scope.tblUpdate = !$scope.tblUpdate; // Simple switch to trigger the table to update
$scope.saved = false;
@@ -64,12 +65,12 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
* Click handler for sorting by facets in the table
* @param {object} e Event object
*/
$scope.handleClick = function (e) {
$scope.handleClick = function(e) {
var elem = angular.element(e.target);
if(elem.attr('prop')) { // Get component ID
if (elem.attr('prop')) { // Get component ID
$scope.sort(elem.attr('prop'));
}
else if (elem.attr('del')) { // Delete index
} else if (elem.attr('del')) { // Delete index
$scope.removeBuild(elem.attr('del'));
}
};
@@ -78,8 +79,8 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
* Sort the comparison array based on the selected facet / ship property
* @param {string} key Ship property
*/
$scope.sort = function (key) {
$scope.desc = ($scope.predicate == key)? !$scope.desc : $scope.desc;
$scope.sort = function(key) {
$scope.desc = $scope.predicate == key ? !$scope.desc : $scope.desc;
$scope.predicate = key;
$scope.builds = $filter('orderBy')($scope.builds, $scope.predicate, $scope.desc);
};
@@ -94,12 +95,12 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
}
var selectedFacets = [];
facets.forEach(function(f) {
if(f.active) {
if (f.active) {
selectedFacets.unshift(f.index);
}
});
Persist.saveComparison($scope.name, $scope.builds, selectedFacets);
$state.go('compare', {name: $scope.name}, {location:'replace', notify:false});
$state.go('compare', { name: $scope.name }, { location: 'replace', notify: false });
$scope.saved = true;
};
@@ -108,7 +109,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
*/
$scope.delete = function() {
Persist.deleteComparison($scope.name);
$state.go('compare', {name: null}, {location:'replace', reload:true});
$state.go('compare', { name: null }, { location: 'replace', reload: true });
};
/**
@@ -134,7 +135,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
*/
$scope.permalink = function(e) {
e.stopPropagation();
$state.go('modal.link', {url: genPermalink()});
$state.go('modal.link', { url: genPermalink() });
};
/**
@@ -147,14 +148,14 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
e.stopPropagation();
// Make a request to goo.gl to shorten the URL, returns a promise
var promise = Utils.shortenUrl( genPermalink()).then(
function (shortUrl) {
function(shortUrl) {
return Utils.comparisonBBCode(facets, $scope.builds, shortUrl);
},
function (e) {
return 'Error - ' + e.statusText;
function(err) {
return 'Error - ' + err.statusText;
}
);
$state.go('modal.export', {promise: promise, title:'Forum BBCode'});
$state.go('modal.export', { promise: promise, title: 'Forum BBCode' });
};
/**
@@ -164,7 +165,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
function genPermalink() {
var selectedFacets = [];
facets.forEach(function(f) {
if(f.active) {
if (f.active) {
selectedFacets.unshift(f.index);
}
});
@@ -175,7 +176,7 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
$scope.predicate,
$scope.desc
);
return $state.href('comparison', {code: code}, {absolute:true});
return $state.href('comparison', { code: code }, { absolute: true });
}
/* Event listeners */
@@ -184,7 +185,6 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
});
/* Initialization */
var shipId, buildName, comparisonData;
if ($scope.compareMode) {
if ($scope.name == 'all') {
for (shipId in Persist.builds) {
@@ -195,13 +195,13 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
} else {
for (shipId in Persist.builds) {
for (buildName in Persist.builds[shipId]) {
$scope.unusedBuilds.push({id: shipId, buildName: buildName, name: Ships[shipId].properties.name});
$scope.unusedBuilds.push({ id: shipId, buildName: buildName, name: Ships[shipId].properties.name });
}
}
comparisonData = Persist.getComparison($scope.name);
if (comparisonData) {
defaultFacets = comparisonData.facets;
comparisonData.builds.forEach(function (b) {
comparisonData.builds.forEach(function(b) {
$scope.addBuild(b.shipId, b.buildName);
});
$scope.saved = true;
@@ -214,9 +214,9 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
$scope.name = comparisonData.n;
$scope.predicate = comparisonData.p;
$scope.desc = comparisonData.d;
comparisonData.b.forEach(function (build) {
comparisonData.b.forEach(function(build) {
$scope.addBuild(build.s, build.n, build.c);
if(!$scope.importObj[build.s]) {
if (!$scope.importObj[build.s]) {
$scope.importObj[build.s] = {};
}
$scope.importObj[build.s][build.n] = build.c;
@@ -226,9 +226,9 @@ angular.module('app').controller('ComparisonController', ['lodash', '$rootScope'
}
}
// Replace fmt with actual format function as defined in rootScope and retain original index
facets.forEach(function(f,i) { f.fmt = $rootScope[f.fmt]; f.index = i; });
facets.forEach(function(f, i) { f.fmt = $rootScope[f.fmt]; f.index = i; });
// Remove default facets, mark as active, and add them back in selected order
_.pullAt(facets, defaultFacets).forEach(function (f) { f.active = true; facets.unshift(f); });
_.pullAt(facets, defaultFacets).forEach(function(f) { f.active = true; facets.unshift(f); });
$scope.builds = $filter('orderBy')($scope.builds, $scope.predicate, $scope.desc);
}]);
}]);

View File

@@ -1,7 +1,7 @@
angular.module('app').controller('DeleteController', ['$scope', 'Persist', function ($scope, Persist) {
$scope.deleteAll = function () {
angular.module('app').controller('DeleteController', ['$scope', 'Persist', function($scope, Persist) {
$scope.deleteAll = function() {
Persist.deleteAll();
$scope.$parent.dismiss();
};
}]);
}]);

View File

@@ -1,5 +1,5 @@
angular.module('app')
.controller('ErrorController', ['$window','$rootScope','$scope','$stateParams', '$location', function ($window, $rootScope, $scope, $p, $location) {
.controller('ErrorController', ['$window', '$rootScope', '$scope', '$stateParams', '$location', function($window, $rootScope, $scope, $p, $location) {
$rootScope.title = 'Error';
$scope.path = $location.path();
$scope.type = $p.type || 'unknown';
@@ -21,9 +21,9 @@ angular.module('app')
$scope.details = $p.details;
break;
default:
$scope.msgPre = "Uh, Jameson, we have a problem..";
$scope.msgPre = 'Uh, Jameson, we have a problem..';
$scope.errorMessage = $p.message;
$scope.details = $p.details;
}
}]);
}]);

View File

@@ -1,18 +1,18 @@
angular.module('app').controller('ExportController', ['$scope', '$stateParams', function ($scope, $stateParams) {
angular.module('app').controller('ExportController', ['$scope', '$stateParams', function($scope, $stateParams) {
$scope.title = $stateParams.title || 'Export';
if ($stateParams.promise) {
$scope.export = 'Generating...';
$stateParams.promise.then(function(data){
$stateParams.promise.then(function(data) {
$scope.export = data;
});
} else {
$scope.export = angular.toJson($stateParams.data, true);
}
$scope.onTextClick = function ($event) {
$scope.onTextClick = function($event) {
$event.target.select();
};
}]);
}]);

View File

@@ -1,4 +1,4 @@
angular.module('app').controller('ImportController', ['$scope', '$stateParams', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function ($scope, $stateParams, Ships, Ship, Persist, Serializer) {
angular.module('app').controller('ImportController', ['$scope', '$stateParams', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function($scope, $stateParams, Ships, Ship, Persist, Serializer) {
$scope.jsonValid = false;
$scope.importData = null;
$scope.errorMsg = null;
@@ -21,7 +21,7 @@ angular.module('app').controller('ImportController', ['$scope', '$stateParams',
return;
}
if(typeof importObj != 'object') {
if (typeof importObj != 'object') {
$scope.errorMsg = 'Must be an object!';
return;
}
@@ -48,7 +48,7 @@ angular.module('app').controller('ImportController', ['$scope', '$stateParams',
}
}
} else {
$scope.errorMsg = '"' + shipId + '" is not a valid Ship Id!';
$scope.errorMsg = '"' + shipId + '"" is not a valid Ship Id!';
return;
}
$scope.builds = importObj.builds;
@@ -57,7 +57,7 @@ angular.module('app').controller('ImportController', ['$scope', '$stateParams',
$scope.jsonValid = true;
};
$scope.hasBuild = function (shipId, name) {
$scope.hasBuild = function(shipId, name) {
return Persist.getBuild(shipId, name) !== null;
};
@@ -98,4 +98,4 @@ angular.module('app').controller('ImportController', ['$scope', '$stateParams',
}
}]);
}]);

View File

@@ -1,16 +1,16 @@
angular.module('app').controller('LinkController', ['$scope', 'Utils', '$stateParams', function ($scope, Utils, $stateParams) {
angular.module('app').controller('LinkController', ['$scope', 'Utils', '$stateParams', function($scope, Utils, $stateParams) {
$scope.url = $stateParams.url;
$scope.shortenedUrl = 'Shortening...';
$scope.onTextClick = function ($event) {
$scope.onTextClick = function($event) {
$event.target.select();
};
Utils.shortenUrl($scope.url)
.then(function(url) {
$scope.shortenedUrl = url;
},function(e) {
}, function(e) {
$scope.shortenedUrl = 'Error - ' + e.statusText;
});
}]);
}]);

View File

@@ -1,9 +1,9 @@
angular.module('app').controller('ModalController', ['$rootScope','$scope', '$state', function ($rootScope, $scope, $state) {
angular.module('app').controller('ModalController', ['$rootScope', '$scope', '$state', function($rootScope, $scope, $state) {
$scope.dismiss = function() {
if ($rootScope.prevState) {
var state = $rootScope.prevState;
$state.go(state.name, state.params, {location: 'replace', reload: false});
$state.go(state.name, state.params, { location: 'replace', reload: false });
} else {
$state.go('shipyard');
}
@@ -11,4 +11,4 @@ angular.module('app').controller('ModalController', ['$rootScope','$scope', '$st
$scope.$on('close', $scope.dismiss);
}]);
}]);

View File

@@ -1,4 +1,4 @@
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) {
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
@@ -12,7 +12,7 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
}
$scope.buildName = $p.bn;
$rootScope.title = ship.name + ($scope.buildName? ' - ' + $scope.buildName : '');
$rootScope.title = ship.name + ($scope.buildName ? ' - ' + $scope.buildName : '');
$scope.ship = ship;
$scope.pp = ship.common[0]; // Power Plant
$scope.th = ship.common[1]; // Thruster
@@ -49,11 +49,11 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
$scope.jrChart = {
labels: {
xAxis: {
title:'Cargo',
title: 'Cargo',
unit: 'T'
},
yAxis: {
title:'Jump Range',
title: 'Jump Range',
unit: 'LY'
}
},
@@ -90,7 +90,7 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
if (id) {
if (id == 'empty') {
ship.use(slot, null, null);
} else if(type == 'h') {
} else if (type == 'h') {
ship.use(slot, id, Components.hardpoints(id));
} else if (type == 'c') {
ship.use(slot, id, Components.common(ship.common.indexOf(slot), id));
@@ -142,13 +142,13 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
*/
$scope.deleteBuild = function() {
Persist.deleteBuild(ship.id, $scope.buildName);
$state.go('outfit', {shipId: ship.id, code: null, bn: null}, {location:'replace', reload:true});
$state.go('outfit', { shipId: ship.id, code: null, bn: null }, { location: 'replace', reload: true });
};
/**
* On build name change, retrieve the existing saved code if there is one
*/
$scope.bnChange = function(){
$scope.bnChange = function() {
$scope.savedCode = Persist.getBuild(ship.id, $scope.buildName);
};
@@ -165,13 +165,13 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
* @param {[type]} key [description]
* @return {[type]} [description]
*/
$scope.sortCost = function (key) {
$scope.costDesc = ($scope.costPredicate == key)? !$scope.costDesc : $scope.costDesc;
$scope.sortCost = function(key) {
$scope.costDesc = $scope.costPredicate == key ? !$scope.costDesc : $scope.costDesc;
$scope.costPredicate = key;
};
$scope.sortPwr = function (key) {
$scope.pwrDesc = ($scope.pwrPredicate == key)? !$scope.pwrDesc : $scope.pwrDesc;
$scope.sortPwr = function(key) {
$scope.pwrDesc = $scope.pwrPredicate == key ? !$scope.pwrDesc : $scope.pwrDesc;
$scope.pwrPredicate = key;
};
@@ -185,37 +185,37 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
updateState();
};
$scope.incPriority = function (c) {
$scope.incPriority = function(c) {
if (ship.changePriority(c, c.priority + 1)) {
$scope.code = Serializer.fromShip(ship);
updateState();
}
};
$scope.decPriority = function (c) {
$scope.decPriority = function(c) {
if (ship.changePriority(c, c.priority - 1)) {
$scope.code = Serializer.fromShip(ship);
updateState();
}
};
$scope.fuelChange = function (fuel) {
$scope.fuelChange = function(fuel) {
$scope.fuel = fuel;
win.triggerHandler('render');
};
$scope.statusRetracted = function (slot) {
$scope.statusRetracted = function(slot) {
return ship.getSlotStatus(slot, false);
};
$scope.statusDeployed = function (slot) {
$scope.statusDeployed = function(slot) {
return ship.getSlotStatus(slot, true);
};
// Utilify functions
function updateState() {
$state.go('outfit', {shipId: ship.id, code: $scope.code, bn: $scope.buildName}, {location:'replace', notify:false});
$state.go('outfit', { shipId: ship.id, code: $scope.code, bn: $scope.buildName }, { location: 'replace', notify: false });
$scope.jrSeries.xMax = ship.cargoCapacity;
$scope.jrSeries.yMax = ship.jumpRangeWithMass(ship.unladenMass);
$scope.jrSeries.mass = ship.unladenMass;
@@ -223,7 +223,7 @@ angular.module('app').controller('OutfitController', ['$window','$rootScope','$s
}
// Hide any open menu/slot/etc if the background is clicked
$scope.$on('close', function () {
$scope.$on('close', function() {
$scope.selectedSlot = null;
});

View File

@@ -1,4 +1,4 @@
angular.module('app').controller('ShipyardController', ['$rootScope', 'ShipsDB', function ($rootScope, ships) {
angular.module('app').controller('ShipyardController', ['$rootScope', 'ShipsDB', function($rootScope, ships) {
$rootScope.title = 'Coriolis';
$rootScope.ships = ships;
}]);
}]);