From 0c14bacea7b7218a80c59cfbb43da6d453c89665 Mon Sep 17 00:00:00 2001 From: j433866 Date: Fri, 18 Jan 2019 15:07:19 +0000 Subject: [PATCH 1/3] Add button to input to allow opening of files using the file prompt. --- src/web/InputWaiter.mjs | 20 ++++++++++++++++++++ src/web/Manager.mjs | 1 + src/web/html/index.html | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/src/web/InputWaiter.mjs b/src/web/InputWaiter.mjs index 37f1134..245891f 100755 --- a/src/web/InputWaiter.mjs +++ b/src/web/InputWaiter.mjs @@ -251,6 +251,26 @@ class InputWaiter { } } + /** + * Handler for open input button events + * Loads the opened data into the input textarea + * + * @param {event} e + */ + inputOpen(e) { + e.preventDefault(); + + const file = e.srcElement.files[0]; + + if (file) { + this.closeFile(); + this.loaderWorker = new LoaderWorker(); + this.loaderWorker.addEventListener("message", this.handleLoaderMessage.bind(this)); + this.loaderWorker.postMessage({"file": file}); + this.set(file); + } + } + /** * Handler for messages sent back by the LoaderWorker. diff --git a/src/web/Manager.mjs b/src/web/Manager.mjs index d33616a..c446aba 100755 --- a/src/web/Manager.mjs +++ b/src/web/Manager.mjs @@ -143,6 +143,7 @@ class Manager { this.addMultiEventListener("#input-text", "paste", this.input.inputPaste, this.input); document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app)); document.getElementById("clr-io").addEventListener("click", this.input.clearIoClick.bind(this.input)); + this.addListeners("#open-file", "change", this.input.inputOpen, this.input); this.addListeners("#input-text,#input-file", "dragover", this.input.inputDragover, this.input); this.addListeners("#input-text,#input-file", "dragleave", this.input.inputDragleave, this.input); this.addListeners("#input-text,#input-file", "drop", this.input.inputDrop, this.input); diff --git a/src/web/html/index.html b/src/web/html/index.html index f03590a..cc10f4b 100755 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -225,6 +225,10 @@
+ From acb8c0b5aff0322a93961f809dcf6604ad76118f Mon Sep 17 00:00:00 2001 From: j433866 Date: Fri, 18 Jan 2019 15:12:03 +0000 Subject: [PATCH 2/3] Change icon from folder to input --- src/web/html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/html/index.html b/src/web/html/index.html index cc10f4b..74eb0ed 100755 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -226,7 +226,7 @@