Make uploadFile have a callback

This should fix #80.
pull/1/head
Denton Liu 9 years ago
parent 76aa02286f
commit 095974e633
  1. 5
      src/app.js
  2. 3
      src/app/editor.js

@ -163,8 +163,9 @@ var run = function () {
for (var i = 0; i < fileList.length; i++) {
var name = fileList[i].name;
if (!window.localStorage[utils.fileKey(name)] || confirm('The file ' + name + ' already exists! Would you like to overwrite it?')) {
editor.uploadFile(fileList[i]);
updateFiles();
editor.uploadFile(fileList[i], function () {
updateFiles();
});
}
}

@ -16,13 +16,14 @@ function Editor (loadingFromGist) {
this.setCacheFileContent('');
};
this.uploadFile = function (file) {
this.uploadFile = function (file, callback) {
var fileReader = new FileReader();
SOL_CACHE_FILE = utils.fileKey(file.name);
fileReader.onload = function (e) {
window.localStorage[SOL_CACHE_FILE] = e.target.result;
sessions[SOL_CACHE_FILE] = null;
callback();
};
fileReader.readAsText(file);
};

Loading…
Cancel
Save