Custom comparisons, performance improvements

This commit is contained in:
Colin McLeod
2015-05-20 00:29:24 -07:00
parent 02fe76f43b
commit 6c1e3a7410
146 changed files with 1096 additions and 1062 deletions

View File

@@ -15,6 +15,7 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
_.map(ship.hardpoints, idToStr),
_.map(ship.internal, idToStr),
];
return _.flatten(data).join('');
};
@@ -53,6 +54,26 @@ angular.module('app').service('Serializer', ['lodash', function (_) {
ship.buildWith(comps);
};
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)});
}.bind(this));
return LZString.compressToBase64(angular.toJson({
n: name,
b: shipBuilds,
f: facets,
p: predicate,
d: desc? 1 : 0
})).replace(/\//g,'-');
}
this.toComparison = function (code) {
return angular.fromJson(LZString.decompressFromBase64(code.replace(/-/g,'/')));
}
/**
* Utility function to retrieve a safe string for selected component for a slot.
* Used for serialization to code only.