Skip to content

Commit

Permalink
sync now accepts custom data
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Apr 20, 2013
1 parent 00edc97 commit 0149dd9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/data.js
Expand Up @@ -42,11 +42,11 @@ Data.prototype = {
// reset the data every day
if( now.getDate() != this.today.getDate() ){
// construct a json out of the data and save
this.sync();
this.sync( this.json() );
this.reset();
} else if( now.getTime() - this.lastSync > 60000 ) {
// sync the data every min
this.sync();
this.sync( JSON.stringify( this.data ) );
// record the last sync
this.lastSync = now.getTime();
}
Expand Down Expand Up @@ -88,9 +88,9 @@ Data.prototype = {

},

json : function( date ) {
json : function() {

//var date = format( this.today );
var date = format( this.today );
var data = this.data;
var daily = new Array();

Expand All @@ -108,11 +108,11 @@ Data.prototype = {
return json;
},

sync : function(){
sync : function( data ){
// for now, just a simple store (overwriting the existing)
// in the future smart merging??
var timestamp = format( this.today );
this.store( timestamp, this.json( timestamp ) );
var file = format( this.today );
this.store( file, data );
},

retrieve : function( file, callback ){
Expand Down

0 comments on commit 0149dd9

Please sign in to comment.