From 9c2bcef8b1b1fa2ccfdbab265d4c8c5b7b0385d6 Mon Sep 17 00:00:00 2001 From: dekabu Date: Sun, 6 Jul 2025 09:24:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/js/main.js b/js/main.js index cd303c0..215fe17 100644 --- a/js/main.js +++ b/js/main.js @@ -93,20 +93,34 @@ async function verseToGrid(i) { div.onclick = () => window.open(`/${i}`, '_self') div.classList.add(verse.GENRE) div.innerHTML = `

${verse.TITLE}

${author.NAME} ${author.SUBNAME}
${verse.PRE}
` - div.style.display = 'flow-root' + div.style.display = 'block' + return div } -function addVersePart(part = 0) { - fetchJSON(`/api/versepart/${part}`) +let Part = 0 + +function addVersePart() { + fetchJSON(`/api/versepart/${Part++}`) .then(result => { if (result) { - let arr = [] - for (v in result) - arr.push(v) + const arr = Object.keys(result) + const first = arr[0] arr.reverse() - arr.forEach(i => { + arr.forEach(async i => { cacheVerse[i] = result[i] - verseToGrid(i) + const div = await verseToGrid(i) + if (i == first) { + const observer = new IntersectionObserver(entries => { + entries.forEach(entry => { + if (entry.isIntersecting) { + addVersePart() + console.log(2) + observer.unobserve(entry.target) + } + }) + }) + observer.observe(div) + } }) } })