From a2e33ea2745dc893007c0a1ec60b8ecc5e86e9d2 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 27 Jan 2014 23:50:28 +0100 Subject: [PATCH] Add lastChange in GroupList export return --- inc/myco_objects.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/inc/myco_objects.js b/inc/myco_objects.js index e628885..3a37026 100644 --- a/inc/myco_objects.js +++ b/inc/myco_objects.js @@ -28,9 +28,12 @@ function GroupList() { } this.export=function() { - return this.each(function(idx,group) { - return group.export(); - }); + return { + 'lastChange': this.lastChange, + 'groups': this.each(function(idx,group) { + return group.export(); + }) + }; } this.import=function(groups) { @@ -40,18 +43,16 @@ function GroupList() { delete ret[el]; } } - for (el in groups) { - this[el]=new Group(el,false,groups[el]); + this.lastChange=groups.lastChange; + for (el in groups.groups) { + this[el]=new Group(el,false,groups.groups[el]); } return true; } this.save=function() { - localStorage.groups=JSON.stringify({ - 'lastChange': new Date().getTime(), - 'groups': this.export() - }); + localStorage.groups=JSON.stringify(this.export()); } this.each=function(fct) {