mirror of
https://github.com/0dayCTF/reverse-shell-generator.git
synced 2024-12-18 10:56:10 +00:00
Fixed Search Bug
Not the best fix, but it'll work for now!
This commit is contained in:
parent
aa284c1ec4
commit
af821dbf78
74
js/script.js
74
js/script.js
@ -537,31 +537,67 @@ $(function () {
|
||||
// TODO: add a random fifo for netcat mkfifo
|
||||
//let randomId = Math.random().toString(36).substring(2, 4);
|
||||
|
||||
// Search functionality
|
||||
document.getElementById('searchBox').addEventListener('keyup', function() {
|
||||
var searchTerm = this.value.toLowerCase();
|
||||
// Global variable to keep track of the last search term
|
||||
// This variable will hold the last search term
|
||||
// This function will apply the search filter to the list
|
||||
// Utility function to save the search term
|
||||
function saveSearchTerm(term) {
|
||||
localStorage.setItem('searchTerm', term);
|
||||
}
|
||||
|
||||
// Utility function to get the saved search term
|
||||
function getSavedSearchTerm() {
|
||||
return localStorage.getItem('searchTerm');
|
||||
}
|
||||
|
||||
// Function to apply the search filter
|
||||
function applySearchFilter(term) {
|
||||
var listItems = document.querySelectorAll('#reverse-shell-selection .list-group-item');
|
||||
var count = 0;
|
||||
|
||||
|
||||
listItems.forEach(function(item) {
|
||||
var text = item.textContent.toLowerCase();
|
||||
var match = text.indexOf(searchTerm) !== -1;
|
||||
if (match) {
|
||||
item.style.display = '';
|
||||
count++;
|
||||
} else {
|
||||
item.style.display = 'none';
|
||||
}
|
||||
var match = text.indexOf(term) !== -1;
|
||||
item.style.display = match ? '' : 'none';
|
||||
if (match) count++;
|
||||
});
|
||||
|
||||
document.getElementById('noResults').style.display = count === 0 ? '' : 'none';
|
||||
});
|
||||
// Show or hide the 'no results' message
|
||||
var noResultsEl = document.getElementById('noResults');
|
||||
if (noResultsEl) {
|
||||
noResultsEl.style.display = count === 0 ? 'block' : 'none';
|
||||
}
|
||||
|
||||
// Event listener for search results
|
||||
document.querySelectorAll('#reverse-shell-selection .list-group-item').forEach(function(item) {
|
||||
item.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
console.log(item.textContent);
|
||||
document.getElementById('searchBox').dispatchEvent(new Event('keyup'));
|
||||
// Reattach event listeners to the filtered items
|
||||
attachClickListenersToItems();
|
||||
}
|
||||
|
||||
// Attach click event listeners to search result items
|
||||
function attachClickListenersToItems() {
|
||||
document.querySelectorAll('#reverse-shell-selection .list-group-item').forEach(function(item) {
|
||||
item.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
var searchTerm = getSavedSearchTerm();
|
||||
if (searchTerm) {
|
||||
applySearchFilter(searchTerm);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Set up the initial event listener for the search box
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var searchBox = document.getElementById('searchBox');
|
||||
if (searchBox) {
|
||||
searchBox.value = getSavedSearchTerm() || '';
|
||||
applySearchFilter(searchBox.value.toLowerCase());
|
||||
|
||||
searchBox.addEventListener('keyup', function() {
|
||||
var searchTerm = this.value.toLowerCase();
|
||||
saveSearchTerm(searchTerm);
|
||||
applySearchFilter(searchTerm);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user