mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 09:16:17 -04:00
replace "options" with "arguments", invert global hide-icon if needed
This commit is contained in:
parent
3bb6a40f82
commit
ed7baf57f0
5 changed files with 41 additions and 24 deletions
|
@ -334,29 +334,29 @@ class ControlsWaiter {
|
|||
|
||||
|
||||
/**
|
||||
* Hides the options for all the operations in the current recipe.
|
||||
* Hides the arguments for all the operations in the current recipe.
|
||||
*/
|
||||
hideRecipeOptClick() {
|
||||
hideRecipeArgsClick() {
|
||||
const icon = document.getElementById("hide-icon");
|
||||
|
||||
if (icon.getAttribute("hide-opt") === "false") {
|
||||
icon.setAttribute("hide-opt", "true");
|
||||
icon.setAttribute("data-original-title", "Show options");
|
||||
if (icon.getAttribute("hide-args") === "false") {
|
||||
icon.setAttribute("hide-args", "true");
|
||||
icon.setAttribute("data-original-title", "Show arguments");
|
||||
icon.children[0].innerText = "keyboard_arrow_down";
|
||||
Array.from(document.getElementsByClassName("hide-options")).forEach(function(item){
|
||||
item.setAttribute("hide-opt", "true");
|
||||
Array.from(document.getElementsByClassName("hide-args-icon")).forEach(function(item){
|
||||
item.setAttribute("hide-args", "true");
|
||||
item.innerText = "keyboard_arrow_down";
|
||||
item.classList.add("hide-options-selected");
|
||||
item.classList.add("hide-args-selected");
|
||||
item.parentNode.previousElementSibling.style.display = "none";
|
||||
});
|
||||
} else {
|
||||
icon.setAttribute("hide-opt", "false");
|
||||
icon.setAttribute("data-original-title", "Hide options");
|
||||
icon.setAttribute("hide-args", "false");
|
||||
icon.setAttribute("data-original-title", "Hide arguments");
|
||||
icon.children[0].innerText = "keyboard_arrow_up";
|
||||
Array.from(document.getElementsByClassName("hide-options")).forEach(function(item){
|
||||
item.setAttribute("hide-opt", "false");
|
||||
Array.from(document.getElementsByClassName("hide-args-icon")).forEach(function(item){
|
||||
item.setAttribute("hide-args", "false");
|
||||
item.innerText = "keyboard_arrow_up";
|
||||
item.classList.remove("hide-options-selected");
|
||||
item.classList.remove("hide-args-selected");
|
||||
item.parentNode.previousElementSibling.style.display = "grid";
|
||||
});
|
||||
}
|
||||
|
|
|
@ -215,27 +215,44 @@ class RecipeWaiter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handler for hide-opt click events.
|
||||
* Handler for hide-args click events.
|
||||
* Updates the icon status.
|
||||
*
|
||||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
hideOptClick(e) {
|
||||
hideArgsClick(e) {
|
||||
const icon = e.target;
|
||||
|
||||
if (icon.getAttribute("hide-opt") === "false") {
|
||||
icon.setAttribute("hide-opt", "true");
|
||||
if (icon.getAttribute("hide-args") === "false") {
|
||||
icon.setAttribute("hide-args", "true");
|
||||
icon.innerText = "keyboard_arrow_down";
|
||||
icon.classList.add("hide-options-selected");
|
||||
icon.classList.add("hide-args-selected");
|
||||
icon.parentNode.previousElementSibling.style.display = "none";
|
||||
} else {
|
||||
icon.setAttribute("hide-opt", "false");
|
||||
icon.setAttribute("hide-args", "false");
|
||||
icon.innerText = "keyboard_arrow_up";
|
||||
icon.classList.remove("hide-options-selected");
|
||||
icon.classList.remove("hide-args-selected");
|
||||
icon.parentNode.previousElementSibling.style.display = "grid";
|
||||
}
|
||||
|
||||
const icons = Array.from(document.getElementsByClassName("hide-args-icon"));
|
||||
if (icons.length > 1) {
|
||||
// Check if ALL the icons are hidden/shown
|
||||
const uniqueIcons = icons.map(function(item) {
|
||||
return item.getAttribute("hide-args");
|
||||
}).unique();
|
||||
console.log(uniqueIcons)
|
||||
|
||||
const controlsIconStatus = document.getElementById("hide-icon").getAttribute("hide-args");
|
||||
console.log(controlsIconStatus)
|
||||
|
||||
// If all icons are in the same state and the global icon isn't, fix it
|
||||
if (uniqueIcons.length === 1 && icon.getAttribute("hide-args") !== controlsIconStatus) {
|
||||
this.manager.controls.hideRecipeArgsClick()
|
||||
}
|
||||
}
|
||||
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue