Merge pull request #85 from Denton-L/upload-fix

Fix all problems with the upload button
pull/1/head
chriseth 9 years ago
commit 49caabdef6
  1. 2
      index.html
  2. 3
      src/app.js
  3. 3
      src/app/editor.js

@ -45,7 +45,7 @@
<div id="editor">
<span class="newFile" title="New File"><i class="fa fa-file-code-o"></i></span>
<span class="uploadFile" title="Upload"><label class="fa fa-upload"><input type="file" class="inputFile" multiple /></label</span>
<span class="uploadFile" title="Upload"><label class="fa fa-upload"><input type="file" class="inputFile" multiple /></label></span>
<div class="files-wrapper">
<div class="scroller scroller-left"><i class="fa fa-chevron-left "></i></div>
<div class="scroller scroller-right"><i class="fa fa-chevron-right "></i></div>

@ -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]);
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