This commit is contained in:
Jeremy Schomery 2017-02-03 12:47:26 +03:30
parent ebacb7c5e6
commit 92d0acfbe3

View File

@ -31,18 +31,16 @@ function loadFromFile(formatToFilter){
fileInput.initialValue = fileInput.value;
fileInput.addEventListener('change', changeHandler);
function changeHandler(){
if (fileInput.value != fileInput.initialValue){
if (fileInput.value !== fileInput.initialValue){
var fReader = new FileReader();
fReader.readAsDataURL(fileInput.files[0]);
fReader.onloadend = function(event){
fReader.onloadend = function (event){
fileInput.removeEventListener('change', changeHandler);
fileInput.remove();
var b64text = event.target.result.split(",")[1],
rawText = atob(b64text);
resolve(rawText);
}
resolve(event.target.result);
};
fReader.readAsText(fileInput.files[0], 'utf-8')
}
}
fileInput.click();
});
}
}