HummingBirdAnimeClient/public/js/manga_collection.js

32 lines
797 B
JavaScript
Raw Normal View History

2016-02-08 20:21:41 -05:00
((_) => {
2016-02-02 11:34:03 -05:00
'use strict';
const search = (tempHtml, query) => {
2016-02-08 20:21:41 -05:00
_.$('.cssload-loader')[0].removeAttribute('hidden');
2017-02-16 13:22:26 -05:00
_.get(_.url('/manga/search'), {query}, (searchResults, status) => {
2016-02-08 13:37:44 -05:00
searchResults = JSON.parse(searchResults);
2016-02-08 20:21:41 -05:00
_.$('.cssload-loader')[0].setAttribute('hidden', 'hidden');
2016-02-02 11:34:03 -05:00
2017-03-29 15:14:30 -04:00
// Give mustache a key to iterate over
searchResults = {
data: searchResults.data
};
2016-02-02 11:34:03 -05:00
Mustache.parse(tempHtml);
2016-02-08 20:21:41 -05:00
_.$('#series_list')[0].innerHTML = Mustache.render(tempHtml, searchResults);
2016-02-02 11:34:03 -05:00
});
};
2017-02-16 13:22:26 -05:00
_.get('/public/templates/manga-ajax-search-results.html', (tempHtml) => {
2016-02-08 20:21:41 -05:00
_.on('#search', 'keyup', _.throttle(250, function(e) {
let query = encodeURIComponent(this.value);
2016-02-02 11:34:03 -05:00
if (query === '') {
return;
}
search(tempHtml, query);
}));
});
2016-02-08 20:21:41 -05:00
})(AnimeClient);