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
|
|
|
|
2016-02-02 11:34:03 -05:00
|
|
|
const search = (tempHtml, query) => {
|
2016-02-08 20:21:41 -05:00
|
|
|
_.$('.cssload-loader')[0].removeAttribute('hidden');
|
|
|
|
_.get(_.url('/collection/search'), {'query':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');
|
2015-07-02 14:04:04 -04:00
|
|
|
|
2016-02-02 11:34:03 -05:00
|
|
|
// Give mustache a key to iterate over
|
|
|
|
searchResults = {
|
2017-01-05 13:41:32 -05:00
|
|
|
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
|
|
|
});
|
|
|
|
};
|
2016-02-01 09:49:18 -05:00
|
|
|
|
2016-02-08 20:21:41 -05:00
|
|
|
_.get('/public/templates/anime-ajax-search-results.html', tempHtml => {
|
|
|
|
_.on('#search', 'keyup', _.throttle(250, function(e) {
|
2016-02-08 11:32:39 -05:00
|
|
|
let query = encodeURIComponent(this.value);
|
2016-02-02 21:28:32 -05:00
|
|
|
if (query === '') {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-01 09:49:18 -05:00
|
|
|
|
2016-02-02 11:34:03 -05:00
|
|
|
search(tempHtml, query);
|
2016-02-01 09:49:18 -05:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2016-02-08 20:21:41 -05:00
|
|
|
})(AnimeClient);
|