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.initialValue = fileInput.value;
fileInput.addEventListener('change', changeHandler); fileInput.addEventListener('change', changeHandler);
function changeHandler(){ function changeHandler(){
if (fileInput.value != fileInput.initialValue){ if (fileInput.value !== fileInput.initialValue){
var fReader = new FileReader(); var fReader = new FileReader();
fReader.readAsDataURL(fileInput.files[0]); fReader.onloadend = function (event){
fReader.onloadend = function(event){
fileInput.removeEventListener('change', changeHandler); fileInput.removeEventListener('change', changeHandler);
fileInput.remove(); fileInput.remove();
var b64text = event.target.result.split(",")[1], resolve(event.target.result);
rawText = atob(b64text); };
resolve(rawText); fReader.readAsText(fileInput.files[0], 'utf-8')
}
} }
} }
fileInput.click(); fileInput.click();
}); });
} }