mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
[#181] resetOperations on escape key
This commit is contained in:
parent
b4c0378a01
commit
e74d7998fd
2 changed files with 19 additions and 14 deletions
|
@ -145,7 +145,7 @@ class Manager {
|
||||||
// Operations
|
// Operations
|
||||||
this.addMultiEventListener("#search", "keyup paste search click", this.ops.searchOperations, this.ops);
|
this.addMultiEventListener("#search", "keyup paste search click", this.ops.searchOperations, this.ops);
|
||||||
this.addDynamicListener(".op-list li.operation", "dblclick", this.ops.operationDblclick, this.ops);
|
this.addDynamicListener(".op-list li.operation", "dblclick", this.ops.operationDblclick, this.ops);
|
||||||
document.getElementById("reset-operations").addEventListener("click", this.ops.resetOperationsClick.bind(this.ops));
|
document.getElementById("reset-operations").addEventListener("click", this.ops.resetOperations.bind(this.ops));
|
||||||
document.getElementById("edit-favourites").addEventListener("click", this.ops.editFavouritesClick.bind(this.ops));
|
document.getElementById("edit-favourites").addEventListener("click", this.ops.editFavouritesClick.bind(this.ops));
|
||||||
document.getElementById("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops));
|
document.getElementById("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops));
|
||||||
document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops));
|
document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops));
|
||||||
|
|
|
@ -35,7 +35,7 @@ class OperationsWaiter {
|
||||||
* @param {boolean} isVisible
|
* @param {boolean} isVisible
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
isVisible( elm, isVisible ){
|
setVisibility( elm, isVisible ){
|
||||||
if ( isVisible ) {
|
if ( isVisible ) {
|
||||||
if ( elm.classList.contains("hidden")) {
|
if ( elm.classList.contains("hidden")) {
|
||||||
elm.classList.remove("hidden");
|
elm.classList.remove("hidden");
|
||||||
|
@ -61,8 +61,8 @@ class OperationsWaiter {
|
||||||
hideOperations = document.getElementById("reset-operations");
|
hideOperations = document.getElementById("reset-operations");
|
||||||
searchResults = document.getElementById("search-results" );
|
searchResults = document.getElementById("search-results" );
|
||||||
|
|
||||||
this.isVisible(categories, true);
|
this.setVisibility(categories, true);
|
||||||
this.isVisible(hideOperations, true);
|
this.setVisibility(hideOperations, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.type === "keyup"){
|
if (e.type === "keyup"){
|
||||||
|
@ -71,15 +71,19 @@ class OperationsWaiter {
|
||||||
searchResults = document.getElementById("search-results" );
|
searchResults = document.getElementById("search-results" );
|
||||||
|
|
||||||
if ( e.target.value.length === 0 ) {
|
if ( e.target.value.length === 0 ) {
|
||||||
this.isVisible(categories, true);
|
this.setVisibility(categories, true);
|
||||||
this.isVisible(hideOperations, true);
|
this.setVisibility(hideOperations, true);
|
||||||
} else {
|
} else {
|
||||||
this.isVisible(categories, false );
|
this.setVisibility(categories, false );
|
||||||
this.isVisible(searchResults, true );
|
this.setVisibility(searchResults, true );
|
||||||
this.isVisible(hideOperations, true );
|
this.setVisibility(hideOperations, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.type === "keyup" && e.keyCode === 27 ) { // Escape
|
||||||
|
this.resetOperations();
|
||||||
|
}
|
||||||
|
|
||||||
if (e.type === "search" || e.keyCode === 13) { // Search or Return
|
if (e.type === "search" || e.keyCode === 13) { // Search or Return
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ops = document.querySelectorAll("#search-results li");
|
ops = document.querySelectorAll("#search-results li");
|
||||||
|
@ -313,9 +317,10 @@ class OperationsWaiter {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide any operation lists ( #categories or #search-results ) and the close button on click
|
* Hide any operation lists ( #categories or #search-results ) and the reset-operations button itself,
|
||||||
|
* clear any search input
|
||||||
*/
|
*/
|
||||||
resetOperationsClick(){
|
resetOperations(){
|
||||||
let search, categories, searchResults, resetOperations;
|
let search, categories, searchResults, resetOperations;
|
||||||
|
|
||||||
search = document.getElementById("search");
|
search = document.getElementById("search");
|
||||||
|
@ -328,9 +333,9 @@ class OperationsWaiter {
|
||||||
search.value = '';
|
search.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isVisible(categories, false );
|
this.setVisibility(categories, false );
|
||||||
this.isVisible(searchResults, false );
|
this.setVisibility(searchResults, false );
|
||||||
this.isVisible(resetOperations, false );
|
this.setVisibility(resetOperations, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue