Add lastChange in GroupList export return
Benjamin Renard

Benjamin Renard commited on 2014-01-27 22:50:28
Showing 1 changed files, with 9 additions and 8 deletions.

... ...
@@ -28,9 +28,12 @@ function GroupList() {
28 28
   }
29 29
 
30 30
   this.export=function() {
31
-    return this.each(function(idx,group) {
31
+    return {
32
+      'lastChange': this.lastChange,
33
+      'groups': this.each(function(idx,group) {
32 34
         return group.export();
33
-    });
35
+      })
36
+    };
34 37
   }
35 38
 
36 39
   this.import=function(groups) {
... ...
@@ -40,18 +43,16 @@ function GroupList() {
40 43
         delete ret[el];
41 44
       }
42 45
     }
43
-    for (el in groups) {
44
-      this[el]=new Group(el,false,groups[el]);
46
+    this.lastChange=groups.lastChange;
47
+    for (el in groups.groups) {
48
+      this[el]=new Group(el,false,groups.groups[el]);
45 49
     }
46 50
     return true;
47 51
   }
48 52
 
49 53
 
50 54
   this.save=function() {
51
-    localStorage.groups=JSON.stringify({
52
-      'lastChange': new Date().getTime(),
53
-      'groups': this.export()
54
-    });
55
+    localStorage.groups=JSON.stringify(this.export());
55 56
   }
56 57
 
57 58
   this.each=function(fct) {
58 59