Missing pieces of previous commit
This commit is contained in:
parent
08176be4d0
commit
e20601053c
@ -260,7 +260,7 @@ function ajaxSerialize(data) {
|
|||||||
*
|
*
|
||||||
* @param {string} url - the url to request
|
* @param {string} url - the url to request
|
||||||
* @param {Object} config - the configuration object
|
* @param {Object} config - the configuration object
|
||||||
* @return {void}
|
* @return {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
AnimeClient.ajax = (url, config) => {
|
AnimeClient.ajax = (url, config) => {
|
||||||
// Set some sane defaults
|
// Set some sane defaults
|
||||||
@ -321,6 +321,8 @@ AnimeClient.ajax = (url, config) => {
|
|||||||
} else {
|
} else {
|
||||||
request.send(config.data);
|
request.send(config.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return request
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,6 +331,7 @@ AnimeClient.ajax = (url, config) => {
|
|||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {object|function} data
|
* @param {object|function} data
|
||||||
* @param {function} [callback]
|
* @param {function} [callback]
|
||||||
|
* @return {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
AnimeClient.get = (url, data, callback = null) => {
|
AnimeClient.get = (url, data, callback = null) => {
|
||||||
if (callback === null) {
|
if (callback === null) {
|
||||||
|
@ -260,7 +260,7 @@ function ajaxSerialize(data) {
|
|||||||
*
|
*
|
||||||
* @param {string} url - the url to request
|
* @param {string} url - the url to request
|
||||||
* @param {Object} config - the configuration object
|
* @param {Object} config - the configuration object
|
||||||
* @return {void}
|
* @return {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
AnimeClient.ajax = (url, config) => {
|
AnimeClient.ajax = (url, config) => {
|
||||||
// Set some sane defaults
|
// Set some sane defaults
|
||||||
@ -321,6 +321,8 @@ AnimeClient.ajax = (url, config) => {
|
|||||||
} else {
|
} else {
|
||||||
request.send(config.data);
|
request.send(config.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return request
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,6 +331,7 @@ AnimeClient.ajax = (url, config) => {
|
|||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {object|function} data
|
* @param {object|function} data
|
||||||
* @param {function} [callback]
|
* @param {function} [callback]
|
||||||
|
* @return {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
AnimeClient.get = (url, data, callback = null) => {
|
AnimeClient.get = (url, data, callback = null) => {
|
||||||
if (callback === null) {
|
if (callback === null) {
|
||||||
@ -589,7 +592,7 @@ const search = (query) => {
|
|||||||
AnimeClient.show('.cssload-loader');
|
AnimeClient.show('.cssload-loader');
|
||||||
|
|
||||||
// Do the api search
|
// Do the api search
|
||||||
AnimeClient.get(AnimeClient.url('/anime-collection/search'), { query }, (searchResults, status) => {
|
return AnimeClient.get(AnimeClient.url('/anime-collection/search'), { query }, (searchResults, status) => {
|
||||||
searchResults = JSON.parse(searchResults);
|
searchResults = JSON.parse(searchResults);
|
||||||
|
|
||||||
// Hide the loader
|
// Hide the loader
|
||||||
@ -601,13 +604,19 @@ const search = (query) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (AnimeClient.hasElement('.anime #search')) {
|
if (AnimeClient.hasElement('.anime #search')) {
|
||||||
|
let prevRequest = null;
|
||||||
|
|
||||||
AnimeClient.on('#search', 'input', AnimeClient.throttle(250, (e) => {
|
AnimeClient.on('#search', 'input', AnimeClient.throttle(250, (e) => {
|
||||||
const query = encodeURIComponent(e.target.value);
|
const query = encodeURIComponent(e.target.value);
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
search(query);
|
if (prevRequest !== null) {
|
||||||
|
prevRequest.abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
prevRequest = search(query);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +684,7 @@ AnimeClient.on('body.anime.list', 'click', '.plus-one', (e) => {
|
|||||||
|
|
||||||
const search$1 = (query) => {
|
const search$1 = (query) => {
|
||||||
AnimeClient.show('.cssload-loader');
|
AnimeClient.show('.cssload-loader');
|
||||||
AnimeClient.get(AnimeClient.url('/manga/search'), { query }, (searchResults, status) => {
|
return AnimeClient.get(AnimeClient.url('/manga/search'), { query }, (searchResults, status) => {
|
||||||
searchResults = JSON.parse(searchResults);
|
searchResults = JSON.parse(searchResults);
|
||||||
AnimeClient.hide('.cssload-loader');
|
AnimeClient.hide('.cssload-loader');
|
||||||
AnimeClient.$('#series-list')[ 0 ].innerHTML = renderMangaSearchResults(searchResults.data);
|
AnimeClient.$('#series-list')[ 0 ].innerHTML = renderMangaSearchResults(searchResults.data);
|
||||||
@ -683,13 +692,19 @@ const search$1 = (query) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (AnimeClient.hasElement('.manga #search')) {
|
if (AnimeClient.hasElement('.manga #search')) {
|
||||||
|
let prevRequest = null;
|
||||||
|
|
||||||
AnimeClient.on('#search', 'input', AnimeClient.throttle(250, (e) => {
|
AnimeClient.on('#search', 'input', AnimeClient.throttle(250, (e) => {
|
||||||
let query = encodeURIComponent(e.target.value);
|
let query = encodeURIComponent(e.target.value);
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
search$1(query);
|
if (prevRequest !== null) {
|
||||||
|
prevRequest.abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
prevRequest = search$1(query);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user