mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[mod] infinite_scroll as preference
* oscar theme: code from searx/plugins/infinite_scroll.py * simple theme: new implementation
This commit is contained in:
parent
de32d543bc
commit
83a47ef70b
16 changed files with 203 additions and 44 deletions
|
|
@ -59,43 +59,40 @@ window.searxng = (function (w, d) {
|
|||
}
|
||||
};
|
||||
|
||||
searxng.http = function (method, url) {
|
||||
var req = new XMLHttpRequest(),
|
||||
resolve = function () {},
|
||||
reject = function () {},
|
||||
promise = {
|
||||
then: function (callback) { resolve = callback; return promise; },
|
||||
catch: function (callback) { reject = callback; return promise; }
|
||||
};
|
||||
searxng.http = function (method, url, data = null) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
var req = new XMLHttpRequest();
|
||||
req.open(method, url, true);
|
||||
|
||||
try {
|
||||
req.open(method, url, true);
|
||||
// On load
|
||||
req.onload = function () {
|
||||
if (req.status == 200) {
|
||||
resolve(req.response, req.responseType);
|
||||
} else {
|
||||
reject(Error(req.statusText));
|
||||
}
|
||||
};
|
||||
|
||||
// On load
|
||||
req.onload = function () {
|
||||
if (req.status == 200) {
|
||||
resolve(req.response, req.responseType);
|
||||
// Handle network errors
|
||||
req.onerror = function () {
|
||||
reject(Error("Network Error"));
|
||||
};
|
||||
|
||||
req.onabort = function () {
|
||||
reject(Error("Transaction is aborted"));
|
||||
};
|
||||
|
||||
// Make the request
|
||||
if (data) {
|
||||
req.send(data)
|
||||
} else {
|
||||
reject(Error(req.statusText));
|
||||
req.send();
|
||||
}
|
||||
};
|
||||
|
||||
// Handle network errors
|
||||
req.onerror = function () {
|
||||
reject(Error("Network Error"));
|
||||
};
|
||||
|
||||
req.onabort = function () {
|
||||
reject(Error("Transaction is aborted"));
|
||||
};
|
||||
|
||||
// Make the request
|
||||
req.send();
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
return promise;
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
searxng.loadStyle = function (src) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue