mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
Merge branch 'open-file-button' of https://github.com/j433866/CyberChef into j433866-open-file-button
This commit is contained in:
commit
d71aa8d7e2
3 changed files with 25 additions and 0 deletions
|
@ -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.
|
* Handler for messages sent back by the LoaderWorker.
|
||||||
|
|
|
@ -146,6 +146,7 @@ class Manager {
|
||||||
this.addMultiEventListener("#input-text", "paste", this.input.inputPaste, this.input);
|
this.addMultiEventListener("#input-text", "paste", this.input.inputPaste, this.input);
|
||||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
||||||
document.getElementById("clr-io").addEventListener("click", this.input.clearIoClick.bind(this.input));
|
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", "dragover", this.input.inputDragover, this.input);
|
||||||
this.addListeners("#input-text,#input-file", "dragleave", this.input.inputDragleave, 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);
|
this.addListeners("#input-text,#input-file", "drop", this.input.inputDrop, this.input);
|
||||||
|
|
|
@ -225,6 +225,10 @@
|
||||||
<div class="title no-select">
|
<div class="title no-select">
|
||||||
<label for="input-text">Input</label>
|
<label for="input-text">Input</label>
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
|
<button type="button" class="btn btn-primary bmd-btn-icon" id="btn-open-file" data-toggle="tooltip" title="Open file as input" onclick="document.getElementById('open-file').click();">
|
||||||
|
<i class="material-icons">input</i>
|
||||||
|
<input type="file" id="open-file" style="display: none">
|
||||||
|
</button>
|
||||||
<button type="button" class="btn btn-primary bmd-btn-icon" id="clr-io" data-toggle="tooltip" title="Clear input and output">
|
<button type="button" class="btn btn-primary bmd-btn-icon" id="clr-io" data-toggle="tooltip" title="Clear input and output">
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in a new issue