From fbae6bd324cdbf532f5cc68e5f49722d7ec97192 Mon Sep 17 00:00:00 2001 From: monicadeshmukh Date: Wed, 1 Jul 2020 23:08:26 -0400 Subject: [PATCH] changed read-files.js. result available in words --- assets/js/read-files.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/assets/js/read-files.js b/assets/js/read-files.js index 5ba0fe8..dfced9b 100644 --- a/assets/js/read-files.js +++ b/assets/js/read-files.js @@ -1,5 +1,7 @@ function printSingleFileAsText(evt) { let fileContent = getSingleFileAsText(evt); + //console.log(fileContent); + console.log(fileContent); } @@ -12,7 +14,19 @@ function getSingleFileAsText(evt) { fileReader.onload = function(event) { let contents = event.target.result; let words = getWords(contents); + // return words; + console.log(words); } + /* fileReader.onloadend = function(event) { + //console.log('DONE', fileReader.readyState); // readyState will be 2 + //console.log(fileReader.result); + return event.target.result; + // + } */ + //console.log(fileReader.result); + //return fileReader.readAsText(file); + //return fileReader.result; +//}; return fileReader.readAsText(file) } } @@ -29,4 +43,13 @@ function getWords(s) { let fileInput = document.getElementById('fileinput'); -fileInput.addEventListener('change', getSingleFileAsText, false); \ No newline at end of file +fileInput.addEventListener('change', getSingleFileAsText, false); +//fileInput.addEventListener('change', printSingleFileAsText, false); + +//printSingleFileAsText(fileInput.readAsText()); + +/*function readFile(){ + console.log(getSingleFileAsText(fileInput)); +} + +readFile();*/ \ No newline at end of file