aboutsummaryrefslogtreecommitdiff
path: root/ui/client-scripts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-02-28 00:24:52 +0100
committermetamuffin <metamuffin@disroot.org>2026-02-28 00:24:52 +0100
commit4841c08da8afa3e42c354fbc325ce56b6f997079 (patch)
tree3574919fc3e631e76e9e8a136c692f2a614e80b2 /ui/client-scripts
parent7930d543a2aa68d4ad2958605827d7eb1baa91f8 (diff)
downloadjellything-4841c08da8afa3e42c354fbc325ce56b6f997079.tar
jellything-4841c08da8afa3e42c354fbc325ce56b6f997079.tar.bz2
jellything-4841c08da8afa3e42c354fbc325ce56b6f997079.tar.zst
bad pagination
Diffstat (limited to 'ui/client-scripts')
-rw-r--r--ui/client-scripts/src/pagination.ts32
1 files changed, 18 insertions, 14 deletions
diff --git a/ui/client-scripts/src/pagination.ts b/ui/client-scripts/src/pagination.ts
index 380b20e..62362c1 100644
--- a/ui/client-scripts/src/pagination.ts
+++ b/ui/client-scripts/src/pagination.ts
@@ -1,18 +1,22 @@
-globalThis.addEventListener("DOMContentLoaded", () => {
- const el = document.querySelector(".next_page") as HTMLElement
+function init_paging() {
+ const el = document.querySelector(".next_page") as HTMLAnchorElement
if (!el) return
- const cont = document.body.parentElement!
- console.log(cont);
-
- cont.addEventListener("scroll", () => {
- const end = cont.scrollTop + cont.clientHeight
- console.log(end, cont.scrollHeight);
-
- if (end + 1000 > el.scrollHeight) {
- el.textContent = "Loading more..."
- el.click()
+ document.body.onscroll = () => {
+ const end = document.body.clientHeight - document.body.parentElement!.scrollTop - document.body.parentElement!.clientHeight
+ if (end < 200) {
+ document.body.onscroll = () => { }
+ load_next(el)
}
+ }
+}
- })
-})
+async function load_next(el: HTMLAnchorElement) {
+ const res = await fetch(el.href + "&no_scaff")
+ if (!res.ok) throw "aaa"
+ const ext = await res.text()
+ el.remove()
+ document.getElementById("main")!.innerHTML += ext
+ init_paging()
+}
+globalThis.addEventListener("DOMContentLoaded", init_paging)