Improve loading torrents
This commit is contained in:
parent
791e53c84f
commit
45ffca7f9b
@ -7,7 +7,7 @@ let orderBy, ascending; // use `setOrderBy()` to modify orderBy
|
|||||||
let lastOrderedValue, lastID;
|
let lastOrderedValue, lastID;
|
||||||
|
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function () {
|
||||||
if (query !== null && query !== "") {
|
if (query !== null && query !== "") {
|
||||||
orderBy = "RELEVANCE";
|
orderBy = "RELEVANCE";
|
||||||
}
|
}
|
||||||
@ -70,18 +70,18 @@ function load() {
|
|||||||
const ul = document.querySelector("main ul");
|
const ul = document.querySelector("main ul");
|
||||||
const template = document.getElementById("item-template").innerHTML;
|
const template = document.getElementById("item-template").innerHTML;
|
||||||
const reqURL = "/api/v0.1/torrents?" + encodeQueryData({
|
const reqURL = "/api/v0.1/torrents?" + encodeQueryData({
|
||||||
query : query,
|
query: query,
|
||||||
epoch : epoch,
|
epoch: epoch,
|
||||||
lastID : lastID,
|
lastID: lastID,
|
||||||
lastOrderedValue: lastOrderedValue,
|
lastOrderedValue: lastOrderedValue,
|
||||||
orderBy : orderBy,
|
orderBy: orderBy,
|
||||||
ascending : ascending
|
ascending: ascending
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("reqURL", reqURL);
|
console.log("reqURL", reqURL);
|
||||||
|
|
||||||
let req = new XMLHttpRequest();
|
let req = new XMLHttpRequest();
|
||||||
req.onreadystatechange = function() {
|
req.onreadystatechange = function () {
|
||||||
if (req.readyState !== 4)
|
if (req.readyState !== 4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -108,6 +108,11 @@ function load() {
|
|||||||
|
|
||||||
ul.innerHTML += Mustache.render(template, t);
|
ul.innerHTML += Mustache.render(template, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (torrents.length < 20) {
|
||||||
|
button.textContent = "No More Results";
|
||||||
|
button.setAttribute("disabled", "");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
req.open("GET", reqURL);
|
req.open("GET", reqURL);
|
||||||
|
Loading…
Reference in New Issue
Block a user