2016-02-08 20:21:41 -05:00
|
|
|
((_) => {
|
2016-02-01 09:49:18 -05:00
|
|
|
|
|
|
|
'use strict';
|
2015-07-02 14:04:04 -04:00
|
|
|
|
2018-01-30 16:57:13 -05:00
|
|
|
const search = (query) => {
|
|
|
|
// Show the loader
|
2016-02-08 20:21:41 -05:00
|
|
|
_.$('.cssload-loader')[0].removeAttribute('hidden');
|
2018-01-30 16:57:13 -05:00
|
|
|
|
|
|
|
// Do the api search
|
2017-09-14 17:32:40 -04:00
|
|
|
_.get(_.url('/anime-collection/search'), {query}, (searchResults, status) => {
|
2016-02-08 13:37:44 -05:00
|
|
|
searchResults = JSON.parse(searchResults);
|
2015-07-02 14:04:04 -04:00
|
|
|
|
2018-01-30 16:57:13 -05:00
|
|
|
// Hide the loader
|
|
|
|
_.$('.cssload-loader')[0].setAttribute('hidden', 'hidden');
|
2016-02-02 11:34:03 -05:00
|
|
|
|
2018-01-30 16:57:13 -05:00
|
|
|
// Show the results
|
|
|
|
_.$('#series_list')[0].innerHTML = render_anime_search_results(searchResults.data);
|
2016-02-02 11:34:03 -05:00
|
|
|
});
|
|
|
|
};
|
2016-02-01 09:49:18 -05:00
|
|
|
|
2018-01-30 16:57:13 -05:00
|
|
|
_.on('#search', 'keyup', _.throttle(250, function() {
|
|
|
|
const query = encodeURIComponent(this.value);
|
2016-02-02 21:28:32 -05:00
|
|
|
if (query === '') {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-01 09:49:18 -05:00
|
|
|
|
2018-01-30 16:57:13 -05:00
|
|
|
search(query);
|
2016-02-01 09:49:18 -05:00
|
|
|
}));
|
|
|
|
|
2016-02-08 20:21:41 -05:00
|
|
|
})(AnimeClient);
|