mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 13:14:21 +01:00
Fixed single object - Bug:#4
This commit is contained in:
@@ -110,11 +110,18 @@
|
||||
}
|
||||
searchResultsEl.style.offsetWidth;
|
||||
|
||||
var matchingPosts = posts.filter(function (post) {
|
||||
if ((post.title + '').toLowerCase().indexOf(currentInputValue) !== -1 || (post.description + '').toLowerCase().indexOf(currentInputValue) !== -1) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
var matchingPosts;
|
||||
// check the `posts` object is single or many objects.
|
||||
// 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) {
|
||||
searchResultsEl.classList.add('is-hidden');
|
||||
}
|
||||
@@ -129,4 +136,4 @@
|
||||
lastSearchResultHash = currentResultHash;
|
||||
});
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user