2016-02-01 09:49:18 -05:00
|
|
|
(($, AnimeClient) => {
|
|
|
|
|
|
|
|
'use strict';
|
2015-07-02 14:04:04 -04:00
|
|
|
|
2016-02-02 11:34:03 -05:00
|
|
|
const search = (tempHtml, query) => {
|
|
|
|
$('.cssload-loader').removeAttr('hidden');
|
|
|
|
$.get(AnimeClient.url('/collection/search'), {'query':query}, (searchResults, status) => {
|
|
|
|
$('.cssload-loader').attr('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 = {
|
|
|
|
anime: searchResults
|
|
|
|
};
|
|
|
|
|
|
|
|
Mustache.parse(tempHtml);
|
|
|
|
$('#series_list').html(Mustache.render(tempHtml, searchResults));
|
|
|
|
});
|
|
|
|
};
|
2016-02-01 09:49:18 -05:00
|
|
|
|
2016-02-02 11:34:03 -05:00
|
|
|
$.get('/public/templates/anime-ajax-search-results.html', tempHtml => {
|
|
|
|
$('#search').on('keypress', AnimeClient.throttle(250, function(e) {
|
|
|
|
let query = encodeURIComponent($(this).val());
|
|
|
|
console.log($(this).val());
|
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-02 11:34:03 -05:00
|
|
|
})(Zepto, AnimeClient);
|