Add lastChange field in objects and their exports
This commit is contained in:
parent
efe943361b
commit
704e322542
1 changed files with 15 additions and 6 deletions
|
@ -1,10 +1,13 @@
|
|||
function GroupList() {
|
||||
|
||||
lastChange=0;
|
||||
|
||||
this.loadFromLocalStorage=function() {
|
||||
if (localStorage.groups!==undefined) {
|
||||
var groups=JSON.parse(localStorage.groups);
|
||||
for (el in groups) {
|
||||
this[el]=new Group(el,groups[el]);
|
||||
var data=JSON.parse(localStorage.groups);
|
||||
this.lastChange=data.lastChange;
|
||||
for (el in data.groups) {
|
||||
this[el]=new Group(el,data.groups[el]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +23,10 @@ function GroupList() {
|
|||
}
|
||||
|
||||
this.save=function() {
|
||||
localStorage.groups=JSON.stringify(this.export());
|
||||
localStorage.groups=JSON.stringify({
|
||||
'lastChange': new Date().getTime(),
|
||||
'groups': this.export()
|
||||
});
|
||||
}
|
||||
|
||||
this.each=function(fct) {
|
||||
|
@ -174,7 +180,8 @@ function Group(name,data) {
|
|||
data.contributions[idx].cost,
|
||||
data.contributions[idx].title,
|
||||
data.contributions[idx].date,
|
||||
idx
|
||||
idx,
|
||||
data.contributions[idx].lastChange
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -198,18 +205,20 @@ function Contributor(name,email,id) {
|
|||
}
|
||||
}
|
||||
|
||||
function Contribution(contributor,cost,title,date,id) {
|
||||
function Contribution(contributor,cost,title,date,id,lastChange) {
|
||||
this.contributor=contributor;
|
||||
this.cost=cost;
|
||||
this.title=title;
|
||||
this.date=date;
|
||||
this.id=id;
|
||||
this.lastChange=lastChange || new Date().getTime();
|
||||
this.export=function() {
|
||||
return {
|
||||
'contributor': this.contributor.name,
|
||||
'cost': this.cost,
|
||||
'title': this.title,
|
||||
'date': this.date,
|
||||
'lastChange': this.lastChange,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue