Adding beginnings of comparison feature

This commit is contained in:
Colin McLeod
2015-05-05 01:05:58 -07:00
parent 748e1261fe
commit f418e7a6ae
15 changed files with 224 additions and 12 deletions

View File

@@ -26,6 +26,7 @@ angular.module('app').config(['$provide','$stateProvider', '$urlRouterProvider',
}
})
.state('shipyard', { url: '/', templateUrl: 'views/page-shipyard.html', controller: 'ShipyardController' })
.state('comparison', { url: '/comparison', templateUrl: 'views/page-comparison.html', controller: 'ComparisonController' })
.state('error', { params: {type:null, message:null, details: null }, templateUrl: 'views/page-error.html', controller: 'ErrorController' })
// Redirects

View File

@@ -0,0 +1,24 @@
angular.module('app').controller('ComparisonController', ['$rootScope', '$scope', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function ($rootScope, $scope, Ships, Ship, Persist, Serializer) {
$rootScope.title = 'Coriolis - Comparison';
$rootScope.bodyClass = 'docking-bay';
var comparison = $scope.comparison = [];
for (var shipId in Persist.builds) {
var data = Ships[shipId];
for (var buildName in Persist.builds[shipId]) {
var code = Persist.builds[shipId][buildName];
var ship = new Ship(shipId, data.properties, data.slots); // Create a new Ship instance
Serializer.toShip(ship, code); // Populate components from 'code' URL param
comparison.push({
shipId: shipId,
buildName: buildName,
ship: ship,
code: code
});
}
}
}]);

View File

@@ -29,6 +29,7 @@ angular.module('app').directive('shipyardHeader', ['lodash','$rootScope', 'Persi
$rootScope.$on('close', function () {
scope.openedMenu = null;
$rootScope.showAbout = false;
});
scope.updateInsurance = function(){
@@ -49,6 +50,17 @@ angular.module('app').directive('shipyardHeader', ['lodash','$rootScope', 'Persi
scope.openedMenu = menu;
};
scope.about = function(e) {
e.preventDefault();
e.stopPropagation();
scope.openedMenu = null;
$rootScope.showAbout = true;
};
$rootScope.hideAbout = function (){
$rootScope.showAbout = false;
}
}
};
}]);

View File

@@ -56,7 +56,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
if (comps.internal[i] !== 0) {
internal[i].id = comps.internal[i];
internal[i].c = Components.internal(comps.internal[i]);
if (internal[i].c.group == 'sg') {
if (internal[i].c.grp == 'sg') {
this.sgSI = i;
}
} else {