diff --git a/inc/myco_objects.js b/inc/myco_objects.js index ef1c1d1..a8ee650 100644 --- a/inc/myco_objects.js +++ b/inc/myco_objects.js @@ -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, }; }