Commit ab852959 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers 🐦

clean up filter code

parent 5c629c87
Pipeline #874 passed with stages
in 21 seconds
......@@ -56,22 +56,30 @@ function loadAndDisplay(){
});
}
/**
* initialise the filtering box
*/
function filterInit() {
$('#rulesetFilter').on( 'input', function() {
filterRules($(this).val());
});
}
/**
* Find rules in the set which match some user provided substring, hide all other rules.
*/
function filterRules(query){
query = query.toLowerCase();
$('#ruleset li').filter( function (index) {
return $(this).children('.name').text().toLowerCase().includes(query);
}).css("display", "block");
$('#ruleset li').each( function( _, item) {
item_jq = $(item);
$('#ruleset li').filter( function (index) {
return !$(this).children('.name').text().toLowerCase().includes(query);
}).css("display", "none");
if (item_jq.children('.name').text().toLowerCase().includes(query)) {
item_jq.show();
} else {
item_jq.hide();
}
});
}
function updateGraph(json){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment