forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenable_search.js
More file actions
33 lines (27 loc) · 816 Bytes
/
enable_search.js
File metadata and controls
33 lines (27 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
module.exports = () => {
let $buttons = $('[data-category]');
$('#search-bar').keyup (function () {
let query = $(this).val ();
let re = new RegExp (query, 'i');
query ? $('#footer').hide () : $('#footer').show ();
$.each ($('#list .category'), function (i, c) {
let $c = $(c);
!$c.hasClass ('open') && $c.click ();
});
$buttons.show ().filter (function () {
let cName = $(this).attr ('data-category');
if ($(this).hasClass ('category')) {
return !re.test ($(`[data-category="${cName}"]`).text ());
}
else {
return !(
re.test ($(`.category[data-category="${cName}"]`).text()) || re.test ($(this).text ())
);
}
}).hide ();
$('.algorithms').show ().filter (function () {
return !$(this).children (':visible').length;
}).hide ();
});
};