not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.0 KiB

define(function (require) {
var model = {};
model.Model = function () {
this.items = [];
};
model.Model.prototype.load = function (items) {
this.items = items;
};
model.Model.prototype.create = function (title) {
title = title || '';
var newItem = {
id: new Date().getTime(),
title: title.trim(),
completed: 0
};
this.items.push(newItem);
return newItem;
};
model.Model.prototype.remove = function (id) {
for (var i = 0; i < this.items.length; i++) {
if (this.items[i].id == id) {
this.items.splice(i, 1);
break;
}
}
};
model.Model.prototype.update = function (id, updateData) {
for (var i = 0; i < this.items.length; i++) {
if (this.items[i].id == id) {
for (var x in updateData) {
this.items[i][x] = updateData[x];
}
}
}
};
return model;
});