mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 06:57:12 -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
|
||||
this.addMultiEventListener("#search", "keyup paste search click", this.ops.searchOperations, 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("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops));
|
||||
document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops));
|
||||
|
|
|
@ -35,7 +35,7 @@ class OperationsWaiter {
|
|||
* @param {boolean} isVisible
|
||||
*
|
||||
*/
|
||||
isVisible( elm, isVisible ){
|
||||
setVisibility( elm, isVisible ){
|
||||
if ( isVisible ) {
|
||||
if ( elm.classList.contains("hidden")) {
|
||||
elm.classList.remove("hidden");
|
||||
|
@ -61,8 +61,8 @@ class OperationsWaiter {
|
|||
hideOperations = document.getElementById("reset-operations");
|
||||
searchResults = document.getElementById("search-results" );
|
||||
|
||||
this.isVisible(categories, true);
|
||||
this.isVisible(hideOperations, true);
|
||||
this.setVisibility(categories, true);
|
||||
this.setVisibility(hideOperations, true);
|
||||
}
|
||||
|
||||
if (e.type === "keyup"){
|
||||
|
@ -71,15 +71,19 @@ class OperationsWaiter {
|
|||
searchResults = document.getElementById("search-results" );
|
||||
|
||||
if ( e.target.value.length === 0 ) {
|
||||
this.isVisible(categories, true);
|
||||
this.isVisible(hideOperations, true);
|
||||
this.setVisibility(categories, true);
|
||||
this.setVisibility(hideOperations, true);
|
||||
} else {
|
||||
this.isVisible(categories, false );
|
||||
this.isVisible(searchResults, true );
|
||||
this.isVisible(hideOperations, true );
|
||||
this.setVisibility(categories, false );
|
||||
this.setVisibility(searchResults, 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
|
||||
e.preventDefault();
|
||||
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;
|
||||
|
||||
search = document.getElementById("search");
|
||||
|
@ -328,9 +333,9 @@ class OperationsWaiter {
|
|||
search.value = '';
|
||||
}
|
||||
|
||||
this.isVisible(categories, false );
|
||||
this.isVisible(searchResults, false );
|
||||
this.isVisible(resetOperations, false );
|
||||
this.setVisibility(categories, false );
|
||||
this.setVisibility(searchResults, false );
|
||||
this.setVisibility(resetOperations, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue