UI changes, added utilitiy services, persistance, serialization

This commit is contained in:
Colin McLeod
2015-05-01 01:14:29 -07:00
parent f736a078ec
commit 51ac98d10f
82 changed files with 2709 additions and 2516 deletions

View File

@@ -2,15 +2,39 @@ angular.module('app').directive('componentSelect', [ function() {
return {
restrict: 'A',
scope:{
opts: '=', // Component Options object
slot: '=', // Slot Object
selectComponent: '&sc' // Select Component function
opts: '=', // Component Options object
},
templateUrl: 'views/component_select.html',
link: function (scope) {
scope.use = function(id, component) {
scope.selectComponent({s: scope.slot, id: id, c: component});
};
link: function(scope, element) {
var list = [], o, id;
var opts = scope.opts;
//TODO: take current ship mass into account if provided
// Generting the HTML in this manner is MUCH faster than using an angular template.
for (id in opts) {
o = opts[id];
list.push('<li class="');
list.push(o.name? 'lc' : 'c');
if (false) { // Omit id if mass is exceeded making it 'disabled'
list.push(' disabled"');
} else {
list.push('" id="');
}
list.push(id);
list.push('">');
list.push(o.class);
list.push(o.rating);
if(o.mode) {
list.push('/' + o.mode);
if(o.missile) {
list.push(o.missile);
}
}
if(o.name) {
list.push(' ' + o.name);
}
list.push('</li>');
}
element.html('<ul>' + list.join('') + '</ul>');
}
};
}]);