mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 05:04:21 +01:00
Fixed single object - Bug:#4
This commit is contained in:
@@ -110,11 +110,18 @@
|
|||||||
}
|
}
|
||||||
searchResultsEl.style.offsetWidth;
|
searchResultsEl.style.offsetWidth;
|
||||||
|
|
||||||
var matchingPosts = posts.filter(function (post) {
|
var matchingPosts;
|
||||||
if ((post.title + '').toLowerCase().indexOf(currentInputValue) !== -1 || (post.description + '').toLowerCase().indexOf(currentInputValue) !== -1) {
|
// check the `posts` object is single or many objects.
|
||||||
return true;
|
// if posts.title === undefined, so posts is many objects.
|
||||||
}
|
if(posts.title === undefined) {
|
||||||
});
|
matchingPosts = posts.filter(function (post) {
|
||||||
|
if ((post.title + '').toLowerCase().indexOf(currentInputValue) !== -1 || (post.description + '').toLowerCase().indexOf(currentInputValue) !== -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
matchingPosts = [posts]; // assign single object to Array
|
||||||
|
}
|
||||||
if (!matchingPosts.length) {
|
if (!matchingPosts.length) {
|
||||||
searchResultsEl.classList.add('is-hidden');
|
searchResultsEl.classList.add('is-hidden');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user