mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Add min / max inputNums on go to tab dialog
This commit is contained in:
parent
2575a762e1
commit
17b95f1609
2 changed files with 70 additions and 20 deletions
|
@ -50,7 +50,6 @@ class InputWaiter {
|
||||||
this.workerId = 0;
|
this.workerId = 0;
|
||||||
this.maxWorkers = navigator.hardwareConcurrency || 4;
|
this.maxWorkers = navigator.hardwareConcurrency || 4;
|
||||||
this.maxTabs = 4;
|
this.maxTabs = 4;
|
||||||
this.inputTimeout = null;
|
|
||||||
this.callbacks = {};
|
this.callbacks = {};
|
||||||
this.callbackID = 0;
|
this.callbackID = 0;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +291,7 @@ class InputWaiter {
|
||||||
this.manager.output.inputSwitch(r.data);
|
this.manager.output.inputSwitch(r.data);
|
||||||
break;
|
break;
|
||||||
case "getInput":
|
case "getInput":
|
||||||
|
case "getInputNums":
|
||||||
this.callbacks[r.data.id](r.data);
|
this.callbacks[r.data.id](r.data);
|
||||||
break;
|
break;
|
||||||
case "removeChefWorker":
|
case "removeChefWorker":
|
||||||
|
@ -576,6 +576,39 @@ class InputWaiter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of inputs from the inputWorker
|
||||||
|
*
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
async getInputNums() {
|
||||||
|
return await new Promise(resolve => {
|
||||||
|
this.getNums(r => {
|
||||||
|
resolve({
|
||||||
|
inputNums: r.inputNums,
|
||||||
|
min: r.min,
|
||||||
|
max: r.max
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of inputNums from the inputWorker, and sends
|
||||||
|
* them back to the specified callback
|
||||||
|
*/
|
||||||
|
getNums(callback) {
|
||||||
|
const id = this.callbackID++;
|
||||||
|
|
||||||
|
this.callbacks[id] = callback;
|
||||||
|
|
||||||
|
this.inputWorker.postMessage({
|
||||||
|
action: "getInputNums",
|
||||||
|
data: id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays information about the input.
|
* Displays information about the input.
|
||||||
*
|
*
|
||||||
|
@ -1346,8 +1379,9 @@ class InputWaiter {
|
||||||
/**
|
/**
|
||||||
* Handler for go to tab button clicked
|
* Handler for go to tab button clicked
|
||||||
*/
|
*/
|
||||||
goToTab() {
|
async goToTab() {
|
||||||
const tabNum = parseInt(window.prompt("Enter tab number:", this.getActiveTab().toString()), 10);
|
const inputNums = await this.getInputNums();
|
||||||
|
const tabNum = parseInt(window.prompt(`Enter tab number (${inputNums.min} - ${inputNums.max}):`, this.getActiveTab().toString()), 10);
|
||||||
this.changeTab(tabNum, this.app.options.syncTabs);
|
this.changeTab(tabNum, this.app.options.syncTabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,9 @@ self.addEventListener("message", function(e) {
|
||||||
case "getInput":
|
case "getInput":
|
||||||
self.getInput(r.data);
|
self.getInput(r.data);
|
||||||
break;
|
break;
|
||||||
|
case "getInputNums":
|
||||||
|
self.getInputNums(r.data);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
log.error(`Unknown action '${r.action}'.`);
|
log.error(`Unknown action '${r.action}'.`);
|
||||||
}
|
}
|
||||||
|
@ -250,23 +253,36 @@ self.getInputValue = function(inputNum) {
|
||||||
* @param {number} inputData.id - The callback ID for the callback to run when returned to the inputWaiter
|
* @param {number} inputData.id - The callback ID for the callback to run when returned to the inputWaiter
|
||||||
*/
|
*/
|
||||||
self.getInput = function(inputData) {
|
self.getInput = function(inputData) {
|
||||||
if (inputData.getObj) {
|
const inputNum = inputData.inputNum,
|
||||||
self.postMessage({
|
data = (inputData.getObj) ? self.getInputObj(inputNum) : self.getInputValue(inputNum);
|
||||||
action: "getInput",
|
self.postMessage({
|
||||||
data: {
|
action: "getInput",
|
||||||
data: self.getInputObj(inputData.inputNum),
|
data: {
|
||||||
id: inputData.id
|
data: data,
|
||||||
}
|
id: inputData.id
|
||||||
});
|
}
|
||||||
} else {
|
});
|
||||||
self.postMessage({
|
};
|
||||||
action: "getInput",
|
|
||||||
data: {
|
/**
|
||||||
data: self.getInputValue(inputData.inputNum),
|
* Gets a list of the stored inputNums, along with the minimum and maximum
|
||||||
id: inputData.id
|
*
|
||||||
}
|
* @param {number} id - The callback ID to be executed when returned to the inputWaiter
|
||||||
});
|
*/
|
||||||
}
|
self.getInputNums = function(id) {
|
||||||
|
const inputNums = Object.keys(self.inputs),
|
||||||
|
min = self.getSmallestInputNum(inputNums),
|
||||||
|
max = self.getLargestInputNum(inputNums);
|
||||||
|
|
||||||
|
self.postMessage({
|
||||||
|
action: "getInputNums",
|
||||||
|
data: {
|
||||||
|
inputNums: inputNums,
|
||||||
|
min: min,
|
||||||
|
max: max,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue