Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

Commit

Permalink
Fix problems with spinners and banners
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Smith committed Dec 21, 2013
1 parent 7a69e9b commit ca65d6c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
8 changes: 7 additions & 1 deletion scripts/cloud/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,22 @@ cloud.dropbox.enumerate = function (directory, callback) {

cloud.dropbox.load = function (path, callback) {
if (cloud.dropbox.client && path) {
spinner();
cloud.dropbox.client.readFile(path, function(e, d) {
// Hide spinner
spinner('hide');

// Callback
if (!e) {
callback(d);
} else {
callback(e.status, true);
}
});
} else {
// Hide spinner
spinner('hide');

// Callback error
if (!cloud.dropbox.client) {
callback("You are not signed in to Dropbox", true);
} else if (!path) {
Expand Down
41 changes: 38 additions & 3 deletions scripts/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ firetext.io.save = function (directory, filename, filetype, content, showBanner,
}

// Finish
updateDocLists(['recents']);
saving = false;
callback();
};
Expand Down Expand Up @@ -593,14 +592,26 @@ firetext.io.save = function (directory, filename, filetype, content, showBanner,
});
}
} else if (location == 'dropbox') {
cloud.dropbox.save(filePath, contentBlob, showSpinner, function () { saving = false; callback(); });
cloud.dropbox.save(filePath, contentBlob, showSpinner, function () {
// Show banner
if (showBanner) {
showSaveBanner();
}

// Finish
saving = false;
callback();
});
}
};

firetext.io.load = function (directory, filename, filetype, callback, location) {
if (!directory | !filename | !filetype | !callback) {
return;
}

// Show spinner
spinner();

// Put directory in proper form
if (directory[directory.length - 1] != '/') {
Expand Down Expand Up @@ -630,7 +641,10 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
// 0.3 only
reader.readAsText(file);

reader.onerror = function () {
reader.onerror = function () {
// Hide spinner
spinner('hide');

alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
callback(this.error.name, true);
};
Expand All @@ -648,6 +662,9 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
// 0.3 only
file = this.result;

// Hide spinner
spinner('hide');

callback(file);
};
};
Expand All @@ -658,13 +675,19 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
else {
alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
}

// Hide spinner
spinner('hide');
};
} else if (deviceAPI == 'file') {
storage.root.getFile(directory + filename + filetype, {}, function(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();

reader.onerror = function () {
// Hide spinner
spinner('hide');

alert('Load unsuccessful :( \n\nInfo for gurus:\n"' + this.error.name + '"');
callback(this.error.name, true);
};
Expand All @@ -680,6 +703,9 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
// 0.3 only
file = this.result;

// Hide spinner
spinner('hide');

callback(file);
};

Expand All @@ -695,17 +721,26 @@ firetext.io.load = function (directory, filename, filetype, callback, location)
reader.readAsText(file);
}, function(err) {
alert("Error opening file\n\ncode: " + err.code);

// Hide spinner
spinner('hide');
});
}, function(err) {
if (err.code === FileError.NOT_FOUND_ERR) {
alert("Load unsuccessful :(\n\nError code: " + err.code);
} else {
alert("Load unsuccessful :(\n\nError code: " + err.code);
}

// Hide spinner
spinner('hide');
});
}
} else if (location = 'dropbox') {
cloud.dropbox.load(filePath, function (result, error) {
// Hide spinner
spinner('hide');

callback(result, error);
});
}
Expand Down

0 comments on commit ca65d6c

Please sign in to comment.