mirror of
https://github.com/0dayCTF/reverse-shell-generator.git
synced 2024-12-22 04:46:11 +00:00
Fixed Search Bug
Not the best fix, but it'll work for now!
This commit is contained in:
parent
aa284c1ec4
commit
af821dbf78
72
js/script.js
72
js/script.js
@ -537,31 +537,67 @@ $(function () {
|
|||||||
// TODO: add a random fifo for netcat mkfifo
|
// TODO: add a random fifo for netcat mkfifo
|
||||||
//let randomId = Math.random().toString(36).substring(2, 4);
|
//let randomId = Math.random().toString(36).substring(2, 4);
|
||||||
|
|
||||||
// Search functionality
|
// Global variable to keep track of the last search term
|
||||||
document.getElementById('searchBox').addEventListener('keyup', function() {
|
// This variable will hold the last search term
|
||||||
var searchTerm = this.value.toLowerCase();
|
// 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 listItems = document.querySelectorAll('#reverse-shell-selection .list-group-item');
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
listItems.forEach(function(item) {
|
listItems.forEach(function(item) {
|
||||||
var text = item.textContent.toLowerCase();
|
var text = item.textContent.toLowerCase();
|
||||||
var match = text.indexOf(searchTerm) !== -1;
|
var match = text.indexOf(term) !== -1;
|
||||||
if (match) {
|
item.style.display = match ? '' : 'none';
|
||||||
item.style.display = '';
|
if (match) count++;
|
||||||
count++;
|
|
||||||
} else {
|
|
||||||
item.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
// Reattach event listeners to the filtered items
|
||||||
document.querySelectorAll('#reverse-shell-selection .list-group-item').forEach(function(item) {
|
attachClickListenersToItems();
|
||||||
item.addEventListener('click', function(event) {
|
}
|
||||||
event.preventDefault();
|
|
||||||
console.log(item.textContent);
|
// Attach click event listeners to search result items
|
||||||
document.getElementById('searchBox').dispatchEvent(new Event('keyup'));
|
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