.
This commit is contained in:
@ -1,21 +1,23 @@
|
||||
let load = false;
|
||||
(() => {
|
||||
const posts = document.querySelector("#posts");
|
||||
document.addEventListener("wheel", e => {
|
||||
if((((document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop + window.innerHeight) + 310
|
||||
>= ((document.documentElement && document.documentElement.scrollHeight) || document.body.scrollHeight)) && !load) {
|
||||
load = true;
|
||||
fetch(`./api/p/${posts.dataset.last}`)
|
||||
.then(res => res.json())
|
||||
.then((msg, html = "") => {
|
||||
for(let i = 0; i < msg.items.length; i++)
|
||||
if(msg.items[i].id)
|
||||
html += `<li class="post"><a href="./${msg.items[i].id}" title="${msg.items[i].mime}"><img class="thumb" src="./t/${msg.items[i].id}.png" /></a></li>\n`;
|
||||
posts.insertAdjacentHTML("beforeend", html);
|
||||
posts.dataset.last = msg.last;
|
||||
load = false;
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
}
|
||||
});
|
||||
if(posts) {
|
||||
document.addEventListener("wheel", e => {
|
||||
if((((document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop + window.innerHeight) + 310
|
||||
>= ((document.documentElement && document.documentElement.scrollHeight) || document.body.scrollHeight)) && !load) {
|
||||
load = true;
|
||||
fetch(`./api/p/${posts.dataset.last}`)
|
||||
.then(res => res.json())
|
||||
.then((msg, html = "") => {
|
||||
for(let i = 0; i < msg.items.length; i++)
|
||||
if(msg.items[i].id)
|
||||
html += `<li class="post"><a href="./${msg.items[i].id}" title="${msg.items[i].mime}"><img class="thumb" src="./t/${msg.items[i].id}.png" /></a></li>\n`;
|
||||
posts.insertAdjacentHTML("beforeend", html);
|
||||
posts.dataset.last = msg.last;
|
||||
load = false;
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
Reference in New Issue
Block a user