提交 9b01f1a6 编写于 作者: D duaraghav8@gmail

Completed Search Feature

上级 c9ae111a
...@@ -4,9 +4,10 @@ module.exports = () => { ...@@ -4,9 +4,10 @@ module.exports = () => {
let $buttons = $('[data-category]'); let $buttons = $('[data-category]');
$('#search-bar').keyup (function () { $('#search-bar').keyup (function () {
let re = new RegExp ($(this).val (), 'i'); let query = $(this).val ();
let re = new RegExp (query, 'i');
if ($(this).val ()) $('#footer').hide (); if (query) $('#footer').hide ();
else $('#footer').show (); else $('#footer').show ();
$.each ($('#list .category'), function (i, c) { $.each ($('#list .category'), function (i, c) {
...@@ -18,15 +19,17 @@ module.exports = () => { ...@@ -18,15 +19,17 @@ module.exports = () => {
let cName = $(this).attr ('data-category'); let cName = $(this).attr ('data-category');
if ($(this).hasClass ('category')) { if ($(this).hasClass ('category')) {
//return !re.test ($('[data-category="${cName}"]').text ()); return !re.test ($(`[data-category="${cName}"]`).text ());
return !re.test ($('[data-category="' + cName + '"]').text ());
} }
else { else {
return !( return !(
//re.test ($('.category[data-category="${cName}"]').text()) || re.test ($(this).text ()) re.test ($(`.category[data-category="${cName}"]`).text()) || re.test ($(this).text ())
re.test ($('.category[data-category="' + cName + '"]').text()) || re.test ($(this).text ())
); );
} }
}).hide (); }).hide ();
$('.algorithms').show ().filter (function () {
return !$(this).children (':visible').length;
}).hide ();
}); });
}; };
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册