diff --git a/OOMAnalyser.html b/OOMAnalyser.html index 2d8cedb..3875668 100644 --- a/OOMAnalyser.html +++ b/OOMAnalyser.html @@ -180,6 +180,31 @@ function goBack() { window.history.back(); } + +// Add listener after the document has been loaded completely +window.addEventListener('DOMContentLoaded', function() { + let dropArea = document.getElementById('input'); + dropArea.addEventListener('drop', file_dragged, false); +}); + +// Event handler triggered if a file has been dragged +function file_dragged(event) { + let file = event.dataTransfer.files[0] + event.preventDefault() + read_and_display_file(file) + return true; +}; + +// Read and display local file +function read_and_display_file(file) { + let reader = new FileReader(); + reader.onload = function(e) { + let textarea_oom = document.getElementById('textarea_oom') + textarea_oom.value = reader.result; + } + reader.readAsText(file); +} +
@@ -210,7 +235,13 @@ function goBack() {