mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Make set() asynchronous
This commit is contained in:
parent
3cffd9334f
commit
50f9bbeac3
2 changed files with 140 additions and 137 deletions
|
@ -306,7 +306,8 @@ class InputWaiter {
|
|||
* @param {number} inputData.progress
|
||||
* @param {boolean} [silent=false]
|
||||
*/
|
||||
set(inputData, silent=false) {
|
||||
async set(inputData, silent=false) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const activeTab = this.getActiveTab();
|
||||
if (inputData.inputNum !== activeTab) return;
|
||||
|
||||
|
@ -338,7 +339,7 @@ class InputWaiter {
|
|||
}
|
||||
|
||||
if (!silent) window.dispatchEvent(this.manager.statechange);
|
||||
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,6 +65,8 @@ class OutputWaiter {
|
|||
}
|
||||
|
||||
data = data.buffer;
|
||||
} else if (typeof data !== "object" && typeof data !== "string") {
|
||||
data = String(data);
|
||||
}
|
||||
return data;
|
||||
} else if (typeof this.outputs[inputNum].data.result === "string") {
|
||||
|
@ -226,7 +228,8 @@ class OutputWaiter {
|
|||
*
|
||||
* @param {number} inputNum
|
||||
*/
|
||||
set(inputNum) {
|
||||
async set(inputNum) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const output = this.outputs[inputNum];
|
||||
if (output === undefined || output === null) return;
|
||||
if (typeof inputNum !== "number") inputNum = parseInt(inputNum, 10);
|
||||
|
@ -351,6 +354,7 @@ class OutputWaiter {
|
|||
this.setOutputInfo(length, lines, output.data.duration);
|
||||
this.backgroundMagic();
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,8 +363,6 @@ class OutputWaiter {
|
|||
* @param {ArrayBuffer} buf
|
||||
*/
|
||||
setFile(buf) {
|
||||
const file = new File([buf], "output.dat");
|
||||
|
||||
// Display file overlay in output area with details
|
||||
const fileOverlay = document.getElementById("output-file"),
|
||||
fileSize = document.getElementById("output-file-size"),
|
||||
|
@ -368,7 +370,7 @@ class OutputWaiter {
|
|||
fileSlice = buf.slice(0, 4096);
|
||||
|
||||
fileOverlay.style.display = "block";
|
||||
fileSize.textContent = file.size.toLocaleString() + " bytes";
|
||||
fileSize.textContent = buf.byteLength.toLocaleString() + " bytes";
|
||||
|
||||
outputText.classList.add("blur");
|
||||
outputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue