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() {
|
function GroupList() {
|
||||||
|
|
||||||
|
lastChange=0;
|
||||||
|
|
||||||
this.loadFromLocalStorage=function() {
|
this.loadFromLocalStorage=function() {
|
||||||
if (localStorage.groups!==undefined) {
|
if (localStorage.groups!==undefined) {
|
||||||
var groups=JSON.parse(localStorage.groups);
|
var data=JSON.parse(localStorage.groups);
|
||||||
for (el in groups) {
|
this.lastChange=data.lastChange;
|
||||||
this[el]=new Group(el,groups[el]);
|
for (el in data.groups) {
|
||||||
|
this[el]=new Group(el,data.groups[el]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +23,10 @@ function GroupList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.save=function() {
|
this.save=function() {
|
||||||
localStorage.groups=JSON.stringify(this.export());
|
localStorage.groups=JSON.stringify({
|
||||||
|
'lastChange': new Date().getTime(),
|
||||||
|
'groups': this.export()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.each=function(fct) {
|
this.each=function(fct) {
|
||||||
|
@ -174,7 +180,8 @@ function Group(name,data) {
|
||||||
data.contributions[idx].cost,
|
data.contributions[idx].cost,
|
||||||
data.contributions[idx].title,
|
data.contributions[idx].title,
|
||||||
data.contributions[idx].date,
|
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.contributor=contributor;
|
||||||
this.cost=cost;
|
this.cost=cost;
|
||||||
this.title=title;
|
this.title=title;
|
||||||
this.date=date;
|
this.date=date;
|
||||||
this.id=id;
|
this.id=id;
|
||||||
|
this.lastChange=lastChange || new Date().getTime();
|
||||||
this.export=function() {
|
this.export=function() {
|
||||||
return {
|
return {
|
||||||
'contributor': this.contributor.name,
|
'contributor': this.contributor.name,
|
||||||
'cost': this.cost,
|
'cost': this.cost,
|
||||||
'title': this.title,
|
'title': this.title,
|
||||||
'date': this.date,
|
'date': this.date,
|
||||||
|
'lastChange': this.lastChange,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue