From 7d312cbbd33a89e91eb233262d7de89b090a8ce6 Mon Sep 17 00:00:00 2001 From: colin niu Date: Wed, 14 Mar 2018 13:18:44 +0800 Subject: [PATCH 1/2] Quick and dirty modification, added "Analyze file" function, because copy & paste large file will hang the browser. --- analyze.js | 19 +++++++++++++++++++ index.html | 1 + 2 files changed, 20 insertions(+) diff --git a/analyze.js b/analyze.js index 2eda8f3..79dbb5b 100644 --- a/analyze.js +++ b/analyze.js @@ -22,7 +22,26 @@ var generatedIdCounter = 1; // This method is called from HTML so we need to tell JSHint it's not unused function analyzeTextfield() { // jshint ignore: line var text = document.getElementById("TEXTAREA").value; + analyze(text); +} + +// This method is called from HTML so we need to tell JSHint it's not unused +function analyzeFile() { // jshint ignore: line + var fileNode = document.getElementById("FILE"); + if(fileNode.files.length > 0) { + var file = fileNode.files[0]; + var fileReader = new FileReader(); + fileReader.readAsText(file); + fileReader.onloadend = function(){ + var text = fileReader.result; + analyze(text); + } + } + +} + +function analyze(text) { var analyzer = new Analyzer(text); setHtml("OUTPUT", analyzer.toHtml()); diff --git a/index.html b/index.html index d88daf0..4c56862 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,7 @@

Online Java Thread Dump Analyzer


+

This page is client-side only, and no data will leave your computer when you click Analyze.

From 96eb047792f29c7f54a4ba098104d66c06349f79 Mon Sep 17 00:00:00 2001 From: Colin Niu Date: Fri, 23 Mar 2018 20:25:44 +0800 Subject: [PATCH 2/2] add jshint config browser:true to pass the tests. --- analyze.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analyze.js b/analyze.js index 79dbb5b..6dcb3ce 100644 --- a/analyze.js +++ b/analyze.js @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +/* jshint browser: true */ /* global document */ var EMPTY_STACK = " "; @@ -35,9 +36,8 @@ function analyzeFile() { // jshint ignore: line fileReader.onloadend = function(){ var text = fileReader.result; analyze(text); - } + }; } - }