Skip to content

Commit

Permalink
fix save friends
Browse files Browse the repository at this point in the history
  • Loading branch information
melvincarvalho committed Dec 22, 2011
1 parent d78d4b2 commit 86404a8
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions index.html
Expand Up @@ -316,36 +316,13 @@ <h5 id="welcome">Loading...</h5>
window.localStorage.setItem('IOUs', JSON.stringify(this.IOUs));
},

saveRemote: function() {
// get user
var user = window.user;
var userSha1 = hex_sha1(user);

// dirs
var baseDir = 'http://opentabs.data.fm/d/' + userSha1.substring(0,2) + '/' + userSha1.substring(2) + '/';
this.createDirectory(baseDir + 'public/');
this.createDirectory(baseDir + 'private/');
this.createDirectory(baseDir + 'friends/');


// DELETE
this.deleteFile(baseDir + 'private/transfers');

// PUT
var body = jsonld.turtle(this.IOUs);
this.putFile(baseDir + 'private/transfers', body);

var friends = jsonld.turtle(this.friends);
this.putFile(baseDir + 'private/friends', friends);

},

saveRemote: function() {
this.saveRemoteIOUs();
this.saveRemoteFriends();
},

saveRemoteIOUs: function() {
this.status('Saving IOUs...', true);
// get user
var user = window.user;
var userSha1 = hex_sha1(user);
Expand All @@ -363,9 +340,11 @@ <h5 id="welcome">Loading...</h5>
// PUT
var body = jsonld.turtle(this.IOUs);
this.putFile(baseDir + 'private/transfers', body);
this.status('Saving IOUs...', false);
},

saveRemoteFriends: function() {
this.status('Saving friends...', true);
// get user
var user = window.user;
var userSha1 = hex_sha1(user);
Expand All @@ -383,11 +362,13 @@ <h5 id="welcome">Loading...</h5>
// PUT
var body = jsonld.turtle(this.friends);
this.putFile(baseDir + 'private/friends', body);
this.status('Saving IOUs...', false);
},



syncRemote: function() {
this.status('Saving IOUs...', true);
// get user
var user = this.makeURI($('#payee').val());
var userSha1 = hex_sha1(user);
Expand Down Expand Up @@ -429,6 +410,7 @@ <h5 id="welcome">Loading...</h5>


that.render();
that.status('Saving IOUs...', false);

}).error(function () {
var IOUs = [];
Expand All @@ -438,6 +420,7 @@ <h5 id="welcome">Loading...</h5>
var body = jsonld.turtle(IOUs);
that.putFile(baseDir + 'private/transfers', body);

that.status('Saving IOUs...', false);
that.render();

});
Expand Down

0 comments on commit 86404a8

Please sign in to comment.