Adding comparison charts, fixes and tweaks

This commit is contained in:
Colin McLeod
2015-05-12 22:43:47 -07:00
parent 1cec10432a
commit 02fe76f43b
22 changed files with 446 additions and 119 deletions

View File

@@ -13,8 +13,11 @@ angular.module('app').service('Persist', ['lodash', function (_) {
this.builds = {};
}
var buildCount = Object.keys(this.builds).length;
this.state = {
hasBuilds: Object.keys(this.builds).length > 0
buildCount: buildCount,
hasBuilds: buildCount > 0
}
/**
* Persist a ship build in local storage.
@@ -28,8 +31,12 @@ angular.module('app').service('Persist', ['lodash', function (_) {
this.builds[shipId] = {};
}
if(!this.builds[shipId][name]) {
this.state.buildCount++;
this.state.hasBuilds = true;
}
this.builds[shipId][name] = code;
this.state.hasBuilds = true;
// Persist updated build collection to localStorage
localStorage.setItem(LS_KEY_BUILDS, angular.toJson(this.builds));
}
@@ -61,7 +68,8 @@ angular.module('app').service('Persist', ['lodash', function (_) {
delete this.builds[shipId][name];
if (Object.keys(this.builds[shipId]).length == 0) {
delete this.builds[shipId];
this.state.hasBuilds = Object.keys(this.builds).length > 0;
this.state.buildCount--;
this.state.hasBuilds = this.state.buildCount > 0;
}
// Persist updated build collection to localStorage
localStorage.setItem(LS_KEY_BUILDS, angular.toJson(this.builds));