sync done.txt with dropbox

This commit is contained in:
Morgan McMillian 2012-12-01 19:47:35 -05:00
parent b36fd3cc1a
commit 2a7bebd457

View file

@ -200,6 +200,7 @@ enyo.kind({
if (this.preferences["offline"] == false) { if (this.preferences["offline"] == false) {
var dboxpath = this.preferences["dboxpath"]; var dboxpath = this.preferences["dboxpath"];
this.$.dropbox.getFile(dboxpath+"/todo.txt"); this.$.dropbox.getFile(dboxpath+"/todo.txt");
this.$.dropbox.getFile(dboxpath+"/done.txt");
} else { } else {
console.log("working offline, loading local copy instead"); console.log("working offline, loading local copy instead");
this.getLocalFile(); this.getLocalFile();
@ -327,7 +328,8 @@ enyo.kind({
if (this.preferences["storage"] == "dropbox" && if (this.preferences["storage"] == "dropbox" &&
this.preferences["offline"] == false && this.preferences["offline"] == false &&
this.dropboxRefresh == false) { this.dropboxRefresh == false) {
var filename = path.match(/todo\.txt.*/); console.log("test:" + path.match(/(todo|done)\.txt.*/)[0]);
var filename = path.match(/(todo|done)\.txt.*/)[0];
filename = this.preferences["dboxpath"]+"/"+filename; filename = this.preferences["dboxpath"]+"/"+filename;
//var params = { overwrite: true }; //var params = { overwrite: true };
this.$.dropbox.putFile(filename, data); this.$.dropbox.putFile(filename, data);
@ -408,11 +410,23 @@ enyo.kind({
}, },
loadDropbox: function(inSender, inResponse, inRequest) { loadDropbox: function(inSender, inResponse, inRequest) {
console.log("url:" + inRequest.url);
var file = new Object(); var file = new Object();
file.content = inResponse; file.content = inResponse;
this.parseFile(null, file); if (inRequest.url.match(/todo\.txt/)) {
this.dropboxRefresh = true; console.log("got the main file");
this.saveFile(this.preferences["filepath"], this.todoList); this.parseFile(null, file);
this.dropboxRefresh = true;
this.saveFile(this.preferences["filepath"], this.todoList);
} else if (inRequest.url.match(/done\.txt/)) {
console.log("got the done file");
this.loadArchive(null, file);
this.dropboxRefresh = true;
this.saveFile(
this.preferences["filepath"].replace(/todo\.txt/, "done.txt"),
this.doneList
);
}
}, },
resetPreferences: function() { resetPreferences: function() {