mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Adjust number of tabs shown when resizing window.
Improve refresh tabs logic. Fix input not being shown when loaded from a URL
This commit is contained in:
parent
722edcc274
commit
85809efcc0
4 changed files with 49 additions and 39 deletions
|
@ -200,6 +200,14 @@ class App {
|
||||||
let inputNum = this.manager.input.getActiveTab();
|
let inputNum = this.manager.input.getActiveTab();
|
||||||
if (inputNum === -1) inputNum = 1;
|
if (inputNum === -1) inputNum = 1;
|
||||||
this.manager.input.updateInputValue(inputNum, input);
|
this.manager.input.updateInputValue(inputNum, input);
|
||||||
|
|
||||||
|
this.manager.input.inputWorker.postMessage({
|
||||||
|
action: "setInput",
|
||||||
|
data: {
|
||||||
|
inputNum: inputNum,
|
||||||
|
silent: true
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,6 +272,8 @@ class App {
|
||||||
expandToMin: false,
|
expandToMin: false,
|
||||||
onDrag: function() {
|
onDrag: function() {
|
||||||
this.manager.recipe.adjustWidth();
|
this.manager.recipe.adjustWidth();
|
||||||
|
this.manager.input.calcMaxTabs();
|
||||||
|
this.manager.output.calcMaxTabs();
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -536,6 +546,8 @@ class App {
|
||||||
this.columnSplitter.setSizes([20, 30, 50]);
|
this.columnSplitter.setSizes([20, 30, 50]);
|
||||||
this.ioSplitter.setSizes([50, 50]);
|
this.ioSplitter.setSizes([50, 50]);
|
||||||
this.manager.recipe.adjustWidth();
|
this.manager.recipe.adjustWidth();
|
||||||
|
this.manager.input.calcMaxTabs();
|
||||||
|
this.manager.output.calcMaxTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,10 @@ class InputWaiter {
|
||||||
if (this.inputWorker) {
|
if (this.inputWorker) {
|
||||||
this.inputWorker.postMessage({
|
this.inputWorker.postMessage({
|
||||||
action: "updateMaxTabs",
|
action: "updateMaxTabs",
|
||||||
data: this.maxTabs
|
data: {
|
||||||
|
maxTabs: this.maxTabs,
|
||||||
|
activeTab: this.getActiveTab()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ self.addEventListener("message", function(e) {
|
||||||
self.maxWorkers = r.data;
|
self.maxWorkers = r.data;
|
||||||
break;
|
break;
|
||||||
case "updateMaxTabs":
|
case "updateMaxTabs":
|
||||||
self.maxTabs = r.data;
|
self.updateMaxTabs(r.data.maxTabs, r.data.activeTab);
|
||||||
break;
|
break;
|
||||||
case "updateInputValue":
|
case "updateInputValue":
|
||||||
self.updateInputValue(r.data);
|
self.updateInputValue(r.data);
|
||||||
|
@ -280,15 +280,9 @@ self.getInputProgress = function(inputNum) {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
self.getLargestInputNum = function() {
|
self.getLargestInputNum = function() {
|
||||||
let largest = 0;
|
|
||||||
const inputNums = Object.keys(self.inputs);
|
const inputNums = Object.keys(self.inputs);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
if (inputNums.length === 0) return -1;
|
||||||
const num = parseInt(inputNums[i], 10);
|
return Math.max(...inputNums);
|
||||||
if (num > largest) {
|
|
||||||
largest = num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return largest;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,15 +291,9 @@ self.getLargestInputNum = function() {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
self.getSmallestInputNum = function() {
|
self.getSmallestInputNum = function() {
|
||||||
let smallest = self.getLargestInputNum();
|
|
||||||
const inputNums = Object.keys(self.inputs);
|
const inputNums = Object.keys(self.inputs);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
if (inputNums.length === 0) return -1;
|
||||||
const num = parseInt(inputNums[i], 10);
|
return Math.min(...inputNums);
|
||||||
if (num < smallest) {
|
|
||||||
smallest = num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return smallest;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,8 +303,9 @@ self.getSmallestInputNum = function() {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
self.getPreviousInputNum = function(inputNum) {
|
self.getPreviousInputNum = function(inputNum) {
|
||||||
let num = -1;
|
|
||||||
const inputNums = Object.keys(self.inputs);
|
const inputNums = Object.keys(self.inputs);
|
||||||
|
if (inputNums.length === 0) return -1;
|
||||||
|
let num = Math.min(...inputNums);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
const iNum = parseInt(inputNums[i], 10);
|
||||||
if (iNum < inputNum) {
|
if (iNum < inputNum) {
|
||||||
|
@ -335,8 +324,8 @@ self.getPreviousInputNum = function(inputNum) {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
self.getNextInputNum = function(inputNum) {
|
self.getNextInputNum = function(inputNum) {
|
||||||
let num = self.getLargestInputNum();
|
|
||||||
const inputNums = Object.keys(self.inputs);
|
const inputNums = Object.keys(self.inputs);
|
||||||
|
let num = Math.max(...inputNums);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
const iNum = parseInt(inputNums[i], 10);
|
||||||
if (iNum > inputNum) {
|
if (iNum > inputNum) {
|
||||||
|
@ -884,6 +873,19 @@ self.changeTabLeft = function(inputNum, tabNums) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the maximum number of tabs, and refreshes them if it changes
|
||||||
|
*
|
||||||
|
* @param {number} maxTabs - The new max number of tabs
|
||||||
|
* @param {number} activeTab - The currently selected tab
|
||||||
|
*/
|
||||||
|
self.updateMaxTabs = function(maxTabs, activeTab) {
|
||||||
|
if (self.maxTabs !== maxTabs) {
|
||||||
|
self.maxTabs = maxTabs;
|
||||||
|
self.refreshTabs(activeTab, "right");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search the inputs for any that match the filters provided,
|
* Search the inputs for any that match the filters provided,
|
||||||
* posting the results back to the inputWaiter
|
* posting the results back to the inputWaiter
|
||||||
|
|
|
@ -37,7 +37,10 @@ class OutputWaiter {
|
||||||
*/
|
*/
|
||||||
calcMaxTabs() {
|
calcMaxTabs() {
|
||||||
const numTabs = Math.floor((document.getElementById("IO").offsetWidth - 75) / 120);
|
const numTabs = Math.floor((document.getElementById("IO").offsetWidth - 75) / 120);
|
||||||
this.maxTabs = numTabs;
|
if (numTabs !== this.maxTabs) {
|
||||||
|
this.maxTabs = numTabs;
|
||||||
|
this.refreshTabs(this.getActiveTab());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -802,15 +805,9 @@ class OutputWaiter {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
getLargestInputNum() {
|
getLargestInputNum() {
|
||||||
let largest = 0;
|
|
||||||
const inputNums = Object.keys(this.outputs);
|
const inputNums = Object.keys(this.outputs);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
if (inputNums.length === 0) return -1;
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
return Math.max(...inputNums);
|
||||||
if (iNum > largest) {
|
|
||||||
largest = iNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return largest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -819,15 +816,9 @@ class OutputWaiter {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
getSmallestInputNum() {
|
getSmallestInputNum() {
|
||||||
let smallest = this.getLargestInputNum();
|
|
||||||
const inputNums = Object.keys(this.outputs);
|
const inputNums = Object.keys(this.outputs);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
if (inputNums.length === 0) return -1;
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
return Math.min(...inputNums);
|
||||||
if (iNum < smallest) {
|
|
||||||
smallest = iNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return smallest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -837,8 +828,9 @@ class OutputWaiter {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
getPreviousInputNum(inputNum) {
|
getPreviousInputNum(inputNum) {
|
||||||
let num = this.getSmallestInputNum();
|
|
||||||
const inputNums = Object.keys(this.outputs);
|
const inputNums = Object.keys(this.outputs);
|
||||||
|
if (inputNums.length === 0) return -1;
|
||||||
|
let num = Math.min(...inputNums);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
const iNum = parseInt(inputNums[i], 10);
|
||||||
if (iNum < inputNum) {
|
if (iNum < inputNum) {
|
||||||
|
@ -857,8 +849,9 @@ class OutputWaiter {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
getNextInputNum(inputNum) {
|
getNextInputNum(inputNum) {
|
||||||
let num = this.getLargestInputNum();
|
|
||||||
const inputNums = Object.keys(this.outputs);
|
const inputNums = Object.keys(this.outputs);
|
||||||
|
if (inputNums.length === 0) return -1;
|
||||||
|
let num = Math.max(...inputNums);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
const iNum = parseInt(inputNums[i], 10);
|
const iNum = parseInt(inputNums[i], 10);
|
||||||
if (iNum > inputNum) {
|
if (iNum > inputNum) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue